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

Using xesmf to efficiently regrid data to another resolution including vertical dimension #268

Open
nuvolet opened this issue Jun 7, 2023 · 6 comments

Comments

@nuvolet
Copy link

nuvolet commented Jun 7, 2023

Greetings,

I found a very useful reference this website to use xesmf to regrid data to another resolution:

https://climate-cms.org/posts/2021-04-09-xesmf-regrid.html

Nevertheless, here it is also detailed to do it for horizontal coordinates (lat, lon).

ds_out = xe.util.grid_2d(-180.0, 180.0, 2.5, -90.0, 90.0, 2.5)
regridder = xe.Regridder(ds, ds_out, 'bilinear', periodic=True)

I was wondering if is possible do it for vertical coordinates (vertical levels) by specifying by an array the number and intervals?.

Thanks in advance

@aulemahal
Copy link
Collaborator

A limited support for vertical regridding exists in ESMF and ESMpy, but it was sadly not yet implemented into xESMF. Note that ESMF only supports vertical coordinates given as a "radius". Not pressure levels, only distance from the earth center.

From my own experience, the dimension mismatch is usually such that it doesn't matter if the vertical regridding is done afterwards (horizontal lengths are much greater than vertical ones). If this is reasonable in your workflow, I would suggest regridding the horizontal coordinates with xESMF and then interpolating the vertical one with xarray.interp ?

@nuvolet
Copy link
Author

nuvolet commented Jun 9, 2023

Hi @aulemahal,
Thanks for your response and clarification.
Indeed it is sad this feature is not implemented in the xesmf. Definitely it would make it a whole complete tool for many people.
While I was waiting for any reply I was thinking something like you suggest.
Thanks again for your reply.

Cheers

@kevinrosa
Copy link

xgcm specializes in vertical interpolation. What is your specific use case?

@nuvolet
Copy link
Author

nuvolet commented Aug 2, 2023

@kevinrosa I have reanalysis files with a spatial and vertical resolution are L576x361_v72 and I want to have it as L288x192_v32, where the vertical dimension is by using hybrid level coefficients:

p(i,j,k)= A_{k}*P_0 + B_{k}*P_{s}(i,j)

@kevinrosa
Copy link

You can perform this transformation in 2 general steps:

  1. Use xESMF to horizontally remap from 576x361x72 to 288x192x72
  2. Use xgcm to vertically remap from 288x192x72 to 288x192x32 https://xgcm.readthedocs.io/en/latest/transform.html

Maybe experiment with the order of these 2 steps to determine whether it's more efficient to do the horizontal or vertical step first. I don't understand the specifics of your hybrid level coordinates equation so I can't offer any xgcm advice but I'd suggest reading the linked documentation which has good examples and then possibly opening an issue in the xgcm repo if you're still struggling.

@nuvolet
Copy link
Author

nuvolet commented Aug 2, 2023

@kevinrosa Thanks

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

No branches or pull requests

3 participants