-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not save timedelta data arrays with small integer dtypes and _FillValue #9134
Comments
#9136 does not fix this issue unfortunately. I've attached INSTALLED VERSIONScommit: 7e856ba xarray: 2024.6.1.dev21+g7e856ba0 |
@mx-moth Sorry, the change over in #9163 is in the decoding path not in the encoding. I think this is a regression stemming from #8575, cc @spencerkclark. There a cast to final dtype was introduced already in The handling of |
Thanks @kmuehlbauer, in thinking about #9154 I've realized that there are other reasons the existing approach is not ideal—sometimes it will miss raising an error in the event of precision loss:
I'll think more carefully about that and this issue over the weekend. |
Thanks @spencerkclark for looking into this. The current approach for datetimes/timedeltas is not really straightforward, especially with all the special casing going around in the other coders. Would it make sense to handle datetimes/timedeltas completely separated from the other coders? |
I agree, it's getting pretty hard to follow at this point. I forget, was there a reason we did not do this earlier, e.g. in #7827? As I think about it more, #9134 (comment) is fairly separate and should not be too difficult to address at least for |
Yes there are many requests to control this independently: #1621 . A good first step toward that would be to just split up the current Coder into two. |
What happened?
If I open a netCDF4 file that contains a variable with
units: "days"
, a small integer dtype, an appropriate_FillValue
attribute, and masked values, xarray will correctly convert this in to a data array with dtypetimedelta64
with a 'NaT' value for all masked values. Attempting to save this dataset back to disk raises this OverFlowError:What did you expect to happen?
The dataset should be successfully saved to disk, with any 'NaT' values replaced with the appropriate '_FillValue'.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment
INSTALLED VERSIONS
commit: None
python: 3.12.0 | packaged by conda-forge | (main, Oct 3 2023, 08:43:22) [GCC 12.3.0]
python-bits: 64
OS: Linux
OS-release: 5.15.0-107-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_AU.UTF-8
LOCALE: ('en_AU', 'UTF-8')
libhdf5: 1.14.2
libnetcdf: 4.9.3-development
xarray: 2024.6.0
pandas: 2.2.2
numpy: 2.0.0
scipy: None
netCDF4: 1.7.1
pydap: None
h5netcdf: None
h5py: None
zarr: None
cftime: 1.6.4
nc_time_axis: None
iris: None
bottleneck: 1.4.0
dask: 2024.6.0
distributed: 2024.6.0
matplotlib: 3.9.0
cartopy: 0.23.0
seaborn: None
numbagg: None
fsspec: 2024.6.0
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 70.0.0
pip: 24.0
conda: None
pytest: 8.2.2
mypy: 1.10.0
IPython: 8.25.0
sphinx: 6.2.1
The text was updated successfully, but these errors were encountered: