Hi @mfcnico , thanks for sharing your inputs!
In looking at your inputs and in revisiting your logfile from the original post in this topic, 6 hours of runtime sounds very reasonable for your landscape. As I mentioned before, this model’s runtime typically is consumed by the convolutions, which are decaying the influence of a stressor over a radius of MAX_DIST
. So in your original run, it looks like you have pixels that are 1m x 1m in size that are decaying over large distances, MAX_DIST=5km
in the case of threat amelh
and MAX_DIST=10km
in the case of ameind
. Your landscape doesn’t cover that much area (the raster is about 7.9km by 5.5km), but because these convolutions are covering so many pixels, it’s just going to take a very long time: if the threat with 1m x 1m pixels is decaying over 5km, computing the entire raster requires visiting approximately ((2*5000)^2)*(7918 * 5574) = 4413493200000000, or about 4.413 quadrillion pixels all in all. If the threat has 100m x 100m pixels, decaying that threat would require visiting approximately ((2*500)^2)*(7918 * 5574) = 441 349 320 000 (441 billion, much more computable). There’s only so much we can do to make that run fast on desktop hardware and so increasing the size of your pixels will make your model run much more quickly, as you discovered.
One thing I would like to mention, though, is that if you do need to run Habitat Quality at higher resolutions, you can try adjusting the n_workers
parameter in the InVEST settings to allow some of the convolutions to happen in parallel on separate processes. This is not a silver bullet, but can help compute certain problems more quickly.
But there is currently a limitation, as you originally posted about. That error:
2022-03-22 21:58:52,913 (pygeoprocessing.geoprocessing) geoprocessing.convolve_2d(2678) INFO starting convolve
2022-03-22 22:00:16,184 (pygeoprocessing.geoprocessing) geoprocessing.convolve_2d(2696) DEBUG start fill work queue thread
2022-03-22 22:00:16,185 (pygeoprocessing.geoprocessing) geoprocessing._fill_work_queue(2700) DEBUG fill work queue
2022-03-22 22:00:16,185 (pygeoprocessing.geoprocessing) geoprocessing.convolve_2d(2714) DEBUG start worker thread
2022-03-22 22:00:16,187 (pygeoprocessing.geoprocessing) geoprocessing.convolve_2d(2726) INFO 23206701680 sent to workers, wait for worker results
2022-03-22 22:01:16,195 (taskgraph.Task) Task.add_task(706) ERROR Something went wrong when adding task convolve_exponential_c_amelh (10), 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 "pygeoprocessing\geoprocessing.py", line 2730, in convolve_2d
File "queue.py", line 178, in get
_queue.Empty
2022-03-22 22:01:16,217 (natcap.invest.utils) utils.prepare_workspace(167) ERROR Exception while executing Habitat-Quality
Traceback (most recent call last):
File "natcap\invest\utils.py", line 165, in prepare_workspace
File "natcap\invest\ui\model.py", line 1649, in _logged_target
File "natcap\invest\habitat_quality.py", line 546, in execute
File "taskgraph\Task.py", line 674, in add_task
File "taskgraph\Task.py", line 1093, in _call
File "pygeoprocessing\geoprocessing.py", line 2730, in convolve_2d
File "queue.py", line 178, in get
_queue.Empty
This looks to be an issue with a fundamental assumption of our geoprocessing library, where it’s taking more than 60 seconds to compute statistics on the raster. This is a bug and we’ll address it in a later version of InVEST.
James