-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
What happened:
If the unit of a date, is a number of nanoseconds elapsed since a reference date, xarray cannot read this dataset and throws the exception KeyError: nanoseconds.
What you expected to happen:
As this unit is valid in CF model, it must be decoded. Today the units that are recognized go from day to microseconds in the module coding/time.py.
Minimal Complete Verifiable Example:
import numpy as np
import array as xr
xr.DataArray(
np.arange(0, 1e10, 1e9).astype("int64"),
attrs=dict(units="nanoseconds since 1970-01-01")).to_netcdf("/tmp/test.nc")
xr.open_dataset("/tmp/test.nc")Environment:
Output of xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.8.3 | packaged by conda-forge | (default, Jun 1 2020, 17:43:00)
[GCC 7.5.0]
python-bits: 64
OS: Linux
OS-release: 3.10.0-957.12.2.el7.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.4
xarray: 0.15.1
pandas: 1.0.4
numpy: 1.17.5
scipy: 1.4.1
netCDF4: 1.5.3
pydap: None
h5netcdf: 0.8.0
h5py: 2.10.0
Nio: None
zarr: 2.4.0
cftime: 1.1.3
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2.18.1
distributed: 2.18.0
matplotlib: 3.2.1
cartopy: None
seaborn: None
numbagg: None
setuptools: 47.3.1.post20200616
pip: 20.1.1
conda: 4.8.3
pytest: 5.4.3
IPython: 7.15.0
sphinx: None