issues: 849751721
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
849751721 | MDU6SXNzdWU4NDk3NTE3MjE= | 5106 | to_zarr() fails on time coordinate in append mode | 40218891 | closed | 0 | 4 | 2021-04-03T22:26:11Z | 2021-04-20T12:04:06Z | 2021-04-20T04:41:07Z | NONE | What happened: When the append dimension coordinates are times and the dimension of the first dataset written is 1, consecutive appends forget the hour part of the coordinate. What you expected to happen: The time coordinate should be set correctly. Minimal Complete Verifiable Example: ``` import pandas as pd import xarray as xr reftime = [pd.Timestamp(2021, 2, 21, 0)] x = [0] dims = ('reftime', 'x') d = np.array([['A']]) ds1 = xr.Dataset(data_vars={'v': (dims, d)}, coords={'reftime': reftime, 'x': x}) _ = ds1.to_zarr('foo', mode='w') reftime = [pd.Timestamp(2021, 2, 21, 6)] d = np.array([['C']]) ds2 = xr.Dataset(data_vars={'v': (dims, d)}, coords={'reftime': reftime, 'x': x}) _ = ds2.to_zarr('foo', append_dim='reftime') ds = xr.open_dataset('foo', engine='zarr') ds.coords['reftime'].values array(['2021-02-21T00:00:00.000000000', '2021-02-21T00:00:00.000000000'], # should be 2021-02-21T06:00:00.000000000 dtype='datetime64[ns]') ``` Anything else we need to know?:
When the array(['2021-02-21T00:00:00.000000000', '2021-02-21T03:00:00.000000000',
'2021-02-21T06:00:00.000000000'], dtype='datetime64[ns]')
array(['2021-02-21T00:00:00.000000000', '2021-02-22T00:00:00.000000000'], dtype='datetime64[ns]') ``` Environment: Output of <tt>xr.show_versions()</tt>INSTALLED VERSIONS ------------------ commit: None python: 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 16:22:27) [GCC 9.3.0] python-bits: 64 OS: Linux OS-release: 5.10.11-200.fc33.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_CA.UTF-8 LOCALE: en_CA.UTF-8 libhdf5: 1.10.6 libnetcdf: 4.7.4 xarray: 0.17.0 pandas: 1.2.3 numpy: 1.20.2 scipy: 1.6.2 netCDF4: 1.5.6 pydap: None h5netcdf: 0.10.0 h5py: 3.1.0 Nio: None zarr: 2.7.0 cftime: 1.4.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: 0.9.8.5 iris: None bottleneck: 1.3.2 dask: 2021.04.0 distributed: 2021.04.0 matplotlib: 3.4.1 cartopy: None seaborn: None numbagg: None pint: None setuptools: 49.6.0.post20210108 pip: 21.0.1 conda: None pytest: None IPython: 7.22.0 sphinx: None |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/5106/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |