nanosecond precision lost when reading time data #7817
Labels
bug
topic-CF conventions
topic-metadata
Relating to the handling of metadata (i.e. attrs and encoding)
What happened?
When reading nanosecond precision time data from netcdf the precision is lost. This happens because CFMaskCoder will convert the variable to floating point and insert "NaN". In CFDatetimeCoder the floating point is cast back to int64 to transform into datetime64. This casting is sometimes undefined, hence #7098.
What did you expect to happen?
Precision should be preserved. The transformation to floating point should be omitted.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
Plot from above code:
Xref: #7098, #7790 (comment)
Environment
xarray: 2023.4.2
pandas: 2.0.1
numpy: 1.24.2
scipy: 1.10.1
netCDF4: 1.6.3
pydap: None
h5netcdf: 1.1.0
h5py: 3.8.0
Nio: None
zarr: 2.14.2
cftime: 1.6.2
nc_time_axis: None
PseudoNetCDF: None
iris: None
bottleneck: 1.3.7
dask: 2023.3.1
distributed: 2023.3.1
matplotlib: 3.7.1
cartopy: 0.21.1
seaborn: None
numbagg: None
fsspec: 2023.3.0
cupy: 11.6.0
pint: 0.20.1
sparse: None
flox: None
numpy_groupies: None
setuptools: 67.6.0
pip: 23.0.1
conda: None
pytest: 7.2.2
mypy: None
IPython: 8.11.0
sphinx: None
The text was updated successfully, but these errors were encountered: