I have the following Numpy dtype for an array:
dtype([('Object_type', 'S30'), ('ID', 'S30'), ('Version', '<i4'), ('basis_1', [('x', '<f8'), ('y', '<f8'), ('z', '<f8')]), ('basis_2', [('x', '<f8'), ('y', '<f8'), ('z', '<f8')]), ('centre_point', [('x', '<f8'), ('y', '<f8'), ('z', '<f8')]), ('width', '<f8'), ('height', '<f8'), ('slit_id', 'S30'), ('slit_no', '<i4')])
When I try to create a NetCDF compound type from this dtype, I get the following error:
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) netCDF4/_netCDF4.pyx in netCDF4._netCDF4._def_compound (netCDF4/_netCDF4.c:51191)() KeyError: 'S30' During handling of the above exception, another exception occurred: ValueError Traceback (most recent call last) <ipython-input-247-c1ab3d42293b> in <module>() 20 nc_coord = bolo_group.createCompoundType(cartesian_coord, "COORDINATE") ---> 21 nc_detector = bolo_group.createCompoundType(aperture_dtype_full, "DETECTOR") 22 foil_no = bolo_group.createDimension("foil_no", foils.size) netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Dataset.createCompoundType (netCDF4/_netCDF4.c:16268)() netCDF4/_netCDF4.pyx in netCDF4._netCDF4.CompoundType.__init__ (netCDF4/_netCDF4.c:49971)() netCDF4/_netCDF4.pyx in netCDF4._netCDF4._def_compound (netCDF4/_netCDF4.c:51245)() ValueError: Unsupported compound type element During handling of the above exception, another exception occurred: RuntimeError Traceback (most recent call last) <ipython-input-247-c1ab3d42293b> in <module>() 27 nc_slits = sxd_group.createVariable("slits", nc_detector, "slit_no") 28 nc_slits[:] = slits_full ---> 29 nc_slits.units = "mm" netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Dataset.__exit__ (netCDF4/_netCDF4.c:13090)() netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Dataset.close (netCDF4/_netCDF4.c:15045)() RuntimeError: NetCDF: HDF error
I understand that it is not possible to create compound types which include variable-length arrays, but the Numpy '<S30' type should always be 30 bytes, not a variable length. This is actually why I'm using S30 and not U30, since the latter may have multi-byte characters.
Is it possible to add support for the S30 dtype in netcdf4-python? Otherwise, is there another way that I can include fixed length string types in a NetCDF compound type?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4