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(h5file: str, uid: uuid.UUID, entity_type: str) → Tuple[dict, dict, dict][source]

Get attributes of an Entity

Parameters
  • h5file – 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: dict of attributes for the Entity
type_attributes: dict of attributes for the EntityType
property_groups: dict of data uuid.UUID
classmethod fetch_cells(h5file: Union[str, NoneType], uid: uuid.UUID) → numpy.ndarray[source]

Get an object’s cells

Parameters
  • h5file – Name of the target geoh5 file

  • uid – Unique identifier of the target object

Return cells

numpy.ndarray of int

classmethod fetch_children(h5file: str, uid: uuid.UUID, entity_type: str) → dict[source]

Get children of an Entity

Parameters
  • h5file – 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_delimiters(h5file: Union[str, NoneType], uid: uuid.UUID) → Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]

Get the delimiters of a BlockModel

Parameters
  • h5file – Name of the target geoh5 file

  • uid – Unique identifier of the target entity

Returns
u_delimiters: numpy.ndarray of u_delimiters
v_delimiters: numpy.ndarray of v_delimiters
z_delimiters: numpy.ndarray of z_delimiters
classmethod fetch_octree_cells(h5file: Union[str, NoneType], uid: uuid.UUID) → numpy.ndarray[source]

Get Octree cells.

Parameters
  • h5file – Name of the target geoh5 file

  • uid – Unique identifier of the target entity

Return octree_cells

numpy.ndarray of int

classmethod fetch_project_attributes(h5file: str) → Dict[Any, Any][source]

Get attributes of an Entity

Parameters

h5file – Name of the target geoh5 file

Return attributes

dict of attributes

classmethod fetch_property_groups(h5file: Union[str, NoneType], uid: uuid.UUID) → Dict[str, Dict[str, str]][source]

Get the property groups

Parameters
  • h5file – Name of the target geoh5 file

  • uid – Unique identifier of the target entity

Return property_group_attributes

dict of property groups and respective attributes

\[\{"group_1": \{"attribute": value, ...\}, \{...\}\}\]
classmethod fetch_values(h5file: Union[str, NoneType], uid: uuid.UUID) → Union[float, NoneType][source]

Get data values

Parameters
  • h5file – Name of the target geoh5 file

  • uid – Unique identifier of the target entity

Return values

numpy.array of float

classmethod fetch_vertices(h5file: Union[str, NoneType], uid: uuid.UUID) → numpy.ndarray[source]

Get an object vertices

Parameters
  • h5file – Name of the target geoh5 file

  • uid – Unique identifier of the target object

Return vertices

numpy.ndarray of [x, y, z] coordinates

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_geoh5(workspace: ‘workspace.Workspace’, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True)[source]

Create a geoh5 file and add the core structure

Parameters
  • workspaceWorkspace object defining the project structure.

  • file – Name or handle to a geoh5 file

  • close_file – Close file after write

Return h5file

Pointer to a geoh5 file

static fetch_h5_handle(file: Union[str, h5py._hl.files.File, NoneType], entity: Union[geoh5py.shared.entity.Entity, ForwardRef(‘shared.EntityType’)]) → h5py._hl.files.File[source]

Open in read+ mode a geoh5 file

Parameters
  • file – Name or handle to a geoh5 file

  • entity – Target Entity

Return h5py.File

Handle to an opened h5py file

classmethod fetch_handle(file: Union[str, h5py._hl.files.File, NoneType], entity)[source]

Get a pointer to an Entity in geoh5.

Parameters
  • file – Name or handle to a geoh5 file

  • entity – Target Entity

Return entity_handle

Pointer to an existing entity or None if not found

classmethod finalize(workspace, close_file=False)[source]

Add/replace the RootGroup in geoh5

Parameters
  • workspace – Workspace object defining the project structure

  • close_file – Close file after write [False]

classmethod save_entity(entity: geoh5py.shared.entity.Entity, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True, add_children: bool = True)[source]

Write an Entity to geoh5 with its children

Parameters
  • entity – Target Entity

  • file – Name or handle to a geoh5 file

  • close_file – Close file after write

  • add_children – Add children

str_type = dtype('O')
classmethod update_attributes(entity, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True)[source]

Update the attributes of an Entity

Parameters
  • entity – Target Entity

  • file – Name or handle to a geoh5 file

  • close_file – Close file after write

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(entity, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True)[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

  • close_file – Close file after write

classmethod write_cell_delimiters(entity, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True)[source]

Add cell delimiters (u, v, z) to a BlockModel.

Parameters
  • file – Name or handle to a geoh5 file

  • entity – Target entity

  • close_file – Close geoh5 file after write

classmethod write_cells(entity, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True)[source]

Add cells

Parameters
  • file – Name or handle to a geoh5 file

  • entity – Target entity

  • close_file – Close geoh5 file after write

classmethod write_color_map(entity_type: ‘shared.EntityType’, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True)[source]

Add ColorMap to a DataType

Parameters
  • file – Name or handle to a geoh5 file

  • entity_type – Target entity_type with color_map

  • close_file – Close geoh5 file after write

classmethod write_data_values(entity, values, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True)[source]

Add data values

Parameters
  • file – Name or handle to a geoh5 file

  • entity – Target entity_type with color_map

  • values – Array of values to be added to the geoh5 file

  • close_file – Close geoh5 file after write

classmethod write_entity(entity, file: Union[str, h5py._hl.files.File, NoneType] = None, values=None, close_file: bool = True)[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

  • values – Array of values to be added to Data entity

  • close_file – Close file after write

Return entity

Pointer to the written entity. Active link if “close_file” is False

classmethod write_entity_type(entity_type: ‘shared.EntityType’, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True)[source]

Add an EntityType to geoh5.

Parameters
  • entity_type – Entity with type to be added

  • file – Name or handle to a geoh5 file

  • close_file – Close file after write

Return type

Pointer to EntityType in geoh5

classmethod write_octree_cells(entity, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True)[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

  • close_file – Close geoh5 file after write

classmethod write_properties(entity: geoh5py.shared.entity.Entity, file: Union[str, h5py._hl.files.File, NoneType] = None, values: Union[numpy.ndarray, NoneType] = None, close_file: bool = True)[source]

Add properties of an Entity

Parameters
  • entity – Target Entity

  • file – Name or handle to a geoh5 file

  • values – Array of values to be added

  • close_file – Close file after write

classmethod write_property_groups(entity, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True)[source]

Write PropertyGroup associated with an Entity.

Parameters
  • file – Name or handle to a geoh5 file

  • entity – Target Entity

  • close_file – Close file after write

classmethod write_to_parent(entity: geoh5py.shared.entity.Entity, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True, 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

  • close_file – Close file after write: [True] or False

  • recursively – Add parents recursively until reaching the RootGroup

classmethod write_vertices(entity, file: Union[str, h5py._hl.files.File, NoneType] = None, close_file: bool = True)[source]

Add vertices of an object.

Parameters
  • file – Name or handle to a geoh5 file

  • entity – Target entity

  • close_file – Close geoh5 file after write

Module contents