ESMValGroup / ESMValCore

ESMValCore: A community tool for pre-processing data from Earth system models in CMIP and running analysis scripts.
https://www.esmvaltool.org
Apache License 2.0
42 stars 38 forks source link

Automatically select a lazy regridding scheme in `regrid` preprocessor function for 2D lat/2D lon grids when possible #2405

Closed bouweandela closed 1 month ago

bouweandela commented 5 months ago

Through iris-esmf-regrid and the generic regridding schemes, it is possible to regrid grids with 2D latitude and 2D longitude coordinates lazily. However, these regridding schemes are not automatically selected and instead the non-lazy ESMPyLinear/ESMPyNearest/ESMPyAreaWeighted built-in schemes are selected. This results in poor computational performance by default.

@schlunma @sloosvel Do you think it would be possible to improve the default so we prefer lazy schemes and automatically select those when possible?

sloosvel commented 5 months ago

I'm not sure this is possible because the generic regridding schemes don't work for all models, you can get results such as this one using ESMFAreaWeighted:

image

bouweandela commented 5 months ago

Could you provide some more details on that image, to help me understand the issue?

sloosvel commented 5 months ago

It happens to models that have OceanGridFix applied to them. The generated bounds work fine to regrid with the non-lazy regridders, but for some reason when you call the lazy AreaWeighted scheme, this happens. You can check with the recipe below for instance:

documentation:
  title: test regrid
  description: |
    Test regrid
  authors:
     - loosveldt-tomas_saskia

datasets:
   - {dataset: FGOALS-g3, ensemble: r1i1p1f1, exp: historical, project: CMIP6, grid: gn, timerange: 1951/1951}

preprocessors:
  pp:
    regrid:
      target_grid: 1.5x1.5
      scheme: 
        reference: esmf_regrid.schemes:ESMFAreaWeighted

diagnostics:
  test_regrid:
    variables:
      tos:
        mip: Omon
        preprocessor: pp
    scripts: null
bouweandela commented 4 months ago

An overview of regridding a 2D ocean variable (sea surface temperature) for most models in CMIP6 to a 1x1 grid is available here and with xesmf here. Created with the debug-regrid branch which keeps going when a regridding error occurs and adds a bit of info.

A first inspection reveals the following issues:

bouweandela commented 4 months ago

It happens to models that have OceanGridFix applied to them.

@sloosvel I tried the recipe, but am getting poor results with all available regridders. Did I miss something? I ran this recipe and got the following images: tos_default_CMIP6_FGOALS-g3_Omon_historical_r1i1p1f1_tos_gn_195101-195101 Default built-in ESMPy based regridder tos_esmpy_CMIP6_FGOALS-g3_Omon_historical_r1i1p1f1_tos_gn_195101-195101 iris-esmf-regrid regridder tos_xesmf_CMIP6_FGOALS-g3_Omon_historical_r1i1p1f1_tos_gn_195101-195101 xesmf regridder from #2433

sloosvel commented 4 months ago

You are right, I don't know why I was under the impression it worked for the non-lazy schemes.