What is a good way to tell a netCDF4 file from a "regular" HDF5 file? #3085
-
I was originally intending to use Even My next best idea is to check for the presence of Is a I am working with v4.9.2 if it matters. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
This mostly a good way to tell the difference. There is a couple of issues, though. |
Beta Was this translation helpful? Give feedback.
-
There is one other possibility. There is an attribute called '_IsNetcdf4' that is backed by a program called "NC4_isnetcdf4" in "libhdf5/nc4hdf.c". The program looks for various elements of the netcdf-4/hdf5 file to decide if it was created by libnetcdf. |
Beta Was this translation helpful? Give feedback.
-
I could simplify that by having _IsNetcdf4 include a check for _NCProperties attribute along with its current checks. |
Beta Was this translation helpful? Give feedback.
-
In recent PR #3125, the check for the _NCProperties attribute was added to _IsNetcdf4. However, as already noted above, all netcdf-4 files created with library versions earlier than 4.4.1 (2016) do not have the _NCProperties attribute. Therefore, if I understand that PR correctly, all of these older netcdf-4 files will now read _IsNetcdf4 = "not netcdf-4". Do you have guidelines for how users should handle this apparent contradiction? Are you sure that adding the _NCProperties check is the right thing to do for the general community? Please excuse my fussing, but I think this could be trouble in some cases. |
Beta Was this translation helpful? Give feedback.
-
Did I screw up that PR? I intended that any single test passing in IsNetCDF4 would return true. |
Beta Was this translation helpful? Give feedback.
There is one other possibility. There is an attribute called '_IsNetcdf4' that is backed by a program called "NC4_isnetcdf4" in "libhdf5/nc4hdf.c". The program looks for various elements of the netcdf-4/hdf5 file to decide if it was created by libnetcdf.
Currently it tests for existence of a variety of attributes, dimension names,etc in the file. It occurs to me that if the program/attribute returns false, and the file is otherwise readable by libnetcdf, then is should be a pure HDF5 file.