pangeo-data / xESMF

Universal Regridder for Geospatial Data
http://xesmf.readthedocs.io/
MIT License
183 stars 32 forks source link

Regridding towards curvilinear grids #287

Open jbeaumet opened 11 months ago

jbeaumet commented 11 months ago

Hi all, I am a new user of xESMF, the regridding package looks very promising. I would like to use xe regridder to upscale (so with method "conservative" or conservative-normed") satellite data wich are rectilinear to the domains of WRF model I am using which are curvilinear. I have read the docs (https://xesmf.readthedocs.io/en/latest/notebooks/Curvilinear_grid.html) and it contains an example of the other way round: regridding from curvilinear to rectilinear, although it says it is possible to regrid towards curvilinear grids. I have tried, it is not working and this far my understanding of it, is that it is not working because in the wrf file there is no information on the lat/lon values of cell boundaries (lat_b, lon_b in the exemple). It is does not seems obvious where to get this information from WRF output files but I imagine I could use XLONG_U/XLONG_V and XLAT_U/XLAT_V from the u,v component of the winds which are usually given on the border of grid cells ? I was wondering if someone allready overcome this issue since there many wrf users ? May-be the issues with data from rasm model mentionned in the doc ? Thanks in advance from your help and regards ! Julien

aulemahal commented 11 months ago

I can't confidently answer the question as I am not a user of WRF, but reading the doc here : https://amps-backup.ucar.edu/information/configuration/wrf_grid_structure.html, I think you are right.

I'm guessing lat_b would be XLAT_V and lon_b would be XLONG_U ?

Otherwise, cf_xarray has capacity to guess the bounds : https://cf-xarray.readthedocs.io/en/latest/bounds.html. But the approximation can be quite crude, depending on the curvature of the grid.

jbeaumet commented 11 months ago

I can't confidently answer the question as I am not a user of WRF, but reading the doc here : https://amps-backup.ucar.edu/information/configuration/wrf_grid_structure.html, I think you are right.

I'm guessing lat_b would be XLAT_V and lon_b would be XLONG_U ?

Otherwise, cf_xarray has capacity to guess the bounds : https://cf-xarray.readthedocs.io/en/latest/bounds.html. But the approximation can be quite crude, depending on the curvature of the grid.

"Thanks a lot for your reply. I think you are right, I am going to try using lat_b as XLAT_V and XLONG_U as lon_b in xESMF and also may-be verify all these coordinates by plotting them in qgis but it makes sense."

huard commented 10 months ago

Salut Julien @jbeaumet

Should we consider this issue resolved?

Also, please consider submitting a short "recipe" for the documentation on how to regrid for WRF, I'm confident this would be useful to many people.

jbeaumet commented 10 months ago

Salut David,

No unfortunately, it is not 100% resolved, the advices of Pascal are correct, unfortunately, the lat_u/v and lon_u/v given in wrf output files have the dimensions of ny+1,nx or ny,nx+1 while the functions from xESMF expect borders coordinates with dimensions ny+1,nx+1. To my knowledge, there is no easy and straighforward solution to this issue, unless taking the original x,y coordinates from wrf in its native grid, expand it (easy since it is regular in meters) and then retrieve the lon/lat value with the information of the projection. I could not finish this before taking some time off in august as I have other projects to work on. I will try to find a solution to this issue in the coming weeks and when I do, i will write the recipe on the git hub page, even though it might not be a good looking one.

Regards, Julien

De : David Huard @.> Envoyé : jeudi 31 août 2023 15:44 À : pangeo-data/xESMF @.> Cc : Julien BEAUMET @.>; Mention @.> Objet : Re: [pangeo-data/xESMF] Regridding towards curvilinear grids (Issue #287)

Salut Julien @jbeaumethttps://github.com/jbeaumet

Should we consider this issue resolved?

Also, please consider submitting a short "recipe" for the documentation on how to regrid for WRF, I'm confident this would be useful to many people.

— Reply to this email directly, view it on GitHubhttps://github.com/pangeo-data/xESMF/issues/287#issuecomment-1701066594, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A23IS5Y6QTQE2DDVN5XKEY3XYCIJZANCNFSM6AAAAAA3BO2BWE. You are receiving this because you were mentioned.Message ID: @.***>

huard commented 10 months ago

Have you looked at https://xgcm.readthedocs.io/en/latest/xgcm-examples/05_autogenerate.html ?

jthielen commented 10 months ago

Sorry for chiming in late to the discussion here, but this seems like it would be a good fit for xWRF, which seeks to adapt WRF output to CF conventions and make it easy to use with tools like xgcm and cf_xarray! I added an issue for this topic here: https://github.com/xarray-contrib/xwrf/issues/134.