Stream: python-questions
Topic: xesmf
Kate Hedstrom (Nov 06 2020 at 06:53):
I'm trying to use xesmf to regrid onto a curvilinear ROMS grid. It is telling me:
File "/import/c1/AKWATERS/kate/.conda/envs/snowdrifts/lib/python3.7/site-packages/xesmf/frontend.py", line 94, in ds_to_ESMFlocstream raise ValueError("lon can only be 1d") ValueError: lon can only be 1d
The test code:
import xarray as xr import xesmf def regrid_tracer(fld, method='bilinear'): coords = xr.open_dataset('/import/AKWATERS/kshedstrom/gridpak/Arctic2/grid_Arctic_4.nc') coords = coords.rename({'lon_rho': 'lon', 'lat_rho': 'lat'}) gsource = xr.open_dataset('/import/AKWATERS/kshedstrom/HYCOM/Svalbard/data/HYCOM_GLBv0.08_2018_001.nc') regrid = xesmf.Regridder( gsource, coords, method=method, locstream_out=True, periodic=False, filename='regrid_t.nc', reuse_weights=True ) tdest = regrid(gsource.ssh) return tdest myssh = regrid_tracer('ssh') myssh.to_netcdf('myssh.nc')
What am I doing wrong?
Matt Long (Nov 06 2020 at 16:27):
I wonder why ds_to_ESMFlocstream
is involved. I would have expected an ESMF grid object. The locstream is indeed a 1D thing. I think xesmf must be getting confused and not instantiating an ESMF grid object from your data.
cc @geocat
Kate Hedstrom (Nov 06 2020 at 16:58):
Oh, I was copying from a code that had locstream set to true. It works without that. Thanks!
Matt Long (Nov 06 2020 at 16:59):
Ah, had I looked more closely at your code, I would have seen that. Glad it's working!
Last updated: Jan 30 2022 at 12:01 UTC