JiaweiZhuang / xESMF

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

Utility to regrid input netCDF and give output netCDF #59

Closed lizziel closed 4 years ago

lizziel commented 4 years ago

I would like to have a tool for GEOS-Chem users to conservatively regrid netCDF files using GMAO grids, between any combination of lat-lon and cubed sphere. I think the best place for this utility would be in GCPy using xESMF, but wonder if any part of the utility should be added to xESMF to then be tapped into by GCPy. For example, having the capability of accepting an input netcdf file, information about output grid, and giving back a new netcdf file.

Let's discuss!

JiaweiZhuang commented 4 years ago

For single-tile grid (such as regular lat-lon), the code is as simple as

ds_in = xarray.open_dataset('input_file.nc')
grid_out = [define your grid here]
regridder = xesmf.Regridder(ds_in, grid_out, ...)
ds_out = regridder(ds_in)
ds_out.to_netcdf('output_file.nc')

which seems simple enough and does not require an extra function.

For multi-tile grid like cubed-sphere, users need to manually merge the tiles before calling to_netcdf(). See https://github.com/JiaweiZhuang/xESMF/issues/21#issuecomment-398530700. It is unclear how the each tile should be merged (do you want an extra tile dimension? Or just stack into y dimension?) , so this is better left to user code...

lizziel commented 4 years ago

I'm generally a fan of pushing users to do their own coding but I think for simple GEOS-Chem file regridding there could be an easy-to-use wrapper. I'll think more about it.

lizziel commented 4 years ago

Any developed GEOS-Chem regridding tool using xESMF will be outside of xESMF so this issue can be closed.