JiaweiZhuang / xESMF

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

Conservative regridding example using 0.2.0 #58

Open lizziel opened 5 years ago

lizziel commented 5 years ago

I am following ReadTheDocs to regrid an xarray DataSet with multiple variables using xESMF 0.2.0: https://xesmf.readthedocs.io/en/latest/notebooks/Dataset.html

The example works great for bilinear method, but fails for conservative, seemingly due to missing lon_b based on the traceback. Looking at the docstrings I see this:

Could you add an example for regridding a DataSet with multiple variables using conservative regridding? Having error handling implemented to give a helpful message when passing DataSet without the needed info would be useful too.

JiaweiZhuang commented 5 years ago

I added how to regrid xarray.Dataset (with both bilinear and conservative algorithm) in the GEOS-Chem-python-tutorial : https://github.com/geoschem/GEOSChem-python-tutorial/blob/master/Chapter03_regridding.ipynb

The conservative regridding works exactly the same as in v0.1.x -- it is looking for 'lon_b' and 'lat_b' in the input/output grid. The boundary handling might be simplified by #13, but for now you still need to manually add the boundaries...

JiaweiZhuang commented 5 years ago

Also note that building the regridder is independent of the type of input data -- a single regridder accepts numpy array, dask array, DataArray, or Dataset.

lizziel commented 5 years ago

Thanks, the GEOS-Chem python tutorial information on this is helpful. I still recommend expanding the xESMF docs to replace "need grid corner information" with specifics.

JiaweiZhuang commented 5 years ago

I still recommend expanding the xESMF docs to replace "need grid corner information" with specifics.

Yes I agree that's somewhat confusing... Hopefully this will be resolved by automatic bound inference JiaweiZhuang/xESMF#13. Adding doc on approximating bounds manually would also seem useful.