geoh5py.io package¶
Submodules¶
geoh5py.io.h5_reader module¶
- class geoh5py.io.h5_reader.H5Reader[source]¶
Bases:
object
Class to read information from a geoh5 file.
- classmethod fetch_attributes(file: str | h5py.File, uid: uuid.UUID, entity_type: str) tuple[dict, dict, dict] [source]¶
Get attributes of an
Entity
.- Parameters
file –
h5py.File
or 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:obj:dict of attributes for the
Entity
- type_attributes:obj:dict of attributes for the
EntityType
- property_groups:obj:dict of data
uuid.UUID
- attributes:obj:dict of attributes for the
- classmethod fetch_cells(file: str | h5py.File, uid: uuid.UUID) np.ndarray | None [source]¶
Get an object’s
cells
.- Parameters
file –
h5py.File
or name of the target geoh5 fileuid – Unique identifier of the target object.
- Return cells
numpy.ndarray
ofint
.
- classmethod fetch_children(file: str | h5py.File, uid: uuid.UUID, entity_type: str) dict [source]¶
-
- Parameters
file –
h5py.File
or 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_coordinates(file: str | h5py.File, uid: uuid.UUID, name: str) np.ndarray | None [source]¶
Get an object coordinates data.
- Parameters
file –
h5py.File
or name of the target geoh5 fileuid – Unique identifier of the target object
name – Type of coordinates ‘vertices’, ‘trace’ or ‘surveys’
- Return surveys
numpy.ndarray
of [x, y, z] coordinates
- classmethod fetch_delimiters(file: str | h5py.File, uid: uuid.UUID) tuple[np.ndarray, np.ndarray, np.ndarray] [source]¶
Get the delimiters of a
BlockModel
.- Parameters
file –
h5py.File
or name of the target geoh5 fileuid – Unique identifier of the target entity.
- Returns
- u_delimiters:obj:numpy.ndarray of u_delimiters
- v_delimiters:obj:numpy.ndarray of v_delimiters
- z_delimiters:obj:numpy.ndarray of z_delimiters
- classmethod fetch_metadata(file: str | h5py.File, uid: uuid.UUID) str | dict | None [source]¶
Fetch the metadata of an entity.
- classmethod fetch_octree_cells(file: str | h5py.File, uid: uuid.UUID) np.ndarray [source]¶
-
- Parameters
file –
h5py.File
or name of the target geoh5 fileuid – Unique identifier of the target entity.
- Return octree_cells
numpy.ndarray
ofint
.
- classmethod fetch_project_attributes(file: str | h5py.File) dict[Any, Any] [source]¶
Get attributes of an
Entity
.- Parameters
file –
h5py.File
or name of the target geoh5 file- Return attributes
dict
of attributes.
- classmethod fetch_property_groups(file: str | h5py.File, uid: uuid.UUID) dict[str, dict[str, str]] [source]¶
Get the property groups.
- Parameters
file –
h5py.File
or name of the target geoh5 fileuid – Unique identifier of the target entity
- Return property_group_attributes
dict
of property groups and respective attributes.
property_group = { "group_1": {"attribute": value, ...}, ..., "group_N": {"attribute": value, ...}, }
- classmethod fetch_trace_depth(file: str | h5py.File, uid: uuid.UUID) np.ndarray [source]¶
Get an object
trace_depth
data- Parameters
file –
h5py.File
or name of the target geoh5 fileuid – Unique identifier of the target object
- Return surveys
numpy.ndarray
of [x, y, z] coordinates
- classmethod fetch_uuids(file: str | h5py.File, entity_type: str) list [source]¶
Fetch all uuids of a given type from geoh5
- Parameters
file –
h5py.File
or 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_value_map(file: str | h5py.File, uid: uuid.UUID) dict [source]¶
Get data
value_map
- Parameters
file –
h5py.File
or name of the target geoh5 fileuid – Unique identifier of the target entity
- Return value_map
dict
of {int
:str
}
- classmethod fetch_values(file: str | h5py.File, uid: uuid.UUID) float | None [source]¶
Get data
values
- Parameters
file –
h5py.File
or name of the target geoh5 fileuid – Unique identifier of the target entity
- Return values
numpy.array
offloat
- key_map = {'cells': 'Cells', 'color_map': 'Color map', 'octree_cells': 'Octree Cells', 'property_groups': 'PropertyGroups', 'surveys': 'Surveys', 'trace': 'Trace', 'trace_depth': 'TraceDepth', 'values': 'Data', 'vertices': 'Vertices'}¶
geoh5py.io.h5_writer module¶
- class geoh5py.io.h5_writer.H5Writer[source]¶
Bases:
object
Writing class to a geoh5 file.
- classmethod create_dataset(entity_handle, dataset: numpy.ndarray, label: str)[source]¶
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
- classmethod create_geoh5(file: str | h5py.File, workspace: workspace.Workspace)[source]¶
Add the geoh5 core structure.
- Parameters
file – Name or handle to a geoh5 file.
workspace –
Workspace
object defining the project structure.
- Return h5file
Pointer to a geoh5 file.
- classmethod fetch_handle(file: str | h5py.File, entity, return_parent: bool = False)[source]¶
Get a pointer to an
Entity
in geoh5.- Parameters
file – Name or handle to a geoh5 file
entity – Target
Entity
return_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.
- classmethod finalize(file: str | h5py.File, workspace: workspace.Workspace)[source]¶
Add/replace the
RootGroup
in geoh5.- Parameters
file – Name or handle to a geoh5 file
workspace – Workspace object defining the project structure.
- key_map = {'cells': 'Cells', 'color_map': 'Color map', 'metadata': 'Metadata', 'octree_cells': 'Octree Cells', 'property_groups': 'PropertyGroups', 'surveys': 'Surveys', 'trace': 'Trace', 'trace_depth': 'TraceDepth', 'values': 'Data', 'vertices': 'Vertices'}¶
- static remove_child(file: str | h5py.File, uid: uuid.UUID, ref_type: str, parent: Entity)[source]¶
Remove a child from a parent.
- Parameters
file – Name or handle to a geoh5 file
uid – uuid of the target
Entity
ref_type – Input type from: ‘Types’, ‘Groups’, ‘Objects’ or ‘Data
parent – Remove entity from parent.
- static remove_entity(file: str | h5py.File, uid: uuid.UUID, ref_type: str, parent: Entity = None)[source]¶
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
Entity
ref_type – Input type from: ‘Types’, ‘Groups’, ‘Objects’ or ‘Data
parent – Remove entity from parent.
- str_type = dtype('O')¶
- classmethod update_attributes(file: str | h5py.File, entity)[source]¶
Update the attributes of an
Entity
.- Parameters
file – Name or handle to a geoh5 file.
entity – Target
Entity
.
- classmethod write_attributes(file: str | h5py.File, entity)[source]¶
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.
- classmethod write_cell_delimiters(file: str | h5py.File, entity)[source]¶
Add cell delimiters (u, v, z) to a
BlockModel
.- Parameters
file – Name or handle to a geoh5 file
entity – Target entity
- classmethod write_cells(file: str | h5py.File, entity)[source]¶
Add
cells
.- Parameters
file – Name or handle to a geoh5 file
entity – Target entity
- classmethod write_color_map(file: str | h5py.File, entity_type: shared.EntityType)[source]¶
-
- Parameters
file – Name or handle to a geoh5 file
entity_type – Target entity_type with color_map
- classmethod write_coordinates(file: str | h5py.File, entity, attribute)[source]¶
Add
surveys
of an object.- Parameters
file – Name or handle to a geoh5 file.
entity – Target entity.
attribute – Name of the attribute to be written to geoh5
- classmethod write_data_values(file: str | h5py.File, entity, attribute)[source]¶
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
- classmethod write_entity(file: str | h5py.File, entity)[source]¶
Add an
Entity
and 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
.
- Return entity
Pointer to the written entity. Active link if “close_file” is False.
- classmethod write_entity_type(file: str | h5py.File, entity_type: shared.EntityType)[source]¶
Add an
EntityType
to geoh5.- Parameters
file – Name or handle to a geoh5 file.
entity_type – Entity with type to be added.
- Return type
Pointer to
EntityType
in geoh5.
- classmethod write_octree_cells(file: str | h5py.File, entity)[source]¶
Add
cells
of anOctree
object to geoh5.- Parameters
file – Name or handle to a geoh5 file.
entity – Target entity_type with color_map.
- classmethod write_properties(file: str | h5py.File, entity: Entity)[source]¶
Add properties of an
Entity
.- Parameters
file – Name or handle to a geoh5 file.
entity – Target
Entity
.
- classmethod write_property_groups(file: str | h5py.File, entity)[source]¶
Write
PropertyGroup
associated with anEntity
.- Parameters
file – Name or handle to a geoh5 file.
entity – Target
Entity
.
- classmethod write_to_parent(file: str | h5py.File, entity: Entity, recursively=False)[source]¶
Add/create an
Entity
and 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.
recursively – Add parents recursively until reaching the
RootGroup
.
- classmethod write_value_map(file: str | h5py.File, entity_type: shared.EntityType)[source]¶
Add
ReferenceValueMap
to aDataType
.- Parameters
file – Name or handle to a geoh5 file
entity_type – Target entity_type with value_map