netcdf-c icon indicating copy to clipboard operation
netcdf-c copied to clipboard

Zarr scalars aren't not correctly handled

Open mannreis opened this issue 9 months ago • 2 comments

As an example here's some python code that writes a xarray dataset into netcdf and zarr (version 2):

import xarray as xr
ds = xr.Dataset({'var':123456789})
ds.to_netcdf('xr.nc')
ds.to_zarr('xr.zarr')

In netcdf the scalar is well interpreted:

$ ncdump  xr.nc 
netcdf xr {
variables:
        int var ;
data:

 var = 123456789 ;
}

In zarr the scalar variable is suppressed:

$ ncdump  -L 0 file://${PWD}/xr.zarr#mode=zarr,file
WARN: Empty shape for variable var suppressed
netcdf xr {
}

mannreis avatar Mar 11 '25 15:03 mannreis

You are using Zarr V3, correct?

DennisHeimbigner avatar Mar 12 '25 18:03 DennisHeimbigner

No, zarrV2 still... I created the dataset with python3.10, using xarray=2025.1.1 and zarr-python=2.18.2. To check, I built netcdf-c from the current main. #3109 tries to patch this but it seems that constants/scalar where not contemplated/supported to begin-with!?

(not much relevant for the moment, but for the I also patched it )

mannreis avatar Mar 12 '25 20:03 mannreis