-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
What happened?
With Zarr v2, Xarray conflated _FillValue
and fill_value
(#5475), so unwritten data in a Zarr file is always decoded as NaN.
In Zarr v3, this changed. Now, it appears that unwritten data in a Zarr file uses the default Zarr fill_value=0
.
In practice, this means that is Zarr metadata is written to disk (with compute=False
) but no values are written, the data will be decoded by xarray as all zeros instead of all NaNs. This is perhaps unavoidable for integer data (there is no integer NaN), but for floats, we should default to a user controllable fill_value
of NaN, which is clearly an invalid value.
To reproduce:
import xarray
import numpy as np
ds = xarray.Dataset({'foo': ('x', np.ones(3))}).chunk()
path = '/tmp/foo5.zarr'
ds.to_zarr(path, compute=False)
# all NaN with zarr v2, all zeros with zarr v3
print(xarray.open_zarr(path).compute())