NDR numpy error in _map_surface_load_op

What is the issue or question you have? An error shows while running the NDR model.

What do you expect to happen? find the place of occurrence of error.

What have you tried so far? Tried several times by changing type of csv table.

Attach the logfile here:11/28/2023 09:24:11 natcap. invest.utils Level 100 Writing log messages to [D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR\InVEST-Nutrient-Delivery-Ratio-log-2023-11-28–09_24_11.txt]

11/28/2023 09:24:11 natcap.invest.ui.model Level 100 Starting model with parameters:

Arguments for InVEST natcap.invest.ndr.ndr 3.12.0:

biophysical_table_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/NDR _Biophysical Table.csv

calc_n True

calc_p False

dem_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/DEM.tif

k_param 2

lulc_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/LU.tif

n_workers -1

results_suffix

runoff_proxy_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Annual_RF.tif

subsurface_critical_length_n 150

subsurface_eff_n 0.8

threshold_flow_accumulation 1000

watersheds_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Watershed1.shp

workspace_dir D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR

11/28/2023 09:24:21 pygeoprocessing.geoprocessing ERROR exception encountered in raster_calculator

Traceback (most recent call last):

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 09:24:21 taskgraph.Task ERROR Something went wrong when adding task map surface load n (19), terminating taskgraph.

Traceback (most recent call last):

File “taskgraph\Task.py”, line 674, in add_task

File “taskgraph\Task.py”, line 1093, in _call

File “natcap\invest\ndr\ndr.py”, line 1085, in _map_surface_load

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 09:24:21 natcap.invest.utils ERROR Exception while executing Nutrient-Delivery-Ratio

Traceback (most recent call last):

File “natcap\invest\utils.py”, line 164, in prepare_workspace

File “natcap\invest\ui\model.py”, line 1632, in _logged_target

File “natcap\invest\ndr\ndr.py”, line 562, in execute

File “taskgraph\Task.py”, line 674, in add_task

File “taskgraph\Task.py”, line 1093, in _call

File “natcap\invest\ndr\ndr.py”, line 1085, in _map_surface_load

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 09:42:43 natcap.invest.utils Level 100 Writing log messages to [D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR\InVEST-Nutrient-Delivery-Ratio-log-2023-11-28–09_42_43.txt]

11/28/2023 09:42:43 natcap.invest.ui.model Level 100 Starting model with parameters:

Arguments for InVEST natcap.invest.ndr.ndr 3.12.0:

biophysical_table_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/NDR _Biophysical Table.csv

calc_n True

calc_p False

dem_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/DEM.tif

k_param 2

lulc_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/LU.tif

n_workers -1

results_suffix

runoff_proxy_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Annual_RF.tif

subsurface_critical_length_n 150

subsurface_eff_n 0.8

threshold_flow_accumulation 1000

watersheds_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Watershed1.shp

workspace_dir D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR

11/28/2023 09:42:43 pygeoprocessing.geoprocessing ERROR exception encountered in raster_calculator

Traceback (most recent call last):

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 09:42:43 taskgraph.Task ERROR Something went wrong when adding task map surface load n (19), terminating taskgraph.

Traceback (most recent call last):

File “taskgraph\Task.py”, line 674, in add_task

File “taskgraph\Task.py”, line 1093, in _call

File “natcap\invest\ndr\ndr.py”, line 1085, in _map_surface_load

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 09:42:43 natcap.invest.utils ERROR Exception while executing Nutrient-Delivery-Ratio

Traceback (most recent call last):

File “natcap\invest\utils.py”, line 164, in prepare_workspace

File “natcap\invest\ui\model.py”, line 1632, in _logged_target

File “natcap\invest\ndr\ndr.py”, line 562, in execute

File “taskgraph\Task.py”, line 674, in add_task

File “taskgraph\Task.py”, line 1093, in _call

File “natcap\invest\ndr\ndr.py”, line 1085, in _map_surface_load

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 09:54:28 natcap.invest.utils Level 100 Writing log messages to [D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR\InVEST-Nutrient-Delivery-Ratio-log-2023-11-28–09_54_28.txt]

11/28/2023 09:54:28 natcap.invest.ui.model Level 100 Starting model with parameters:

Arguments for InVEST natcap.invest.ndr.ndr 3.12.0:

biophysical_table_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/NDR _Biophysical Table.csv

calc_n True

calc_p False

dem_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/DEM.tif

k_param 2

lulc_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/LU.tif

n_workers -1

results_suffix

runoff_proxy_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Annual_RF.tif

subsurface_critical_length_n 150

subsurface_eff_n 0.8

threshold_flow_accumulation 1000

watersheds_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Watershed1.shp

workspace_dir D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR

11/28/2023 09:54:31 pygeoprocessing.geoprocessing ERROR exception encountered in raster_calculator

