I'm wondering if there's still a plan to port the NCL ESMF_regrid functionality into GeoCAT? The last comment on this was from a couple years ago: https://github.com/NCAR/geocat-comp/issues/6
This is desirable because xesmf does not appear to be able to handle unstructured grids (eg. CAM-SE) even if the weights have been precomputed (using SCRIP, for example).
Thanks for bringing this into attention, @Stephen Yeager ! We would absolutely work on the unstructured grids part of this under the scope of the Project Raijin, which is recently awarded by NSF for unstructured grids research. We would also need to determine how we should proceed with the regular lat/lon regridding, taking the existence of XESMF into account.
cc'ing GeoCAT team: @Alea Kootz @Anissa Zacharias @Michaela Sizemore
@Stephen Yeager, it might be helpful to see what the limitation in xESMF is with the unstructured grid. Hardcoded assumption about the grid being 2D?
I also noticed that there is no issue about unstructured grid support at the xESMF repository (https://github.com/pangeo-data/xESMF). It would be good to ask them about plans and if they are open to contributions
Ah there is an issue on the older, abandoned repo: https://github.com/JiaweiZhuang/xESMF/issues/18
I've tried to generate a regridder using xesmf to regrid CAM-SE (ne120) data to a regular 0.25x0.25 grid using:
regrid_ne120 = xe.Regridder(ds_cam_ne120, target_p25, method='bilinear',periodic=True)
and
regrid_ne120 = xe.Regridder(ds_cam_ne120, target_p25, method='bilinear',periodic=True,filename=wgtfile,reuse_weights=True)
In the second, I'm trying to reuse SCRIP weights from a file. Both calls generate the error "Unable to allocate 4.40 TiB for an array with shape (777602, 777602) and data type float64". The error appears to be thrown in: xesmf/frontend.py in as_2d_mesh(lon, lat)
so it appears to be trying to force the ne120 to look like a 2d mesh?
The notebook is here:
/glade/u/home/yeager/analysis/python/Robinson.ipynb
which also includes a failed attempt to use ESMpy (it won't read in the ne120 grid file correctly).
From the xesmf documention:
"ESMPy is actually able to deal with general irregular meshes (example), but designing an elegant front-end for that is very challenging. Plain 2D arrays cannot describe irregular meshes. There needs to be additional information for connectivity, as suggested by UGRID Conventions.
xESMF supports quadrilateral grids and has limited support of triangular or hexagonal meshes. xESMF also supports complex polygonal meshes, but only in the context of regional averaging.
xarray’s data model, although powerful, can only describe quadrilateral grids (including multi-tile quadrilateral grids like the cubed-sphere). If there is an elegant data model in Python for irregular meshes, interfacing with ESMPy should not be very difficult. Pull requests along these lines are welcome."
FWIW the unstructured grid support planned as part of Project Raijin will be based around extensions to XArray that are modeled on the UGRID specifications: http://ugrid-conventions.github.io/ugrid-conventions. At least that is the plan of record :-).
Last updated: May 16 2025 at 17:14 UTC