Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an iris-esmf-regrid based regridding scheme #2457

Merged
merged 25 commits into from
Sep 4, 2024

Conversation

bouweandela
Copy link
Member

@bouweandela bouweandela commented Jun 14, 2024

Description

Add an iris-esmf-regrid-based regridding scheme and use it as the default scheme for irregular grids and meshes

Example usage (as generic scheme) in preprocessor in recipe:

regrid:
  target_grid: 1x1
  scheme:
    reference: esmvalcore.preprocessor.regrid_schemes:IrisESMFRegrid
    method: bilinear
    mdtol: 0.7

Example plots for regridding 2D variable tos to a 1x1 degree grid are available here.
Example plots for regridding 3D variable thetao to a 1x1 degree grid and subsequently extracting the 500m depth level are available here.

Closes #2405.

Links to documentation:


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:

@bouweandela bouweandela added preprocessor Related to the preprocessor dask related to improvements using Dask labels Jun 14, 2024
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.72%. Comparing base (343368e) to head (a848468).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2457      +/-   ##
==========================================
+ Coverage   94.70%   94.72%   +0.02%     
==========================================
  Files         248      249       +1     
  Lines       14002    14071      +69     
==========================================
+ Hits        13260    13329      +69     
  Misses        742      742              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bouweandela bouweandela marked this pull request as ready for review July 17, 2024 15:16
Copy link
Contributor

@schlunma schlunma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good already Bouwe, it's great to see our custom ESMF code being replaced. Some additional comments:

  1. In the PR description, please replace "unstructured" with "irregular" (you are replacing the schemes for irregular)
  2. Would it make sense to deprecate our own ESMFPy... schemes? I don't think they are really useful anymore given that we have a much better solution for this now.
  3. Would it maybe even make sense and go one step further by also replacing the schemes for regular regridding? This would make our code even easier. I think esmf-regrid also supports that kind of regridding with the same schemes. In principle, it would even work for unstructured grids, but in this case the data would need to be UGRID-compliant, and I am not sure we can enforce that (yet).

doc/conf.py Outdated Show resolved Hide resolved
esmvalcore/preprocessor/_regrid.py Outdated Show resolved Hide resolved
esmvalcore/preprocessor/_regrid_iris_esmf_regrid.py Outdated Show resolved Hide resolved
esmvalcore/preprocessor/_regrid_iris_esmf_regrid.py Outdated Show resolved Hide resolved
tests/unit/preprocessor/_regrid/test_regrid.py Outdated Show resolved Hide resolved
tests/unit/preprocessor/_regrid/test_regrid.py Outdated Show resolved Hide resolved
@bouweandela
Copy link
Member Author

Thanks for reviewing @schlunma!

In the PR description, please replace "unstructured" with "irregular" (you are replacing the schemes for irregular)

I mixed those two up, it should be better now.

Would it make sense to deprecate our own ESMFPy... schemes? I don't think they are really useful anymore given that we have a much better solution for this now.

Yes, but maybe with the next release of iris-esmf-regrid where the nearest scheme is also supported. @stephenworsley mentioned that he expects to sort out SciTools-incubator/iris-esmf-regrid#276 and SciTools-incubator/iris-esmf-regrid#369 and make a new release soon.

Would it maybe even make sense and go one step further by also replacing the schemes for regular regridding? This would make our code even easier. I think esmf-regrid also supports that kind of regridding with the same schemes. In principle, it would even work for unstructured grids, but in this case the data would need to be UGRID-compliant, and I am not sure we can enforce that (yet).

I like this idea, but there is an issue with ESMF that prevents parallelisation using Dask (see #2316). I have reported it to the ESMF developers and they said they saw opportunities to solve it, but I'm not sure when this will be solved. I would be keen to improve our parallisation scheme for those cases where ESMF is not needed and then it is relevant to only use it when is really needed.

@schlunma
Copy link
Contributor

Thanks for addressing my comments @bouweandela! Could you please add some documentation about the new schemes for meshes? It would also be great to use a common naming convention for this, e.g., at the moment, the documentation only talks about UGRID instead of iris meshes (in the ICON doc). Maybe you could move that part to regridding docs and only reference that in the ICON-specific section?

@bouweandela
Copy link
Member Author

Would it make sense to deprecate our own ESMFPy... schemes? I don't think they are really useful anymore given that we have a much better solution for this now.

Done in 9aaf1b2

@bouweandela
Copy link
Member Author

@schlunma I've improved the documentation and testing and also added support for lazy nearest neighbour regridding now because this is at least partly supported with the new iris-esmf-regrid v0.11. Could you do another review, please?

Copy link
Contributor

@schlunma schlunma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I just tested this extensively with all different grid types, and everything works as excepted 🚀

Just have a couple of minor comments on the doc. Cheers!

doc/quickstart/find_data.rst Outdated Show resolved Hide resolved
doc/recipe/preprocessor.rst Outdated Show resolved Hide resolved
esmvalcore/preprocessor/_regrid_esmpy.py Show resolved Hide resolved
esmvalcore/preprocessor/_regrid_iris_esmf_regrid.py Outdated Show resolved Hide resolved
esmvalcore/preprocessor/_regrid_iris_esmf_regrid.py Outdated Show resolved Hide resolved
esmvalcore/preprocessor/_regrid_iris_esmf_regrid.py Outdated Show resolved Hide resolved
esmvalcore/preprocessor/_regrid_iris_esmf_regrid.py Outdated Show resolved Hide resolved
@bouweandela
Copy link
Member Author

Thanks for reviewing @schlunma. I think I have addressed all comments now, could you have another look please?

Copy link
Contributor

@schlunma schlunma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks @bouweandela! This will facilitate regridding enormously 🚀

@schlunma schlunma added this to the v2.12.0 milestone Sep 4, 2024
@sloosvel sloosvel merged commit a35d50d into main Sep 4, 2024
5 of 6 checks passed
@sloosvel sloosvel deleted the add-iris-esmf-regrid-scheme branch September 4, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dask related to improvements using Dask preprocessor Related to the preprocessor
Projects
3 participants