You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This happens, if missing_value is an attribute of a specific netCDF Dataset of an existing file. On read the missing_value will be masked with np.nan on the data and it will be preserved within encoding. On write, _FillValue will be added as attribute by xarray (if not available, at least for floating point types), too. So far so good.
The error first manifests if you read back this file and try to write it again. There is no warning on the second read, that the two _FillValue and missing_value are differing. Only on the second write.
What did you expect to happen?
The file should be written on the second roundtrip.
There are at least two solutions to this:
Mask missing_value on read and purge missing_value completely in favor of _FillValue.
Do not handle missing_value at all, but let the user take action.
This attribute is not treated in any special way by the library or conforming generic applications, but is often useful documentation and may be used by specific applications.
What happened?
see also #7191
If
missing_value
and_FillValue
is an attribute of a DataArray it can't be written out to file if these two contradict:This happens, if
missing_value
is an attribute of a specific netCDF Dataset of an existing file. On read themissing_value
will be masked withnp.nan
on the data and it will be preserved withinencoding
. On write,_FillValue
will be added as attribute by xarray (if not available, at least for floating point types), too. So far so good.The error first manifests if you read back this file and try to write it again. There is no warning on the second read, that the two
_FillValue
andmissing_value
are differing. Only on the second write.What did you expect to happen?
The file should be written on the second roundtrip.
There are at least two solutions to this:
missing_value
on read and purgemissing_value
completely in favor of_FillValue
.missing_value
at all, but let the user take action.Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
The adding of
_FillValue
on write happens here:xarray/xarray/conventions.py
Line 300 in d4db166
xarray/xarray/conventions.py
Lines 144 to 152 in d4db166
Environment
xarray: 2023.3.0
pandas: 1.5.3
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
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2023.3.1
distributed: 2023.3.1
matplotlib: None
cartopy: None
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: