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.

static bool_value(value: numpy.int8) bool[source]
classmethod fetch_attributes(file: str | h5py.File, uid: uuid.UUID, entity_type: str) tuple[dict, dict, dict][source]

Get attributes of an Entity.

Parameters
  • fileh5py.File or name of the target geoh5 file

  • uid – 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
classmethod fetch_cells(file: str | h5py.File, uid: uuid.UUID) np.ndarray | None[source]

Get an object’s cells.

Parameters
  • fileh5py.File or name of the target geoh5 file

  • uid – Unique identifier of the target object.

Return cells

numpy.ndarray of int.

classmethod fetch_children(file: str | h5py.File, uid: uuid.UUID, entity_type: str) dict[source]

Get children of an Entity.

Parameters
  • fileh5py.File or name of the target geoh5 file

  • uid – 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
  • fileh5py.File or name of the target geoh5 file

  • uid – 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
  • fileh5py.File or name of the target geoh5 file

  • uid – 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]

Get Octree cells.

Parameters
  • fileh5py.File or name of the target geoh5 file

  • uid – Unique identifier of the target entity.

Return octree_cells

numpy.ndarray of int.

classmethod fetch_project_attributes(file: str | h5py.File) dict[Any, Any][source]

Get attributes of an Entity.

Parameters

fileh5py.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
  • fileh5py.File or name of the target geoh5 file

  • uid – 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
  • fileh5py.File or name of the target geoh5 file

  • uid – 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
  • fileh5py.File or name of the target geoh5 file

  • entity_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
  • fileh5py.File or name of the target geoh5 file

  • uid – 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
  • fileh5py.File or name of the target geoh5 file

  • uid – Unique identifier of the target entity

Return values

numpy.array of float

static format_type_string(string)[source]
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'}
static str_from_utf8_bytes(value: bytes | str) str[source]
static uuid_str(value: uuid.UUID) str[source]
static uuid_value(value: str) uuid.UUID[source]

geoh5py.io.h5_writer module

class geoh5py.io.h5_writer.H5Writer[source]

Bases: object

Writing class to a geoh5 file.

static bool_value(value: numpy.int8) bool[source]

Convert integer to bool.

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.

  • workspaceWorkspace 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.

classmethod save_entity(file: str | h5py.File, entity, add_children: bool = True)[source]

Write an Entity to geoh5 with its children.

Parameters
  • file – Name or handle to a geoh5 file.

  • entity – Target Entity.

  • add_children – Add children.

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.

static uuid_str(value: uuid.UUID) str[source]

Convert uuid.UUID to string used in geoh5.

static uuid_value(value: str) uuid.UUID[source]

Convert string to uuid.UUID.

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]

Add ColorMap to a DataType.

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 an Octree 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 an Entity.

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 a DataType.

Parameters
  • file – Name or handle to a geoh5 file

  • entity_type – Target entity_type with value_map

classmethod write_visible(file: str | h5py.File, entity)[source]

Needs revision once Visualization is implemented

Parameters
  • file – Name or handle to a geoh5 file

  • entity – Target entity

Module contents