-
Notifications
You must be signed in to change notification settings - Fork 58
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
Wrong error with flag_masks containing only one element #914
Comments
Maybe related to #792 |
Hi, It's been a while since I've reviewed implementation of the flags (although I am am recently re-reviewing the conformance pages). In the CF 1.6 conventions flags section, there is the following snippet (emphasis mine):
|
Hi, do you mean that it is not allowed with CF to have a flags variable containing only one bit field? What is the reason? This seems not very logical to me. |
Note also that the other NetCDF checker https://github.com/cedadev/cf-checker accepts scalar flag_masks. |
Hi, it looks like netCDF4-Python casts one-element 1D arrays to the corresponding scalar type of the first (and only) element. I checked both the NetCDF User Guide and the netCDF4 Python Documentation to see if there was something describing this behavior. It looks like it may be related to the NetCDF4 classic data model wherein attributes are a 1D array of values: https://www.unidata.ucar.edu/software/netcdf/workshops/2011/datamodels/NcClassicModel.html . If this is the case, this will be a bug on our end, although the behavior could be made a little clearer in the Python NetCDF4 documentation. Usually files with
|
@jdemaria, I tried your file generated from |
@benjwadams, I confirm that your fix works on my side too, thanks a lot for the quick analysis and fix! |
Version of compliance checker running: latest git master version at this time: 79c67c4
Describe the checker this affects: CF
Attach a minimal CDL or NetCDF file which is able to reproduce the issue
flag_masks_one_elem.txt
To Reproduce:
Describe the issue below:
flag_masks attribute containing only one element seems not well supported as it should be and gives this error:
With at least two elements in flag_masks there is no error.
Maybe this is related to the fact that the netCDF4 or xarray Python modules return a scalar numpy.int8 if the attribute has only one elements but a numpy.ndarray if it has more than one, which is not always easy to handle.
The text was updated successfully, but these errors were encountered: