Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UFRM: error-checking when LULC and biophysical table mismatch #686

Closed
davemfish opened this issue Oct 13, 2021 · 1 comment · Fixed by #698
Closed

UFRM: error-checking when LULC and biophysical table mismatch #686

davemfish opened this issue Oct 13, 2021 · 1 comment · Fixed by #698
Assignees
Labels
bug Something isn't working
Milestone

Comments

@davemfish
Copy link
Contributor

davemfish commented Oct 13, 2021

First, a user reported a cryptic IndexError when the biophysical table was missing values in the LULC raster. https://community.naturalcapitalproject.org/t/urban-flood-risk-mitigation-indexerror/2215/3

Traceback (most recent call last):
File “site-packages\natcap\invest\ui\execution.py”, line 68, in run
File “site-packages\natcap\invest\ui\model.py”, line 1649, in _logged_target
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 241, in execute
File “site-packages\taskgraph\Task.py”, line 747, in add_task
File “site-packages\taskgraph\Task.py”, line 1234, in _call
File “site-packages\pygeoprocessing\geoprocessing.py”, line 438, in raster_calculator
File “site-packages\natcap\invest\urban_flood_risk_mitigation.py”, line 775, in _lu_to_cn_op
File “site-packages\scipy\sparse_index.py”, line 35, in getitem
File “site-packages\scipy\sparse_index.py”, line 139, in _validate_indices
File “site-packages\scipy\sparse_index.py”, line 171, in _asindices
IndexError: index (127) out of range

Second, when I tried to reproduce this error by modifying the sample data, I accidentally found a related bug. So long as the lucode column in the biophysical table contains a row with an lucode >= to largest int value in the LULC raster, we don't even see this IndexError. The model will complete successfully even when many/all of the LULC values are missing from the biophysical table. Presumably the results are invalid in this case.

To reproduce, edit the sample data table to be like this:

lucode,Description,NEH type (to define CN),CN_A,CN_B,CN_C,CN_D,SW_type,EMC
24,Tundra,,1,1,1,1,3000,0

This all seems a byproduct of using a sparse matrix with indices defined based on the lucode values found in the table.

@davemfish davemfish added the bug Something isn't working label Oct 13, 2021
@davemfish davemfish added this to the 3.9.2 milestone Oct 13, 2021
@davemfish
Copy link
Contributor Author

We should also be sure the solution includes better error messaging that can help users debug their table-LULC mismatches.

@davemfish davemfish self-assigned this Oct 22, 2021
@davemfish davemfish added the in progress This issue is actively being worked on label Oct 22, 2021
davemfish added a commit to davemfish/invest that referenced this issue Oct 25, 2021
davemfish added a commit to davemfish/invest that referenced this issue Oct 25, 2021
@davemfish davemfish removed the in progress This issue is actively being worked on label Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant