Skip to content
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

NCZarr reading a Zarr file with no variable name #2603

Open
abhibaruah opened this issue Feb 1, 2023 · 4 comments
Open

NCZarr reading a Zarr file with no variable name #2603

abhibaruah opened this issue Feb 1, 2023 · 4 comments

Comments

@abhibaruah
Copy link

NetCDF version: 4.9.0
OS: Linux

I am using Zarr Python to create a Zarr file without a variable name.

My Python code:

import zarr
import numpy as np
z1 = zarr.open('example_zarr_py.zarr', mode='w', shape=(100,100), chunks=(10,10), dtype='i4')
z1[:] = 42
z1[0, :] = np.arange(100)
z1[:, 0] = np.arange(100)

The 'example_zarr_py.zarr' folder created has files like '.zarray', '0.0', '0.1'.... (the array data) and does not have a sub-folder with a variable or dataset name or a .zgroup file.

I am trying to read this file using NCZarr.

While I can open this file with:

status = nc_open(FILENAME, NC_NOWRITE, &ncid);
where FILENAME is "file://example_zarr_py.zarr#mode=zarr,file"

I am not sure of how to proceed after this to read the data as the logical next step in netCDF to read a variable is to use 'nc_inq_varid' with the variable name (For example in the example here) or 'nc_inq_var' to get the name of the first variable.

Are these Zarr files with no variable or dataset names and no '.zgroup' files not supported?
If not, how do I read the variable data?

example_zarr_py.zarr.zip

@DennisHeimbigner
Copy link
Collaborator

Does the Zarr V2 spec even allow this?

@abhibaruah
Copy link
Author

The Python repro code that I posted above is borrowed from the Zarr documentation (https://zarr.readthedocs.io/en/stable/tutorial.html#creating-an-array) from the sections on 'Creating an Array' and 'Reading and writing data'.
I am not sure of what the Zarr v2 spec specifically mentions, but I thought that since this is the first example in the Zarr tutorials, it is allowed.

@DennisHeimbigner
Copy link
Collaborator

Unfortunately, there is a lot of stuff in the tutorial that is not in the
specification.
But I am curious, do you actually need a nameless array?

@abhibaruah
Copy link
Author

We do not really need it as of now.
I was trying to experiment with NCZarr by creating files in Python and reading them using NCZarr. The nameless array was one of the first ones I created (by following the tutorial). So I tried to read the data using NCZarr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants