issues: 312449001
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
312449001 | MDU6SXNzdWUzMTI0NDkwMDE= | 2043 | How to completely prevent time coordinates from being decoded? | 5700886 | closed | 0 | 1 | 2018-04-09T09:01:35Z | 2018-04-09T10:55:58Z | 2018-04-09T10:55:58Z | CONTRIBUTOR | Minimal exampleThe following shows that creating a time-coordinate with two dates before and after the latest date compatible to ```python In [1]: from datetime import datetime ...: import numpy as np ...: import xarray as xr In [2]: dates = [datetime(year, 1, 1) for year in [2262, 2263]] ...: ds = xr.Dataset(coords={"dates": dates}) In [3]: print(ds.coords["dates"][0]) <xarray.DataArray 'dates' ()> array('2262-01-01T00:00:00.000000000', dtype='datetime64[ns]') Coordinates: dates datetime64[ns] 2262-01-01 In [4]: print(ds.coords["dates"][1]) <xarray.DataArray 'dates' ()> array(datetime.datetime(2263, 1, 1, 0, 0), dtype=object) Coordinates: dates object 2263-01-01 In [5]: ds2 = xr.Dataset({}) In [6]: ds2["dates"] = (["dates", ], dates) In [7]: ds2.coords["dates"][0] Out[7]: <xarray.DataArray 'dates' ()> array('2262-01-01T00:00:00.000000000', dtype='datetime64[ns]') Coordinates: dates datetime64[ns] 2262-01-01 In [8]: ds2.coords["dates"][1] Out[8]: <xarray.DataArray 'dates' ()> array(datetime.datetime(2263, 1, 1, 0, 0), dtype=object) Coordinates: dates object 2263-01-01 ``` Problem descriptionI don't seem to find a way of passing time-coordinates to an xarray Dataset without having them decoded. This is problematic, because it makes it very hard (or impossible?) for a user to make sure a time axis does completely consist of, e.g., Output of xr.show_versions()```python In [5]: xr.show_versions() /home/wrath/miniconda3_20171008/envs/py3_std_course/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`. from ._conv import register_converters as _register_converters INSTALLED VERSIONS ------------------ commit: None python: 3.6.4.final.0 python-bits: 64 OS: Linux OS-release: 4.13.0-38-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 xarray: 0.10.2 pandas: 0.22.0 numpy: 1.14.2 scipy: 1.0.1 netCDF4: 1.3.1 h5netcdf: 0.5.0 h5py: 2.7.1 Nio: None zarr: 2.2.0 bottleneck: 1.2.1 cyordereddict: None dask: 0.17.2 distributed: 1.21.4 matplotlib: 2.2.2 cartopy: 0.16.0 seaborn: 0.8.1 setuptools: 39.0.1 pip: 9.0.1 conda: None pytest: None IPython: 6.3.1 sphinx: None ``` |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2043/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |