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

Is scalar flag_masks allowed? #151

Open
jdemaria opened this issue Apr 6, 2022 · 4 comments
Open

Is scalar flag_masks allowed? #151

jdemaria opened this issue Apr 6, 2022 · 4 comments
Labels
question Further information is requested or discussion invited

Comments

@jdemaria
Copy link

jdemaria commented Apr 6, 2022

Hi,

This CF checker complains about a scalar flag_masks:

Thanks,
Julien

@jdemaria jdemaria added the question Further information is requested or discussion invited label Apr 6, 2022
@benjwadams
Copy link

Note from linked conversation, this is probably due to how the Python NetCDF4 library handles assignment of scalar and single element, single dimension arrays. NetCDF classic data model treats attributes as 1D array of some type. NetCDF4 Python treats assignment of a single element array as the same as assignment of a scalar -- namely, it returns a scalar when interrogated for the value. As files with single flag_masks were not submitted very often and weren't under test, this case was not caught in my library.

@jdemaria
Copy link
Author

jdemaria commented Apr 7, 2022

Thanks for the answers Benjamin, yes the way NetCDF Python modules handle one element attribute is well-integrated but sometimes this is tricky to handle in our codes because in some cases you expect an array an get a scalar.

CF people, do you confirm that scalar flag_masks is allowed by the convention?

@benjwadams
Copy link

Please close, this likely has to do with external library implementation and representation of NetCDF attributes.

@jdemaria
Copy link
Author

jdemaria commented Apr 8, 2022

I think the CF section you pointed could be improved:

The flag_masks attribute is the same type as the variable to which it is attached, and contains a list of values matching unique bit fields

to value(s) (there are other usages of optional (s) in the specs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested or discussion invited
Projects
None yet
Development

No branches or pull requests

2 participants