netcdf-c: NetCDF unable to read some HDF5 enums
h5py stores boolean data using an HDF5 enum: http://docs.h5py.org/en/latest/faq.html
The attached file is a such an example: test.nc.zip
However, the netCDF-C library doesn’t report these variables at all:
$ ncdump test.nc
netcdf test {
}
This is somewhat unfortunate.
Here’s the output of h5dump on the file, along with a file created via netCDF4:
$ h5dump test.nc $ made with h5py
HDF5 "test.nc" {
GROUP "/" {
DATASET "foo" {
DATATYPE H5T_ENUM {
H5T_STD_I8LE;
"FALSE" 0;
"TRUE" 1;
}
DATASPACE SCALAR
DATA {
(0): TRUE
}
}
}
}
$ h5dump test2.nc # made with netCDF4-python
HDF5 "test2.nc" {
GROUP "/" {
DATATYPE "boolean" H5T_ENUM {
H5T_STD_I8LE;
"FALSE" 0;
"TRUE" 1;
};
DATASET "foo" {
DATATYPE H5T_ENUM {
H5T_STD_I8LE;
"FALSE" 0;
"TRUE" 1;
}
DATASPACE SCALAR
DATA {
(0): TRUE
}
}
}
}
Scripts to produce these files:
import h5py
import numpy as np
with h5py.File('test.nc') as f:
f.create_dataset('foo', data=np.array(True))
import netCDF4
import numpy as np
with netCDF4.Dataset('test2.nc', 'w') as ds:
dt = ds.createEnumType('i1', 'boolean', {'FALSE': 0, 'TRUE': 1})
v = ds.createVariable('foo', dt, ())
v[:] = True
ncdump reports “netcdf library version 4.4.0”
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 28 (18 by maintainers)
Thanks, if I’m not back in a year or so, consider me lost in space.