Smarter area weight grid saves memory in grdfilter #7192
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of precomputing an area weight grid for all input nodes (and hence doubling the memory requirement of the grid), we now only do so for 3 nodes along each row (west, middle, east) since all the columns away from the ends have the same weight along a row and only vary with latitude. The west and east columns may differ depending on boundary conditions, periodicity (360), and gridline vs pixel registration. It also speeds up the precalculation itself but mostly saves memory for large grids to be filtered in grdfilter. The case that triggered this was a 16 Gb in-memory grid that resulted in another 16 Gb memory grid being used - this now drops down to 1 Mb.
I have run all tests and it looks unchanged. Happy to have someone do a few filter operations to see if they notice anything, but the new logic looks solid to me. I had to add a silly API bool variable to bypass a test that for this strange grid (say 3 columns and 43600 rows) would fail in BC setting - this skips that check.