Traceback (most recent call last):

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 09:54:31 taskgraph.Task ERROR Something went wrong when adding task map surface load n (19), terminating taskgraph.

Traceback (most recent call last):

File “taskgraph\Task.py”, line 674, in add_task

File “taskgraph\Task.py”, line 1093, in _call

File “natcap\invest\ndr\ndr.py”, line 1085, in _map_surface_load

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 09:54:31 natcap.invest.utils ERROR Exception while executing Nutrient-Delivery-Ratio

Traceback (most recent call last):

File “natcap\invest\utils.py”, line 164, in prepare_workspace

File “natcap\invest\ui\model.py”, line 1632, in _logged_target

File “natcap\invest\ndr\ndr.py”, line 562, in execute

File “taskgraph\Task.py”, line 674, in add_task

File “taskgraph\Task.py”, line 1093, in _call

File “natcap\invest\ndr\ndr.py”, line 1085, in _map_surface_load

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 09:57:37 natcap.invest.utils Level 100 Writing log messages to [D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR\InVEST-Nutrient-Delivery-Ratio-log-2023-11-28–09_57_37.txt]

11/28/2023 09:57:37 natcap.invest.ui.model Level 100 Starting model with parameters:

Arguments for InVEST natcap.invest.ndr.ndr 3.12.0:

biophysical_table_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/NDR _Biophysical Table.csv

calc_n True

calc_p False

dem_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/DEM.tif

k_param 2

lulc_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/LU.tif

n_workers -1

results_suffix

runoff_proxy_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Annual_RF.tif

subsurface_critical_length_n 150

subsurface_eff_n 0.8

threshold_flow_accumulation 1000

watersheds_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Watershed1.shp

workspace_dir D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR

11/28/2023 09:57:38 pygeoprocessing.geoprocessing ERROR exception encountered in raster_calculator

Traceback (most recent call last):

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 09:57:38 taskgraph.Task ERROR Something went wrong when adding task map surface load n (19), terminating taskgraph.

Traceback (most recent call last):

File “taskgraph\Task.py”, line 674, in add_task

File “taskgraph\Task.py”, line 1093, in _call

File “natcap\invest\ndr\ndr.py”, line 1085, in _map_surface_load

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 09:57:38 natcap.invest.utils ERROR Exception while executing Nutrient-Delivery-Ratio

Traceback (most recent call last):

File “natcap\invest\utils.py”, line 164, in prepare_workspace

File “natcap\invest\ui\model.py”, line 1632, in _logged_target

File “natcap\invest\ndr\ndr.py”, line 562, in execute

File “taskgraph\Task.py”, line 674, in add_task

File “taskgraph\Task.py”, line 1093, in _call

File “natcap\invest\ndr\ndr.py”, line 1085, in _map_surface_load

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 10:06:20 natcap.invest.utils Level 100 Writing log messages to [D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR\InVEST-Nutrient-Delivery-Ratio-log-2023-11-28–10_06_20.txt]

11/28/2023 10:06:20 natcap.invest.ui.model Level 100 Starting model with parameters:

Arguments for InVEST natcap.invest.ndr.ndr 3.12.0:

biophysical_table_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/NDR _Biophysical Table.csv

calc_n True

calc_p False

dem_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/DEM.tif

k_param 2

lulc_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/LU.tif

n_workers -1

results_suffix

runoff_proxy_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Annual_RF.tif

subsurface_critical_length_n 150

subsurface_eff_n 0.8

threshold_flow_accumulation 1000

watersheds_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Watershed1.shp

workspace_dir D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR

11/28/2023 10:06:20 natcap.invest.utils ERROR ‘key_field’ : ‘lucode’ could not be found as a column in the table. Table path: D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/NDR _Biophysical Table.csv.

11/28/2023 10:06:20 natcap.invest.utils ERROR Exception while executing Nutrient-Delivery-Ratio

Traceback (most recent call last):

File “natcap\invest\utils.py”, line 164, in prepare_workspace

File “natcap\invest\ui\model.py”, line 1632, in _logged_target

File “natcap\invest\ndr\ndr.py”, line 370, in execute

File “natcap\invest\utils.py”, line 554, in build_lookup_from_csv

File “pandas\util_decorators.py”, line 311, in wrapper

File “pandas\core\frame.py”, line 5503, in set_index

KeyError: “None of [‘lucode’] are in the columns”

11/28/2023 10:07:19 natcap.invest.utils Level 100 Writing log messages to [D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR\InVEST-Nutrient-Delivery-Ratio-log-2023-11-28–10_07_19.txt]

11/28/2023 10:07:19 natcap.invest.ui.model Level 100 Starting model with parameters:

Arguments for InVEST natcap.invest.ndr.ndr 3.12.0:

biophysical_table_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/NDR _Biophysical Table.csv

calc_n True

calc_p False

dem_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/DEM.tif

k_param 2

