item assignment
Opened this issue · 1 comments
raybellwaves commented
Couldn't see an issue open for this. It may also not be in the roadmap.
import xarray as xr
ds = xr.open_zarr("s3://era5-pds/zarr/2021/01/data/air_temperature_at_2_metres.zarr").isel(lat=0, lon=0)
# coord named time0 with standard_name: time
# want to change time to be in a local timezone
# in xarray
ds["time0"] = ds["time0"].to_index().tz_localize("UTC").tz_convert("US/Eastern").tz_localize(None).to_numpy())
# feature request in cf xarray
ds.cf["time"] = ds.cf["time"].to_index().tz_localize("UTC").tz_convert("US/Eastern").tz_localize(None).to_numpy())
TypeError: 'CFDatasetAccessor' object does not support item assignment
raybellwaves commented
I think i'm just after the mapping here e.g.
time_dim = ds.cf["time"].name
then would be
ds[time_dim] = ds[time_dim].to_index().tz_localize("UTC").tz_convert("US/Eastern").tz_localize(None).to_numpy())