TypeError: ufunc 'isfinite' in HQ model

Hi everyone,
I have an issue running the HQ model with both versions on Windows 10.

I already ran the model in January with version 3.7.0 and it finished within 2 minutes. This time, with modified threat and sensitivity tables, the model ran several hours without any result.
InVEST-Habitat-Quality-log-2020-03-12–09_46_43.txt (455.4 KB)

I decided to try version 3.8.0 but now I get the error:
TypeError: ufunc ‘isfinite’ not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ‘‘safe’’
InVEST-Habitat-Quality-log-2020-03-12–20_27_47.txt (2.7 KB)

Cheers,
Gloria

Hi Gloria,

There was a change in Habitat Quality for version 3.8.0 that changes the way nodata values in the threat rasters are handled. Specifically, nodata pixels are now reclassified to value of 0, meaning no threat present.

As a result, it is required that the input threat rasters have a defined nodata value. The error seen here will happen if the nodata value is undefined. Can you check that for your threat rasters? In particular the Rubber threat?

Hi Dave,
I had defined my nodata values to 0. But you are right, for whatever reason I still found nodata values in my rasters now and defined them to 0.
Now, I don’t get the error anymore but the model again doesn’t come to an end in version 3.8.0.
InVEST-Habitat-Quality-log-2020-03-13–05_32_04.txt (13.4 KB)

Okay that’s progress.

From the log it looks like the model is still running, but won’t finish anytime soon. It’s about 0.4% of the way through a convolution after 5 minutes.

How many pixels are in your Rubber threat raster? From the logging, it looks like the pixel size might be 5 meters? Is that right? The overall size of the raster cold explain why this step will take a long time.

My rasters have 40.144.104 pixels. But as I said, two months ago I used the exact same rasters and I had no problem at all.
Is there anything else I can try?

Hi @fipsi2000,

In addition to the fix @dave mentioned about how nodata values are handled, InVEST 3.8.0 also includes a change in how threat rasters are handled: all rasters are now adjusted in size to match the size and shape of your LULC. In InVEST 3.7.0 and earlier, only the intersection of the bounding boxes of all of your rasters (LULC and Threats) were used in the model. As a result of this change, the 3.8.0 model’s runtime may be a whole lot longer than what it previously was for your study area if your LULC is significantly larger (in terms of geographic area) than your threat rasters.

Hope this helps!
James

1 Like

Hi James,
thank you for the additional information. I decreased the raster resolution and now it’s running faster!