Skip to content

1/8 Fix dual-regional ESMF weight generation - #38

Open
Timothy-W-Hilton wants to merge 1 commit into
tglauch:mainfrom
Timothy-W-Hilton:fix-esmf-dual-regional-grids
Open

1/8 Fix dual-regional ESMF weight generation#38
Timothy-W-Hilton wants to merge 1 commit into
tglauch:mainfrom
Timothy-W-Hilton:fix-esmf-dual-regional-grids

Conversation

@Timothy-W-Hilton

Copy link
Copy Markdown

Fix dual-regional ESMF weight generation

Summary

ESMF_RegridWeightGen distinguishes 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 -r option consistently when both source and destination grids are regional.

The correction applies to:

  • ERA5-to-satellite weight generation;
  • land-cover-to-satellite conservative weights; and
  • satellite-to-WRF weight generation.

Why

The previous commands combined -r with source- and destination-specific regional flags. In the ESMF_RegridWeightGen command-line interface, --src_regional means source regional AND destination global, while --dst_regional means destination regional AND source global; -r is the option for both grids regional. Passing both --src_regional and --dst_regional is 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

  • Added regression tests that capture the constructed ESMF command before
    execution for the ERA5, land-cover, and WRF paths.
  • The tests assert that every affected command contains -r and contains
    neither --src_regional nor --dest_regional.
  • Focused test suite: 3 passed.

Visual evidence

I think it is likely (though I have not tested) that the --src_regional --dest_regional contradictory 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 👍):
L389_vprm_base_model_in_get_vprm_variables_ERA5_t2m_t0_02

regridded ERA5 t2m with --src_regional --dest_regional (does NOT look like New Zealand 😭):
L396_vprm_base_model_in_get_vprm_variables_ERA5_t2m_t0_without_rflag

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:
lon_error

After: longitude error with -r:
lon_error_rflag

Before: latitude error with --src_regional --dest_regional:
lat_error

After: latitude error with -r:
lat_error_rflag

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant