home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 784497022

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/3739#issuecomment-784497022 https://api.github.com/repos/pydata/xarray/issues/3739 784497022 MDEyOklzc3VlQ29tbWVudDc4NDQ5NzAyMg== 10638475 2021-02-23T20:41:17Z 2021-02-23T20:41:17Z NONE

I got a similar error message when opening a Zarr store with datetime64 time values, where I tried to set the "calendar" attribute on the time axis (the attribute was unset in the original store). I've found some xarray code that appears to treat the "calendar" and "units" time attributes as special, and it essentially prevents users from setting or changing these values, even when those values are not present:

From xarray/coding/times.py:

``` class CFDatetimeCoder(VariableCoder): def init(self, use_cftime=None): self.use_cftime = use_cftime

def encode(self, variable, name=None):
    dims, data, attrs, encoding = unpack_for_encoding(variable)
    if np.issubdtype(data.dtype, np.datetime64) or contains_cftime_datetimes(
        variable
    ):
        (data, units, calendar) = encode_cf_datetime(
            data, encoding.pop("units", None), encoding.pop("calendar", None)
        )
        safe_setitem(attrs, "units", units, name=name)
        safe_setitem(attrs, "calendar", calendar, name=name)

    return Variable(dims, data, attrs, encoding)

```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  558293655
Powered by Datasette · Queries took 0.675ms · About: xarray-datasette