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

Load data only once for ESMPy regridders #2418

Closed bouweandela closed 3 months ago

bouweandela commented 3 months ago

Description

Realize the data only once for the ESMPy regridders.

Closes https://github.com/ESMValGroup/ESMValTool/issues/3590

Test recipe:

documentation:
  description: Example recipe that shows slow regridding.
  title: Example recipe that shows slow regridding.
  authors:
    - andela_bouwe
  maintainer:
    - andela_bouwe
  references:
    - acknow_project
  projects:
    - esmval

preprocessors:
  time_ocean_zonal_mean:
    custom_order: true
    climate_statistics:
      operator: mean
      period: full
    extract_levels:
      levels: [ 0,  10, 20, 50, 100, 200, 300, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, 3250, 3500, 3750, 4000, 4250, 4500, 4750, 5000, 5250, 5500, 5750]
      scheme: linear_extrapolate
      coordinate: depth
    regrid:
      target_grid: 1x1
      scheme: nearest
    zonal_statistics:
      operator: mean

datasets:
  - dataset: CanESM5-1
    exp: piControl
    ensemble: r1i1p2f1
    grid: gn
    institute: CCCma

diagnostics:
  diagnostic1:
    variables:
      thetao:
        mip: Omon
        project: CMIP6
        timerange: 6191/6220
        preprocessor: time_ocean_zonal_mean
    scripts: null

With these changes, the recipe takes less than a minute to run on my laptop. I did not wait for the process to complete (killed it after about 10 minutes), but reportedly it takes about an hour without these changes.


Before you get started

Checklist

It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the πŸ›  Technical or πŸ§ͺ Scientific review.


To help with the number pull requests:

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.51%. Comparing base (a51da92) to head (f15cba0).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2418 +/- ## ======================================= Coverage 94.51% 94.51% ======================================= Files 246 246 Lines 14020 14023 +3 ======================================= + Hits 13251 13254 +3 Misses 769 769 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

bouweandela commented 3 months ago

@chrisbillowsMO @ehogan Would it be possible to include this in the upcoming v2.11 release?