JiaweiZhuang / xESMF

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

Regridding CMIP5 data #49

Open DamienIrving opened 5 years ago

DamienIrving commented 5 years ago

I'm regridding CMIP5 ocean temperature data from a curvilinear to rectilinear grid. Following the relevant example in the documentation, I've tried to use xESMF for this task without success: https://github.com/DamienIrving/ocean-analysis/blob/master/development/xESMF_test.ipynb

I was wondering if there's an obvious mistake I've made in that notebook?

JiaweiZhuang commented 5 years ago

The code looks alright; it should be either ESMPy install issues or weird singularities in the input grid. Do you have an example data file (say just one time slice)?

DamienIrving commented 5 years ago

Yep. No problem - you can download a cut down version of the data file (first timestep only) here.

DamienIrving commented 5 years ago

GitHub seems to be having issues rendering anything but the initial version of the notebook, so best to use this link: https://github.com/DamienIrving/ocean-analysis/blob/c9d46e50b3171c0000c43a8628b42dba4d9a881f/development/xESMF_test.ipynb

JiaweiZhuang commented 5 years ago

The problem is that the grid you pass to xESMF contains multiple disconnected tiles, although they are stored in a single 2D array:

image

So, apparently, xESMF/ESMPy has trouble understanding the connectivity.

The error is fixed by breaking your full grid to several well-defined 2D tiles.

See this GitHub gist for full code: https://nbviewer.jupyter.org/gist/JiaweiZhuang/7a620ccea7d686891fed0221f386a50b

A very similar issue is https://github.com/JiaweiZhuang/xESMF/issues/14#issuecomment-370175606

A more general discussion on multi-tile support is at #21.

DamienIrving commented 5 years ago

Thanks, @JiaweiZhuang. This is super helpful.

Interestingly, iris (regrid_weighted_curvilinear_to_rectilinear) had similar problems with this particular model/grid, but cdo remapbil handled the regirdding just fine.

JiaweiZhuang commented 5 years ago

Yes Iris exactly uses ESMPy under the hood so should have the same issue. CDO seems to use its own, non-ESMF regridding implementation.