Support multidimensional coordinates for bounds and regridding#820
Support multidimensional coordinates for bounds and regridding#820tomvothecoder wants to merge 7 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #820 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 18 18
Lines 1989 2002 +13
=========================================
+ Hits 1989 2002 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Notes
|
|
Thanks for pushing this forward @jasonb5! This PR seems to work for the example in #816, but I think it is failing for a related case (curvilinear->rectilinear): wget https://esgf-node.ornl.gov/thredds/fileServer/css03_data/CMIP6/CMIP/CNRM-CERFACS/CNRM-CM6-1/historical/r1i1p1f2/Amon/tas/gr/v20180917/tas_Amon_CNRM-CM6-1_historical_r1i1p1f2_gr_185001-201412.nc
wget https://esgf-node.ornl.gov/thredds/fileServer/css03_data/CMIP6/CMIP/CNRM-CERFACS/CNRM-CM6-1/historical/r1i1p1f2/SImon/siconc/gn/v20180917/siconc_SImon_CNRM-CM6-1_historical_r1i1p1f2_gn_185001-201412.nc# %% imports
import xcdat as xc
# %% parameters
fn_source = 'siconc_SImon_CNRM-CM6-1_historical_r1i1p1f2_gn_185001-201412.nc'
fn_target = 'tas_Amon_CNRM-CM6-1_historical_r1i1p1f2_gr_185001-201412.nc'
# %% get source / target grids
ds = xc.open_dataset(fn_source)
ngrid = xc.open_dataset(fn_target)
# %% try regridding with xcdat
dsr = ds.regridder.horizontal('tmp2m', ngrid, tool="xesmf", method="conservative_normed", periodic=True)
I can get this to work with: import xesmf as xe
regridder = xe.Regridder(ds, ngrid, "conservative_normed", periodic=True, ignore_degenerate=True)
dsr = regridder(ds) |
27ee94b to
36aa432
Compare
|
@pochedls Could you give this another try? Thanks! |
|
This is working for both of the cases I raised (code below for my reference), but I think it isn't generically picking up the coordinates. For example, CESM2 has the following structure
Which produces the following error when regridding:
Is there a more generic way to handle these auxiliary coordinates (x/nj/etc)? Perlmutter code for reference. import xsearch as xs
import xcdat as xc
p = list(xs.findPaths('historical', 'siconc', 'mon', model='CNRM-CM6-1', member = 'r1i1p1f2').keys())[0]
p2 = list(xs.findPaths('historical', 'tas', 'mon', model='CNRM-CM6-1', member = 'r1i1p1f2').keys())[0]
ds = xc.open_mfdataset(p)
ngrid = xc.open_mfdataset(p2)
dsr = ds.regridder.horizontal('siconc', ngrid, tool="xesmf", method="conservative_normed", periodic=True) |
|
That actually caught an edge case I didn't consider. If the |
Thanks @jasonb5 – I think curvilinear regridding is seemingly full of edge cases. I appreciate your effort in making this robust (and I'm happy you can quickly understand what is going on). |
|
@pochedls There's more to this issue. My original fix may not be correct. I'm working on a new fix and will push it soon. |
b4d0557 to
048a07a
Compare
|
@pochedls Try the latest. The CESM example will fail because it has two possible |
FYI – this is working for CNRM-CM6-1 and the |
|
@pochedls Go ahead and try again. All three cases should work this time. |
Description
Checklist
If applicable: