home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 317954266

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
317954266 MDU6SXNzdWUzMTc5NTQyNjY= 2085 units = 'days' leads to timedelta64 for data variable 10194086 closed 0     5 2018-04-26T09:47:11Z 2018-04-26T16:44:25Z 2018-04-26T15:55:09Z MEMBER      

Code Sample

```python

import numpy as np import xarray as xr

def test_units(units):

x = np.arange(10)
data = np.random.randn(10)

ds = xr.Dataset(data_vars=dict(data=('x', data)), coords=dict(x=('x', x)))
ds.data.attrs['units'] = units

ds.to_netcdf('tst.nc')

decoded = xr.open_dataset('tst.nc')

print(units.ljust(8), decoded.data.dtype)


ds.close()
decoded.close()

test_units('seconds') test_units('second')

test_units('minutes') test_units('minute')

test_units('days') test_units('day')

test_units('months') test_units('years') ```

Problem description

Returns: seconds timedelta64[ns] second float64 minutes timedelta64[ns] minute float64 days timedelta64[ns] day float64 months float64 years float64

Expected Output

I would expect type float for all of them. Or is this expected behaviour?

I have a dataset that reports 'consecutive dry days' and the dataset creator correctly set the units of the data to 'days', but I don't want this to be decoded (but the time axis should)....

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.4.final.0 python-bits: 64 OS: Linux OS-release: 4.4.126-48-default machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 xarray: 0.10.2+dev6.g9261601 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: None bottleneck: 1.2.1 cyordereddict: 1.0.0 dask: 0.17.2 distributed: 1.21.3 matplotlib: 2.2.2 cartopy: None seaborn: None setuptools: 39.0.1 pip: 9.0.2 conda: None pytest: 3.4.2 IPython: 6.2.1 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2085/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 5 rows from issue in issue_comments
Powered by Datasette · Queries took 0.632ms · About: xarray-datasette