-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
I would like to be able to apply CF encoding to an existing DataArray (or multiple in a Dataset) and then store the encoded forms elsewhere. Is this already possible?
More specifically, I would like to encode a large array of 32-bit floats as 8-bit ints and then write them to a Zarr store using rechunker.
I'm essentially after this pangeo-data/rechunker#45 (Xarray support in rechunker), but I'm looking for what functionality exists in Xarray to make it possible in the meantime.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
dcherian commentedon Sep 8, 2020
Not at the moment.
I think we should add an
xr.encode_cf
that wrapsconventions.cf_encoder
(this may have already come up in the "flexible backends" discussions). This would parallelxr.decode_cf
xarray/xarray/conventions.py
Lines 740 to 793 in 66259d1
It'll also need to wrap this logic:
xarray/xarray/backends/api.py
Lines 1113 to 1127 in 66259d1
For simple use cases, you could write a small wrapper for
.cf_encoder
that takes datasets and returns datasets and it should work just fine (Look atconventions.decode_cf
).eric-czech commentedon Sep 8, 2020
Ok thanks @dcherian! I'll try that (feel free to close this).
dcherian commentedon May 10, 2023
Related request for
to_zarr(..., encode_cf=False)
: #5405This came up in the discussion today.
cc @tom-white @kmuehlbauer
int64
when writing netcdf or zarr #3942