question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should the zarr backend support NCZarr conventions?

See original GitHub issue

What is your issue?

As part of the CZI EOSS4 grant, at B-Open we are keen on improving xarray/zarr cross-community conventions. It looks like xarray’s "zarr" backend does not support Unidata NCZarr conventions while NetCDF-c>=4.8.1 supports xarray conventions.

Currently, it is possible to open a NCZarr data source using the "netcdf4" backend only. Here is an example:

import xarray as xr
import numpy as np

ds = xr.Dataset(
    {
        "a": (("y", "x"), np.random.rand(6).reshape(2, 3)),
        "b": (("y", "x"), np.random.rand(6).reshape(2, 3)),
    },
    coords={"y": [0, 1], "x": [10, 20, 30]},
)
ds.to_netcdf("file://test.nczarr#mode=nczarr")

ds_from_nczarr = xr.open_dataset("file://test.nczarr#mode=nczarr", engine="netcdf4")
xr.testing.assert_identical(ds, ds_from_nczarr)

xr.open_dataset("test.nczarr", engine="zarr")
# KeyError: 'Zarr object is missing the attribute `_ARRAY_DIMENSIONS`, which is required for xarray to determine variable dimensions.'

Would the community benefit from a "zarr" backend compatible with NCZarr as well? @rsignell-usgs and @rabernat suggested to discuss this within the xarray community, but I don’t think a dedicated issue has been opened yet.

cc: @alexamici @aurghs @joshmoore

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
shoyercommented, Mar 23, 2022

@DennisHeimbigner I think it would be great to standardize NCZarr as a super-set of the “Xarray-Zarr” standard! I think Xarray should indeed be able to read such files. If you want to read a sub-group, you can read the sub-group in a separate call to xarray.open_zarr().

@rabernat I would not be opposed to adding support inside Xarray for reading NCZarr data, specifically to understand NCZarr’s encoding of dimension names when using Zarr-Python. This wouldn’t give 100% compatibility with NCZarr, but it would be very close (maybe just with incorrect dtypes for attributes) with a minimal amount of work. I don’t think it would be a big deal to look for .nczvar files.

1reaction
shoyercommented, Apr 6, 2022

@wankoelias could you kindly open a new issue for writing GDAL ZARR?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overview of Zarr Support in netCDF-C - Unidata
Briefly, the data model supported by NCZarr is netcdf-4 minus the user-defined types and the String type. As with netcdf-4 it supports chunking....
Read more >
Zarr Encoding Specification - Xarray
Future versions of the Zarr spec will likely include a more formal convention for the storage of the NetCDF data model in Zarr;...
Read more >
Tutorial — zarr 2.13.3 documentation - Read the Docs
Zarr arrays support a similar interface to NumPy arrays for reading and writing ... The array above will store its configuration metadata and...
Read more >
Temporary 2022.10.05 Zarr notes - HackMD
WF: not about that. Ellen Johnson is the main contact. Will add that to the list. :tada: Java and async. scalableminds: Java backend...
Read more >
Using Cloud Computing to Analyze Model Output Archived in ...
Archives of the original HRRR GRIB2 files and the resulting Zarr stores on Amazon Web Services (AWS) Simple Storage Service (S3) are available...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found