A CFood for hdf5 files
This module allows to parse hdf5 files and reproduce their structure in form of Records that reference each other.
hdf5 files are composed of groups and datasets. Both of which can have attributes. Groups and datasets are mapped to Records and attributes to Properties.
H5CFood which consumes a HDF5 file.
The structure is mapped onto an equivalent structure of interconnected Records.
Name of the hdf5-file to read
h5py.File, default None
The CFood collects information for further processing.
Often CFoods need information from files or even from the database in order to make processing decision. It is intended that this function is called after match. Thus match can be used without connecting to the database.
To be overwritten by subclasses
Create identifiables out of groups in the HDF5 file.
This method will call is_identifiable(h5path, h5object) and create_identifiable(h5path, h5object) on each HDF5 object to decide and actually create the identifiables.
create_structure(h5obj, create_recordTypes=False, collection=None, special_treatment=None, root_name='root')
Create Records and Record types from a given hdf5-object for all items in the tree. Attributes are added as properties, the values only if the dimension < 2.
h5obj (h5py.File) – a hdf5-file object
root_name (name that is used instead of '/') – Type of the root Record (the Record corresponding to the root node in the HDF5 file)
rec – Contains the Record Types, Records and Properties for the input-tree
- Return type
special_treatment(key, value, dtype)
define special treatment of attributes
to be overwritten by child classes.
key: attribute name value: attribute value
Check if the identifiables need to be updated.
In that case also add the updated entities to the list of updateables.
This method will iterate over the groups and datasets governed by this CFood’s identifiables and call
update_object(path, h5object)on each object.
returns the value and datatype of a CaosDB Property for the given value
1d arrays are converted to lists If no suitable Property can be created (None, None) is returned.
2d and higher dimensionality arrays are being ignored.