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

Zarr generation creates a unexpected array value for fill_value #2008

Closed
rouault opened this issue May 26, 2021 · 3 comments · Fixed by #2017
Closed

Zarr generation creates a unexpected array value for fill_value #2008

rouault opened this issue May 26, 2021 · 3 comments · Fixed by #2017

Comments

@rouault
Copy link
Contributor

rouault commented May 26, 2021

Version: libnetcdf 4.8.0, built on Ubuntu 20.04 with NCZarr support

Given simple.cdl:

netcdf test {
dimensions:
	dim = 1;
variables:
	int test(dim) ;
		test:_FillValue = -32767 ;
data:

 test = 1;
}

~/install-netcdf-4.8.0/bin/ncgen -4 -lb -o "file://simple_zarr#mode=nczarr,file" simple.cdl generates a simple_zarr/test/.zarray file with following content :

"zarr_format": 2,"shape": [1],"dtype": "<i4","chunks": [1],"fill_value": [-32767],"order": "C","compressor": null,"filters": null}

"fill_value": [-32767] doesn't match what the Python Zarr reference implementation does. It would generate "fill_value": -32767 . The spec at https://zarr.readthedocs.io/en/stable/spec/v2.html#fill-value-encoding is admittedly a bit vague about that, but I wouldn't expect an array from reading it.

@DennisHeimbigner
Copy link
Collaborator

Good catch. I will have to check, but in netcdf. the value of the attribute is actually a sequence of values, possibly of size 1. I did the translation directly. Instead, I should see if the attribute has a single value and then stored it as such.
Should be an easy fix.

@DennisHeimbigner
Copy link
Collaborator

Also, this applies because of the netcdf _FillValue attribute.

DennisHeimbigner added a commit to DennisHeimbigner/netcdf-c that referenced this issue Jun 5, 2021
re: Unidata#2008

The fill_value key in a .zarray should have a single value,
but it currently has a value that is a 1 element array.
Fix is to pull out the single element.

This occurred because the fill_value is taken from the _FillValue attribute,
and all attributes are stored as arrays, of length 1 in this case.

Misc. other changes:

1. Fix bug in testpathcvt caused by the way various shells handle backslash escapes.
2. Fix bug in testauth where test for MSVC is wrong.
DennisHeimbigner added a commit to DennisHeimbigner/netcdf-c that referenced this issue Jun 5, 2021
re: Unidata#2008

The fill_value key in a .zarray should have a single value,
but it currently has a value that is a 1 element array.
Fix is to pull out the single element.

This occurred because the fill_value is taken from the _FillValue attribute,
and all netcdf attributes are stored as arrays, of length 1 in this case.

In a related change, any attribute with length 1 is now stored in .zattrs
as a singleton rather than an array of length 1. This make the generated
Zarr more consistent with other Zarr implementations.

Misc. other changes:

1. Fix bug in testpathcvt caused by the way various shells handle backslash escapes.
2. Fix bug in testauth where test for MSVC is wrong.
@DennisHeimbigner
Copy link
Collaborator

Fixed by PR #2017

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

Successfully merging a pull request may close this issue.

2 participants