You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The NUG indicates that strings (dimension and variable names, anyway) should be NFC normalized.
"""
... names are normalized according to Unicode NFC normalization rules during encoding as UTF-8 for storing in the file header. This is necessary to ensure that gratuitous differences in the representation of Unicode names do not cause anomalies in comparing files and querying data objects by name.
"""
(and next CF release will specify NFC normalization for all text)
But as far as I can tell, netCDF4 isn't doing that. It probably should.
That section of the NUG only applies to netcdf classic, not HDF5. Plus, I read that as meaning that the library does that for you (so the python layer doesn't need to).
Hmm -- I'm pretty sure that all variable and dimension names are supposed to be NFC normalized. The sectionof the NUG does talk about he Header, so yes, probably only vital for netcdf classic. But still a good idea, and CF will be requiring it anyway.
The search on the NUG is broken, so I'm having a hard time finding what I'm looking for :-(
The library does that for you,
I doubt it -- but worth a look. It would be great if it did.
Another potential issue -- not sure if this is something that should be built in to the lib:
The next version of CF will specify that attributes should be NFC normalized. This is because a number of CF attributes reference variable names, so they really need to be exact / compare equally.
I just tested, and string attributes are not being normalized.
So the netCDF4 lib could normalize attributes too.
(so could the C lib, but I'm guessing they won't want to go there -- it's not critical to netcdf itself)
Activity
jswhit commentedon Oct 29, 2024
That section of the NUG only applies to netcdf classic, not HDF5. Plus, I read that as meaning that the library does that for you (so the python layer doesn't need to).
ChrisBarker-NOAA commentedon Oct 29, 2024
Hmm -- I'm pretty sure that all variable and dimension names are supposed to be NFC normalized. The sectionof the NUG does talk about he Header, so yes, probably only vital for netcdf classic. But still a good idea, and CF will be requiring it anyway.
The search on the NUG is broken, so I'm having a hard time finding what I'm looking for :-(
I doubt it -- but worth a look. It would be great if it did.
I'll try to poke into it.
ChrisBarker-NOAA commentedon Oct 29, 2024
OK -- I've poked into it, and you are completely correct -- the netCDF C lib is NFC normalizing variable names. Here's an experiment with netCDF4:
And when run:
So indeed, the C lib is doing it for you -- nothing to be done here.
Except maybe a note in the docs ...
ChrisBarker-NOAA commentedon Oct 29, 2024
Another potential issue -- not sure if this is something that should be built in to the lib:
The next version of CF will specify that attributes should be NFC normalized. This is because a number of CF attributes reference variable names, so they really need to be exact / compare equally.
I just tested, and string attributes are not being normalized.
So the netCDF4 lib could normalize attributes too.
(so could the C lib, but I'm guessing they won't want to go there -- it's not critical to netcdf itself)