lulc_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/LU.tif

n_workers -1

results_suffix

runoff_proxy_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Annual_RF.tif

subsurface_critical_length_n 150

subsurface_eff_n 0.8

threshold_flow_accumulation 1000

watersheds_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Watershed1.shp

workspace_dir D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR

11/28/2023 10:07:19 pygeoprocessing.geoprocessing ERROR exception encountered in raster_calculator

Traceback (most recent call last):

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 10:07:19 taskgraph.Task ERROR Something went wrong when adding task map surface load n (19), terminating taskgraph.

Traceback (most recent call last):

File “taskgraph\Task.py”, line 674, in add_task

File “taskgraph\Task.py”, line 1093, in _call

File “natcap\invest\ndr\ndr.py”, line 1085, in _map_surface_load

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 10:07:19 natcap.invest.utils ERROR Exception while executing Nutrient-Delivery-Ratio

Traceback (most recent call last):

File “natcap\invest\utils.py”, line 164, in prepare_workspace

File “natcap\invest\ui\model.py”, line 1632, in _logged_target

File “natcap\invest\ndr\ndr.py”, line 562, in execute

File “taskgraph\Task.py”, line 674, in add_task

File “taskgraph\Task.py”, line 1093, in _call

File “natcap\invest\ndr\ndr.py”, line 1085, in _map_surface_load

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 13:56:38 natcap.invest.utils Level 100 Writing log messages to [D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR\InVEST-Nutrient-Delivery-Ratio-log-2023-11-28–13_56_38.txt]

11/28/2023 13:56:38 natcap.invest.ui.model Level 100 Starting model with parameters:

Arguments for InVEST natcap.invest.ndr.ndr 3.12.0:

biophysical_table_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/NDR _Biophysical Table.csv

calc_n True

calc_p False

dem_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/DEM.tif

k_param 2

lulc_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/LU.tif

n_workers -1

results_suffix

runoff_proxy_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Annual_RF.tif

subsurface_critical_length_n 150

subsurface_eff_n 0.8

threshold_flow_accumulation 1000

watersheds_path D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR/Watershed1.shp

workspace_dir D:/Resource Info Sys/2023/Ecosystem services/Maragala/NDR

11/28/2023 13:56:43 pygeoprocessing.geoprocessing ERROR exception encountered in raster_calculator

Traceback (most recent call last):

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 13:56:43 taskgraph.Task ERROR Something went wrong when adding task map surface load n (19), terminating taskgraph.

Traceback (most recent call last):

File “taskgraph\Task.py”, line 674, in add_task

File “taskgraph\Task.py”, line 1093, in _call

File “natcap\invest\ndr\ndr.py”, line 1085, in _map_surface_load

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

11/28/2023 13:56:43 natcap.invest.utils ERROR Exception while executing Nutrient-Delivery-Ratio

Traceback (most recent call last):

File “natcap\invest\utils.py”, line 164, in prepare_workspace

File “natcap\invest\ui\model.py”, line 1632, in _logged_target

File “natcap\invest\ndr\ndr.py”, line 562, in execute

File “taskgraph\Task.py”, line 674, in add_task

File “taskgraph\Task.py”, line 1093, in _call

File “natcap\invest\ndr\ndr.py”, line 1085, in _map_surface_load

File “pygeoprocessing\geoprocessing.py”, line 443, in raster_calculator

File “natcap\invest\ndr\ndr.py”, line 1082, in _map_surface_load_op

numpy.core._exceptions._UFuncNoLoopError: ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘int32’), dtype(‘<U32’)) → None

Pls help on recovering the error occurred.

Hi @tamasha,
This looks like an error with your CSV table. You can upload it here and I’ll try to identify the problem. Please also try updating to the latest version of InVEST, 3.14.0.

Dear E Soth

Pls see the attached csv file hereto and help me on this matter and I have tried several ways to overcome this matter. But failed.
Even change the bit depth of rasters. Failed.

Pls help on this matter.

Kind regards
Tamasha/SEO/Central Environmental Authority
Sri Lanka

NDR _Biophysical Table.csv (1.07 KB)

Hello @tamasha , thanks for uploading your table!

The error is that you have a blank value in the proportion_subsurface_n column for the Rubber LULC code. All values for all columns must be defined for the model to work as expected.

Please try this out and let us know how it goes!
James

Dear James

Thanks a lot. The model runs properly. I didn’t see the blank value even I look at the table many times. I tried with value type in the CSV.
Thanks again for the support.

Kind regards
Tamasha Fernando/Senior Environmental Officer
Central Environmental Authority
Sri Lanka

OK! Well, if the model is running as expected, then that’s great. Please be sure to let us know if you have any further questions by opening a new topic.

Thanks,
James

Dear James
The model runs correctly. Will be in touch when a problem arises while running the Invest models. Thanks for the great help.

Regards
Tamasha

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.