pangeo-data / xESMF

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

Create Regridder object from existing ESMF weights file #202

Open dcherian opened 1 year ago

dcherian commented 1 year ago

This is a common request (example) because at many modelling centers, a remapping files is generated once and stored in a common location and used by other tools (e.g. NCL).

So my question: Is it possible to create a Regridder object from an existing ESMF weights file. This would generalize this bit of code: https://xesmf.readthedocs.io/en/latest/notebooks/Backend.html#Apply-weights-using-Scipy-backend

raphaeldussin commented 1 year ago

@dcherian yes! use reuse_weights=True and filename=wgts.nc or weights=, as arguments to the regridder. you still need to pass the source and target grid but you could just make them empty arrays of the right dimensions.

dcherian commented 1 year ago

I tried this today and it's a bit clunky: https://github.com/NCAR/esds/pull/217

I think we could improve it a bit with a Regridder.from_weights_file classmethod