1/8 Fix dual-regional ESMF weight generation - #38
Open
Timothy-W-Hilton wants to merge 1 commit into
Open
Conversation
Use ESMF_RegridWeightGen’s -r option consistently when both source and
destination grids are regional, replacing contradictory combinations of
-r, --src_regional, and --dest_regional. Apply the correction to
ERA5-to-satellite, land-cover-to-satellite, and satellite-to-WRF weight
generation, and add regression tests that capture each generated command
before ESMF executes.
Treat ESMF regridding grids as regional
Use ESMF_RegridWeightGen’s -r option alone when both source and
destination grids are regional so regional source and destination grids
are not interpreted as periodic global grids. This prevents invalid
connections across a regional grid’s opposing boundaries. Without this,
regrids can fail obviously near the 180th meridian, and quite possibly
fail subtly for some grids in other parts of world.
The ESMF_RegridWeightGen reference manual defines -r as the
dual-regional case; --src_regional instead means a regional source with
a global destination, while --dst_regional means a global source with a
regional destination. Remove the contradictory mixed-grid flags from the
generic ESMF and fractional land-cover command builders so regional
MODIS and ancillary- grid boundaries are handled according to the ESMF
documented interface.
from ESMF_RegridWeightGen docs:
-r - an optional argument specifying that the source and
destination grids are regional grids. If the argument
is not given, the grids are assumed to be global.
--src_regional - an optional argument specifying that the source is
a regional grid and the destination is a global grid.
--dst_regional - an optional argument specifying that the destination
is a regional grid and the source is a global grid.
Test dual-regional ESMF commands
Add regression coverage for ESMF_RegridWeightGen command construction in
WRF-output and fractional land-cover regridding paths. Mock external
execution while asserting that two regional grids use -r alone, omit the
contradictory one-sided regional flags, and retain the land-cover
unmapped-cell option.
Test ERA5 regional ESMF command
Add regression coverage for ERA5-to-satellite weight generation, which
is also affected by the dual-regional ESMF fix. The test constructs a
minimal meteorology handler, captures its generated command before ESMF
executes, and verifies that it uses -r alone rather than contradictory
per-grid regional flags.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix dual-regional ESMF weight generation
Summary
ESMF_RegridWeightGendistinguishes between a source-only regional grid, a destination-only regional grid, and the case where both grids are regional. Several pyVPRM command builders used a contradictory combination of these options. This PR uses ESMF's dual-regional-roption consistently when both source and destination grids are regional.The correction applies to:
Why
The previous commands combined
-rwith source- and destination-specific regional flags. In theESMF_RegridWeightGencommand-line interface,--src_regionalmeans source regional AND destination global, while--dst_regionalmeans destination regional AND source global;-ris the option for both grids regional. Passing both--src_regionaland--dst_regionalis therefore contradictory.Treating both grids as regional is required for these pyVPRM workflows and prevents ESMF from applying global-grid topology assumptions. The documented options are listed in the ESMF_RegridWeightGen reference manual.
Validation
execution for the ERA5, land-cover, and WRF paths.
-rand containsneither
--src_regionalnor--dest_regional.3 passed.Visual evidence
I think it is likely (though I have not tested) that the
--src_regional --dest_regionalcontradictory combination results in some really minimal regrid errors at all places/times. As demonstrated below it does cause the regrid to implode really spectacularly in the New Zealand area. The NZ ERA5 met regrid put pronounced East-West stripes into the regridded data:regridded ERA5 t2m with

-r(looks like New Zealand 👍):regridded ERA5 t2m with

--src_regional --dest_regional(does NOT look like New Zealand 😭):I generated the below diagnostic images while investigating a regional-grid failure. The longitude error field showed pronounced horizontal striping without the dual-regional option; with
-r, it is reduced to the small numerical residual expected from coordinate transformation and interpolation.Before: longitude error with

--src_regional --dest_regional:After: longitude error with

-r:Before: latitude error with

--src_regional --dest_regional:After: latitude error with

-r: