geoh5py.io package#
Submodules#
geoh5py.io.h5_reader module#
- class geoh5py.io.h5_reader.H5Reader#
Bases:
objectClass to read information from a geoh5 file.
- classmethod fetch_array_attribute(file: str | File, uid: UUID, entity_type: str, key: str) ndarray | None#
Get an entity attribute stores as array such as
cells.- Parameters:
file –
h5py.Fileor name of the target geoh5 fileuid – Unique identifier of the target object.
entity_type – Group type to fetch entity from.
key – Field attribute name.
- Return cells:
numpy.ndarrayofint.
- classmethod fetch_attributes(file: str | File, uid: UUID, entity_type: str) tuple[dict, dict, dict] | tuple[None, None, None]#
Get attributes of an
Entity.- Parameters:
file –
h5py.Fileor name of the target geoh5 fileuid – Unique identifier
entity_type – Type of entity from ‘group’, ‘data’, ‘object’, ‘group_type’, ‘data_type’, ‘object_type’
Returns#
attributes:
dictof attributes for theEntitytype_attributes:dictof attributes for theEntityTypeproperty_groups:dictof datauuid.UUID
- classmethod fetch_children(file: str | File, uid: UUID, entity_type: str) dict#
Get
childrenof anEntity.- Parameters:
file –
h5py.Fileor name of the target geoh5 fileuid – Unique identifier
entity_type – Type of entity from ‘group’, ‘data’, ‘object’, ‘group_type’, ‘data_type’, ‘object_type’
- Return children:
[{uuid: type}, … ] List of dictionaries for the children uid and type
- classmethod fetch_concatenated_attributes(file: str | File, uid: UUID, entity_type: str, label: str) list | dict | None#
Get ‘Attributes’, ‘Data’ or ‘Index’ from Concatenator group.
- Parameters:
file –
h5py.Fileor name of the target geoh5 fileuid – Unique identifier
entity_type – Type of entity from ‘group’, ‘data’, ‘object’, ‘group_type’, ‘data_type’, ‘object_type’
label – Group identifier for the attribute requested.
- Return children:
[{uuid: type}, … ] List of dictionaries for the children uid and type
- classmethod fetch_concatenated_values(file: str | File, uid: UUID, entity_type: str, label: str) tuple | None#
Get
childrenvalues of concatenated group.- Parameters:
file –
h5py.Fileor name of the target geoh5 fileuid – Unique identifier
entity_type – Type of entity from ‘group’, ‘data’, ‘object’, ‘group_type’, ‘data_type’, ‘object_type’
label – Group identifier for the attribute requested.
- Return children:
[{uuid: type}, … ] List of dictionaries for the children uid and type
- classmethod fetch_file_object(file: str | File, uid: UUID, file_name: str) bytes | None#
Load data associated with an image file
- Parameters:
file – Name of the target geoh5 file
uid – Unique identifier of the target entity
file_name – Name of the file stored as bytes data.
- Return values:
Data file stored as bytes
- classmethod fetch_metadata(file: str | File, uid: UUID, entity_type: str = 'Objects', argument: str = 'Metadata') str | dict | None#
Fetch text of dictionary type attributes of an entity.
- Parameters:
file – Target h5 file.
uid – Unique identifier of the target Entity.
entity_type – Base type of the target Entity.
argument – Label name of the dictionary.
- classmethod fetch_project_attributes(file: str | File) dict[Any, Any]#
Get attributes of an
Entity.- Parameters:
file –
h5py.Fileor name of the target geoh5 file- Return attributes:
dictof attributes.
- classmethod fetch_property_groups(file: str | File, uid: UUID) dict[str, dict[str, str]]#
Get the property groups.
- Parameters:
file –
h5py.Fileor name of the target geoh5 fileuid – Unique identifier of the target entity
- Return property_group_attributes:
dictof property groups and respective attributes.
property_group = { "group_1": {"attribute": value, ...}, ..., "group_N": {"attribute": value, ...}, }
- classmethod fetch_type(file: str | File, uid: UUID, entity_type: str) dict#
Fetch a type from the target geoh5.
- Parameters:
file –
h5py.Fileor name of the target geoh5 fileuid – Unique identifier of the target entity
entity_type – One of ‘Data’, ‘Object’ or ‘Group’
- Return property_group_attributes:
dictof property groups and respective attributes.
- classmethod fetch_type_attributes(type_handle: Group) dict#
Fetch type attributes from a given h5 handle.
- classmethod fetch_uuids(file: str | File, entity_type: str) list#
Fetch all uuids of a given type from geoh5
- Parameters:
file –
h5py.Fileor name of the target geoh5 fileentity_type – Type of entity from ‘group’, ‘data’, ‘object’, ‘group_type’, ‘data_type’, ‘object_type’
- Return uuids:
[uuid1, uuid2, …] List of uuids
- classmethod fetch_values(file: str | File, uid: UUID) ndarray | str | float | None#
Get data
values- Parameters:
file –
h5py.Fileor name of the target geoh5 fileuid – Unique identifier of the target entity
- Return values:
numpy.arrayoffloat
- static format_type_string(string: str) str#
Format names used for types.
geoh5py.io.h5_writer module#
- class geoh5py.io.h5_writer.H5Writer#
Bases:
objectWriting class to a geoh5 file.
- static add_or_update_property_group(file, property_group, remove=False)#
Update a
PropertyGroupassociated with anEntity.- Parameters:
file – Name or handle to a geoh5 file.
property_group – Target PropertyGroup
- static clear_stats_cache(file: str | File, entity: Data) None#
Clear the StatsCache dataset.
- Parameters:
file – Name or handle to a geoh5 file.
entity – Target entity.
- static create_dataset(entity_handle, dataset: ndarray, label: str) None#
Create a dataset on geoh5.
- Parameters:
entity_handle – Pointer to a hdf5 group
dataset – Array of values to be written
label – Name of the dataset on file
- static fetch_handle(file: str | File, entity, return_parent: bool = False) None | Group#
Get a pointer to an
Entityin geoh5.- Parameters:
file – Name or handle to a geoh5 file
entity – Target
Entityreturn_parent – Option to return the handle to the parent entity.
- Return entity_handle:
HDF5 pointer to an existing entity, parent or None if not found.
- static init_geoh5(file: str | h5py.File, workspace: workspace.Workspace)#
Add the geoh5 core structure.
- Parameters:
file – Name or handle to a geoh5 file.
workspace –
Workspaceobject defining the project structure.
- Return h5file:
Pointer to a geoh5 file.
- static prepare_data_to_write(h5file: File, entity: Data | Group | ObjectBase, attribute: str) tuple[Group, str] | tuple[None, None]#
Prepare data to be written to a geoh5 file.
- Parameters:
h5file – Name or handle to a geoh5 file.
entity – Entity with attributes to be added to the geoh5 file.
attribute – The attribute to be written to the geoh5 file.
- Returns:
The entity handle, the name map, and the values to be written to the geoh5 file.
- static remove_child(file: str | File, uid: UUID, ref_type: str, parent: Entity) None#
Remove a child from a parent.
- Parameters:
file – Name or handle to a geoh5 file
uid – uuid of the target
Entityref_type – Input type from: ‘Types’, ‘Groups’, ‘Objects’ or ‘Data
parent – Remove entity from parent.
- static remove_entity(file: str | File, uid: UUID, ref_type: str, parent: Entity | None = None) None#
Remove an entity and its type from the target geoh5 file.
- Parameters:
file – Name or handle to a geoh5 file
uid – uuid of the target
Entityref_type – Input type from: ‘Types’, ‘Groups’, ‘Objects’ or ‘Data
parent – Remove entity from parent.
- static save_entity(file: str | File, entity, compression: int = 5, add_children: bool = True) Group#
Save a
Entityto geoh5 with itschildrenrecursively.- Parameters:
file – Name or handle to a geoh5 file.
entity – Target
Entity.compression – Compression level for the data.
add_children – Add
children.
- str_type = dtype('O')#
- static update_concatenated_field(file: str | File, entity, attribute: str, channel: str) None#
Update the attributes of a concatenated
Entity.- Parameters:
file – Name or handle to a geoh5 file.
entity – Target
Entity.attribute – Name of the attribute to get updated.
channel – Name of the data or index to be modified.
- static update_field(file: str | File, entity, attribute: str, compression: int = 5, **kwargs) None#
Update the attributes of an
Entity.- Parameters:
file – Name or handle to a geoh5 file.
entity – Target
Entity.attribute – Name of the attribute to get updated.
compression – Compression level for the data.
- static write_array_attribute(file: str | File, entity, attribute, values=None, **kwargs) None#
Add
surveysof an object.- Parameters:
file – Name or handle to a geoh5 file.
entity – Target entity.
attribute – Name of the attribute to be written to geoh5
- static write_attributes(file: str | File, entity) None#
Write attributes of an
Entity.- Parameters:
file – Name or handle to a geoh5 file.
entity – Entity with attributes to be added to the geoh5 file.
- static write_color_map(file: str | h5py.File, entity_type: shared.EntityType) None#
-
- Parameters:
file – Name or handle to a geoh5 file
entity_type – Target entity_type with color_map
- static write_data_map(file: str | File, data: ReferencedData)#
Write the value map of geometric data.
- Parameters:
file – Name or handle to a geoh5 file
data – Target referenced data with value map
- static write_data_values(file: str | File, entity: Data, attribute, compression: int, **kwargs) None#
Add data
values.- Parameters:
file – Name or handle to a geoh5 file.
entity – Target entity.
attribute – Name of the attribute to be written to geoh5
compression – Compression level for the data.
- static write_entity(file: str | File, entity, compression: int) Group#
Add an
Entityand its attributes to geoh5. The function returns a pointer to the entity if already present on file.- Parameters:
file – Name or handle to a geoh5 file.
entity – Target
Entity.compression – Compression level for data.
- Return entity:
Pointer to the written entity. Active link if “close_file” is False.
- static write_entity_type(file: str | h5py.File, entity_type: shared.EntityType | ReferenceDataType) h5py.Group#
Add an
EntityTypeto geoh5.- Parameters:
file – Name or handle to a geoh5 file.
entity_type – Entity with type to be added.
- Return type:
Pointer to
EntityTypein geoh5.
- static write_file_name_data(entity_handle: Group, entity: FilenameData) None#
Write a dataset for the file name and file blob.
- Parameters:
entity_handle – Pointer to the geoh5 Group.
entity – Target
FilenameDataentity.values – Bytes data
- static write_group_values(file: str | File, entity: Group, attribute, compression: int, values=None, **kwargs)#
Add Concatenator values.
- Parameters:
file – Name or handle to a geoh5 file.
entity – Target entity.
attribute – Name of the attribute to be written to geoh5
compression – Compression level for the data.
values – Data values.
- static write_metadata(file: str | File, entity: Group | ObjectBase, attribute, values=None, **kwargs) None#
Add data
values.- Parameters:
file – Name or handle to a geoh5 file.
entity – Target entity.
attribute – Name of the attribute to be written to geoh5
values – Data values.
- static write_properties(file: str | File, entity: Entity, compression: int) None#
Add properties of an
Entity.- Parameters:
file – Name or handle to a geoh5 file.
entity – Target
Entity.compression – Compression level for data.
- static write_property_groups(file: str | File, entity) None#
Write
PropertyGroupassociated with anEntity.- Parameters:
file – Name or handle to a geoh5 file.
entity – Target
Entity.
- static write_to_parent(file: str | File, entity: Entity, compression: int, recursively: bool = False) None#
Add/create an
Entityand add it to its parent.- Parameters:
file – Name or handle to a geoh5 file.
entity – Entity to be added or linked to a parent in geoh5.
compression – Compression level for data.
recursively – Add parents recursively until reaching the
RootGroup.
- static write_value_map(file: str | File, entity_type: ReferenceDataType, name='Value map', value_map: ReferenceValueMap | None = None) None#
Add
ReferenceValueMapto aDataType.- Parameters:
file – Name or handle to a geoh5 file
entity_type – Target entity_type with value_map
name – Name of the value map
value_map – Value map to be written
- static write_visible(file: str | File, entity) None#
Needs revision once Visualization is implemented
- Parameters:
file – Name or handle to a geoh5 file
entity – Target entity
geoh5py.io.utils module#
- geoh5py.io.utils.str_from_subtype(entity_type: EntityType) str#
Convert sub entity type to geoh5 string standard.
- Parameters:
entity_type – Sub-class of entity type.
- Returns:
String equivalent.
- geoh5py.io.utils.str_from_type(entity: Entity | PropertyGroup | EntityType) str#
Convert entity type to geoh5 string standard.
- Parameters:
entity – Entity, PropertyGroup or EntityType
- Returns:
String equivalent.