Apply xcdat to xarray-opened dataset #614
-
Question criteria
Describe your questionDo we have a capability to enable xcdat capability to already opened xarray dataset? For example import xarray as xr
import xcdat as xc
ds = xr.open_dataset(MYFILE)
ds_new = DO_SOMETHING(ds)
ds_new_ave = ds_new.spatial.average(data_var, axis=['X', 'Y']) I am curious because if there is some capability like this, it might be possible to easily use sample data from This might also enable use of xcdat combined with intake or intake-esm capability. Any idea or opinion will be appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
I guess this might be technically possible by making the @tomvothecoder is that sounds a reasonable thing to do? |
Beta Was this translation helpful? Give feedback.
-
@lee1043 – shouldn't this code work as is? The only reason I think this wouldn't work is if you didn't have bounds (which would have been added using |
Beta Was this translation helpful? Give feedback.
You're right.
xcdat
functionality will operate on xarray dataset objects after import (no need to open datasets with xcdat). Note thatxc.open_dataset
just uses/wrapsxr.open_dataset
with some custom features (e.g., adding bounds, handling a directory with mfdataset, dealing withmonths since...
time units, and things like this).