Fix: allow downscaling to operate on lat/lon subset of coarse global data #764
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.
ACE inference can be configured to save only a portion of the globe, but when using regional input coarse data to HiRO we ran into a bug where inferred coordinate ranges at write time were incorrect. This was because
adjust_fine_coord_rangeused to subselect the saved model topography data uses the coarse data tensor shape (<global bounds) and topography tensor shape (global bounds) to infer the downscale factor ifdownscale_factoris not passed as an arg. The error in coordinate subselection propagates further, resulting in the runtime error.This PR fixes the issue by passing
model.downscale_factorthrough the build methods so thatadjust_fine_coord_rangecan use it to get the correct coord range. It is already an optional input to the function because the cascaded model generation run into this scenario.I confirmed this works by running inference on a subset of 100 km data that failed previously. I attempted to add this case to the integration tests for inference but found it would require adding a lot more complexity to the test data generation since other tests currently assume the fine and coarse test coordinates match in range. I could add some optional indirect parameterization but then the test inference model config uses the fine data as the topography so there would also have to be updates to change it to something that doesn't match the coarse test data. After all those changes it starts to feel like the integration test data is constructed so differently from what we'd encounter in a production run that the test may not be very useful.