geoh5py.data package

Submodules

geoh5py.data.blob_data module

class geoh5py.data.blob_data.BlobData(association: DataAssociationEnum = DataAssociationEnum.OBJECT, modifiable: bool = True, visible: bool = False, values: Any | None = None, **kwargs)[source]

Bases: Data

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

validate_values(values: Any | None) Any[source]

Validate values for BlobData.

geoh5py.data.boolean_data module

class geoh5py.data.boolean_data.BooleanData(**kwargs)[source]

Bases: ReferencedData

Data class for logical (bool) values.

property entity_type

ReferencedBooleanType

format_type(values: ndarray)[source]

Check if the type of values is valid and coerce to type bool. :param values: numpy array to modify. :return: the formatted values.

property formatted_values

The data with the right format for Geoscience ANALYST.

property ndv: int

No-Data-Value

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

geoh5py.data.color_map module

class geoh5py.data.color_map.ColorMap(**kwargs)[source]

Bases: object

Records colors assigned to value ranges (where Value is the start of the range).

property name: str

str: Name of the colormap

property parent: DataType | None

Parent data type

property values: ndarray

numpy.array: Colormap defined by values and corresponding RGBA:

values = [
    [V_1, R_1, G_1, B_1, A_1],
    ..., [V_i, R_i, G_i, B_i, A_i]
]

where V (Values) are sorted floats defining the position of each RGBA. R (Red), G (Green), B (Blue) and A (Alpha) are integer values between [0, 255].

property workspace: Workspace | None

Workspace object

geoh5py.data.data module

class geoh5py.data.data.Data(association: DataAssociationEnum = DataAssociationEnum.OBJECT, modifiable: bool = True, visible: bool = False, values: Any | None = None, **kwargs)[source]

Bases: Entity

Base class for Data entities.

Parameters:
  • association – Relationship made between the parent object and values.

  • modifiable – Entity can be modified.

  • visible – Entity is visible. Only a single data can be visible at a time.

  • values – Data values.

property association: DataAssociationEnum

Relationship made between the values() and elements of the parent object.

copy(parent=None, *, clear_cache: bool = False, mask: ndarray | None = None, **kwargs) Data[source]

Function to copy data to a different parent entity.

Parameters:
  • parent – Target parent to copy the entity under. Copied to current parent if None.

  • clear_cache – Clear array attributes after copy.

  • mask – Array of bool defining the values to keep.

  • kwargs – Additional keyword arguments to pass to the copy constructor.

Return entity:

Registered Entity to the workspace.

copy_from_extent(extent: ndarray, parent=None, *, clear_cache: bool = False, inverse: bool = False, **kwargs) Entity | None[source]

Function to copy data based on a bounding box extent.

Parameters:
  • extent – Bounding box extent requested for the input entity, as supplied for mask_by_extent().

  • parent – Target parent to copy the entity under. Copied to current parent if None.

  • clear_cache – Clear array attributes after copy.

  • inverse – Keep the inverse (clip) of the extent selection.

  • kwargs – Additional keyword arguments to pass to the copy constructor.

Return entity:

Registered Entity to the workspace.

classmethod default_type_uid() UUID | None[source]

Abstract method to return the default type uid for the class.

property entity_type

Type of data.

property formatted_values

The data with the right format for Geoscience ANALYST.

mask_by_extent(extent: ndarray, inverse: bool = False) ndarray | None[source]

Sub-class extension of mask_by_extent().

Uses the parent object’s vertices or centroids coordinates.

Parameters:
  • extent – Array or coordinate defining the lower and upper bounds of the extent.

  • inverse – Keep the inverse (clip) of the extent selection.

property modifiable: bool

Entity can be modified within ANALYST.

property n_values: int | None

Number of expected data values based on association

property nan_value: None

Value used to represent missing data in python.

abstract classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

static validate_association(value: str | DataAssociationEnum)[source]
validate_entity_type(entity_type: DataType | None) DataType[source]

Validate the entity type.

Parameters:

entity_type – Entity type to validate.

abstract validate_values(values: Any | None) Any[source]

Validate the values.

To be deprecated along with the standalone Drillhole class in future version.

Parameters:

values – Values to validate.

property values

Data values

property visible: bool

Whether the data is visible in camera (checked in ANALYST object tree).

geoh5py.data.data_association_enum module

class geoh5py.data.data_association_enum.DataAssociationEnum(value)[source]

Bases: Enum

Known data association between values and the parent object. Available options:

CELL = 2
DEPTH = 6
FACE = 4
GROUP = 5
OBJECT = 1
UNKNOWN = 0
VERTEX = 3

geoh5py.data.data_type module

class geoh5py.data.data_type.DataType(workspace: Workspace, *, primitive_type: type[Data] | PrimitiveTypeEnum | str = PrimitiveTypeEnum.INVALID, color_map: ColorMap | None = None, duplicate_on_copy: bool = False, duplicate_type_on_copy: bool = False, hidden: bool = False, mapping: ColorMapping = 'equal_area', number_of_bins: int | None = None, precision: int = 2, scale: str | None = None, scientific_notation: bool = False, transparent_no_data: bool = True, units: str | None = None, **kwargs)[source]

Bases: EntityType

DataType class.

Controls all the attributes of the data type for displays in Geoscience ANALYST.

Parameters:
  • workspace – An active Workspace.

  • primitive_type – The primitive type of the data.

  • color_map – The colormap used for plotting.

  • duplicate_on_copy – Force a copy on copy of the data entity.

  • duplicate_type_on_copy – Force a copy on copy of the data entity.

  • hidden – If the data are hidden or not.

  • mapping – The type of color stretching to plot the colormap.

  • number_of_bins – The number of bins used by the histogram.

  • precision – The decimals precision of the data to display.

  • scale – The type of scale of the data.

  • scientific_notation – If the data should be displayed in scientific notation.

  • transparent_no_data – If the no data values are displayed as transparent or not.

  • units – The type of the units of the data.

  • kwargs – Additional keyword arguments to set as attributes (see shared.entity_type.EntityType).

property color_map: ColorMap | None

The Colormap used for plotting

The colormap can be set from a dictionary of sorted values with corresponding RGBA color. Or from a numpy array containing the RGBA values.

color_map = {
    val_1: [r_1, g_1, b_1, a_1],
    ...,
    val_i: [r_i, g_i, b_i, a_i]
}

It can be set to None if non-existing.

property dtype: type

The data type of the data.

property duplicate_on_copy: bool

If the data type should be duplicated on copy.

property duplicate_type_on_copy: bool

If the data type should be duplicated on copy.

classmethod find_or_create_type(workspace: Workspace, primitive_type: PrimitiveTypeEnum | str, dynamic_implementation_id: str | UUID | None = None, uid: UUID | None = None, **kwargs) DataType[source]

Get the data type for geometric data.

Parameters:
  • workspace – An active Workspace class

  • primitive_type – The primitive type of the data.

  • uid – The unique identifier of the entity type.

  • kwargs – The attributes of the entity type.

Returns:

EntityType

property hidden: bool

If the data are hidden or not.

property mapping: str

The type of color stretching to plot the colormap. It chan be one of the following: ‘linear’, ‘equal_area’, ‘logarithmic’, ‘cdf’, ‘missing’

property number_of_bins: int | None

The number of bins used by the histogram. It can be None if no histogram is used.

property precision: int

The decimals precision of the data to display.

property primitive_type: PrimitiveTypeEnum

The primitive type of the data.

static primitive_type_from_values(values: ndarray | None) PrimitiveTypeEnum[source]

Validate the primitive type of the data.

Parameters:

values – The values to validate.

Returns:

The equivalent primitive type of the data.

property scale: str | None

The type of scale of the data.

property scientific_notation: bool

If the data should be displayed in scientific notation.

property transparent_no_data: bool

If the no data values are displayed as transparent or not.

property units: str | None

The type of the units of the data.

static validate_primitive_type(primitive_type: PrimitiveTypeEnum | str | type[Data]) PrimitiveTypeEnum[source]

Validate the primitive type of the data.

Parameters:

primitive_type – Some reference to the primitive type of the data.

Returns:

A known primitive type.

class geoh5py.data.data_type.GeometricDataValueMapType(workspace: Workspace, *, value_map: dict[int, str] | tuple | ReferenceValueMap | None = None, parent: ObjectBase | None = None, description: str = 'Dynamic referenced data', primitive_type: PrimitiveTypeEnum | str = PrimitiveTypeEnum.GEOMETRIC, **kwargs)[source]

Bases: ReferenceDataType, GeometricDynamicDataType

Data container for value map

get_parent_reference(parent: ObjectBase)[source]

Recover the parent ReferencedData by name.

property referenced_data: ReferencedData | None

Reference data type holding the value map.

static validate_keys(value_map: ReferenceValueMap)[source]

Validate the keys of the value map.

validate_value_map(value_map: dict[int, str] | ndarray | tuple | ReferenceValueMap) ReferenceValueMap | None[source]

Validate the attribute of ReferencedDataType

property value_map: ReferenceValueMap | None

Reference value to map index with description.

The value_map can be set from a dictionary of sorted integer values with text description.

value_map = {
    val_1: str_1,
    ...,
    val_i: str_i
}
class geoh5py.data.data_type.GeometricDataXType(workspace: Workspace, uid: UUID | None = None, **kwargs)[source]

Bases: GeometricDynamicDataType

Data container for X values

class geoh5py.data.data_type.GeometricDataYType(workspace: Workspace, uid: UUID | None = None, **kwargs)[source]

Bases: GeometricDynamicDataType

Data container for Y values

class geoh5py.data.data_type.GeometricDataZType(workspace: Workspace, uid: UUID | None = None, **kwargs)[source]

Bases: GeometricDynamicDataType

Data container for Z values

class geoh5py.data.data_type.GeometricDynamicDataType(workspace: Workspace, uid: UUID | None = None, **kwargs)[source]

Bases: DataType, ABC

Data container for dynamic geometric data.

classmethod default_type_uid() UUID | None[source]

Default uuid for the entity type.

property dynamic_implementation_id: UUID

The dynamic implementation id.

class geoh5py.data.data_type.ReferenceDataType(workspace: Workspace, value_map: dict[int, str] | np.ndarray | tuple | ReferenceValueMap = ((0, 'Unknown'),), **kwargs)[source]

Bases: DataType

DataType class.

Controls all the attributes of reference data.

Parameters:

value_map – Reference value to map index with description.

abstract static validate_keys(value_map: ReferenceValueMap) ReferenceValueMap[source]

Validate the keys of the value map.

validate_value_map(value_map: dict[int, str] | ndarray | tuple | ReferenceValueMap) ReferenceValueMap | None[source]

Validate the attribute of ReferencedDataType

property value_map: ReferenceValueMap | None

Reference value map for to map index with description.

The value_map can be set from a dictionary of sorted values int values with text description.

value_map = {
    val_1: str_1,
    ...,
    val_i: str_i
}
class geoh5py.data.data_type.ReferencedBooleanType(workspace: Workspace, value_map: dict[int, str] | np.ndarray | tuple | ReferenceValueMap = array([(0, b'False'), (1, b'True')], dtype=[('Key', '<u4'), ('Value', 'O')]), **kwargs)[source]

Bases: ReferenceDataType

Data container for referenced boolean data.

static validate_keys(value_map: ReferenceValueMap)[source]

Validate the keys of the value map.

class geoh5py.data.data_type.ReferencedValueMapType(workspace: Workspace, **kwargs)[source]

Bases: ReferenceDataType

Data container for referenced value map.

static validate_keys(value_map: ReferenceValueMap)[source]

Validate the keys of the value map.

geoh5py.data.data_unit module

class geoh5py.data.data_unit.DataUnit(unit_name: str | None = None)[source]

Bases: object

Data unit

property name: str | None

geoh5py.data.datetime_data module

class geoh5py.data.datetime_data.DatetimeData(association: DataAssociationEnum = DataAssociationEnum.OBJECT, modifiable: bool = True, visible: bool = False, values: Any | None = None, **kwargs)[source]

Bases: TextData

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

geoh5py.data.filename_data module

class geoh5py.data.filename_data.FilenameData(values: str | None = None, file_bytes: bytes | None = None, name='GeoImageMesh_Image', public: bool = False, **kwargs)[source]

Bases: Data

Class for storing files as data blob.

Parameters:
  • values – Name of the file.

  • file_bytes – Binary representation of the file.

property file_bytes

Binary blob value representation of a file.

property file_name

Binary blob value representation of a file.

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

save_file(path: str | Path = PosixPath('.'), name=None)[source]

Save the file to disk.

Parameters:
  • path – Directory to save the file to.

  • name – Name given to the file.

validate_values(values: Any | None) Any[source]

Validate the values.

To be deprecated along with the standalone Drillhole class in future version.

Parameters:

values – Values to validate.

geoh5py.data.float_data module

class geoh5py.data.float_data.FloatData(association: DataAssociationEnum = DataAssociationEnum.OBJECT, modifiable: bool = True, visible: bool = False, values: Any | None = None, **kwargs)[source]

Bases: NumericData

Data container for floats values

format_type(values: ndarray) ndarray[source]

Check if the type of values is valid and coerse to type float64. :param values: numpy array to modify. :return: the formatted values.

property formatted_values

The data with the right format for Geoscience ANALYST.

property nan_value

Nan-Data-Value

property ndv: float

No-Data-Value

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

geoh5py.data.geometric_data module

class geoh5py.data.geometric_data.GeometricDataConstants(allow_move=False, visible=False, allow_delete=False, allow_rename=False, **kwargs)[source]

Bases: Data

Base class for geometric data constants.

Parameters:
  • allow_move – Defaults coordinate to remain on object.

  • visible – Defaults to not visible.

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

validate_values(values: None) None[source]

Validate values for GeometricDataConstants.

geoh5py.data.integer_data module

class geoh5py.data.integer_data.IntegerData(association: DataAssociationEnum = DataAssociationEnum.OBJECT, modifiable: bool = True, visible: bool = False, values: Any | None = None, **kwargs)[source]

Bases: NumericData

format_type(values: ndarray) ndarray[source]

Check if the type of values is valid and coerse to type int32. :param values: numpy array to modify. :return: the formatted values.

property formatted_values

The data with the right format for Geoscience ANALYST.

property nan_value

Nan-Data-Value

property ndv: int

No-Data-Value

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

geoh5py.data.numeric_data module

class geoh5py.data.numeric_data.NumericData(association: DataAssociationEnum = DataAssociationEnum.OBJECT, modifiable: bool = True, visible: bool = False, values: Any | None = None, **kwargs)[source]

Bases: Data, ABC

Data container for floats values

format_length(values: ndarray) ndarray[source]

Check for possible mismatch between the length of values :param values: the values to check. :return: the values with the right length.

abstract format_type(values: ndarray) ndarray[source]

Check if the type of values is valid and convert it to right dtype. :param values: numpy array to modify. :return: the formatted values.

abstract property ndv

No-data-value

property ndv_values: ndarray | None

Data with nan replaced by ndv

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

validate_values(values: ndarray | None) ndarray[source]

Check for possible mismatch between the length of values stored and the expected number of cells or vertices.

Parameters:

values – Array of values to check

Returns:

values: An array of float values of length n_values or None

geoh5py.data.primitive_type_enum module

class geoh5py.data.primitive_type_enum.DataTypeEnum(value)[source]

Bases: Enum

An enumeration.

BLOB = <class 'bytes'>
BOOLEAN = <class 'bool'>
DATETIME = <class 'str'>
FILENAME = <class 'pathlib.Path'>
FLOAT = <class 'numpy.float32'>
GEOMETRIC = <class 'NoneType'>
INTEGER = <class 'numpy.int32'>
INVALID = <class 'NoneType'>
MULTI_TEXT = <class 'str'>
REFERENCED = <class 'numpy.uint32'>
TEXT = <class 'str'>
VECTOR = <class 'NoneType'>
classmethod from_primitive_type(primitive_type: PrimitiveTypeEnum) type[source]

Get the data type from the primitive type.

Parameters:

primitive_type – The primitive type.

Returns:

The data type.

class geoh5py.data.primitive_type_enum.PrimitiveTypeEnum(value)[source]

Bases: Enum

Known data type.

Available options:

BLOB = 6
BOOLEAN = 11
DATETIME = 8
FILENAME = 5
FLOAT = 2
GEOMETRIC = 9
INTEGER = 1
INVALID = 0
MULTI_TEXT = 10
REFERENCED = 4
TEXT = 3
VECTOR = 7

geoh5py.data.reference_value_map module

class geoh5py.data.reference_value_map.ReferenceValueMap(value_map: dict[int, str] | ndarray | tuple, name: str = 'Value map')[source]

Bases: ABC

Maps from reference index to reference value of ReferencedData.

MAP_DTYPE = dtype([('Key', '<u4'), ('Value', 'O')])
property map: ndarray

A reference array mapping values to strings. The keys are positive integers, and the values description. The key ‘0’ is always ‘Unknown’.

map_values(values: ndarray) ndarray[source]

Map the values to the reference values.

Parameters:

values – The values to map.

Returns:

The mapped values.

classmethod validate_value_map(value_map: ndarray | dict) ndarray[source]

Verify that the key and value are valid. It raises errors if there is an issue

Parameters:

value_map – Array of key, value pairs.

geoh5py.data.referenced_data module

class geoh5py.data.referenced_data.ReferencedData(**kwargs)[source]

Bases: IntegerData

Reference data described by indices and associated strings.

add_data_map(name: str, data: ndarray | dict)[source]

Add a data map to the value map.

Parameters:
  • name – The name of the data map.

  • data – The data map to add.

property data_maps: dict[str, GeometricDataConstants] | None

A reference dictionary mapping properties to numpy arrays.

property entity_type: ReferenceDataType

The associated reference data type.

property mapped_values: ndarray

The values mapped from the reference data.

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

remove_data_map(name: str)[source]

Remove a data map from the list of children.

Parameters:

name – The name of the data map to remove.

property value_map: ReferenceValueMap | None

Pointer to the data.data_type.DataType.value_map

geoh5py.data.text_data module

class geoh5py.data.text_data.CommentsData(association: DataAssociationEnum = DataAssociationEnum.OBJECT, modifiable: bool = True, visible: bool = False, values: Any | None = None, **kwargs)[source]

Bases: Data

Comments added to an Object or Group. Stored as a list of dictionaries with the following keys:

comments = [
    {
        "Author": "username",
        "Date": "2020-05-21T10:12:15",
        "Text": "A text comment."
    },
]
property formatted_values

The data with the right format for Geoscience ANALYST.

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

validate_values(values) dict | None[source]

Validate the values.

To be deprecated along with the standalone Drillhole class in future version.

Parameters:

values – Values to validate.

class geoh5py.data.text_data.MultiTextData(association: DataAssociationEnum = DataAssociationEnum.OBJECT, modifiable: bool = True, visible: bool = False, values: Any | None = None, **kwargs)[source]

Bases: Data

property formatted_values

The data with the right format for Geoscience ANALYST.

property nan_value

Value used to represent missing data in python.

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

validate_values(values: ndarray | str | None) ndarray | str | None[source]

Validate the values.

To be deprecated along with the standalone Drillhole class in future version.

Parameters:

values – Values to validate.

class geoh5py.data.text_data.TextData(association: DataAssociationEnum = DataAssociationEnum.OBJECT, modifiable: bool = True, visible: bool = False, values: Any | None = None, **kwargs)[source]

Bases: Data

property formatted_values

The data with the right format for Geoscience ANALYST.

property nan_value

Nan-Data-Value to be used in arrays

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

validate_values(values: ndarray | str | None) ndarray | str | None[source]

Validate the values.

To be deprecated along with the standalone Drillhole class in future version.

Parameters:

values – Values to validate.

geoh5py.data.text_data.text_formating(values: None | ndarray | str) ndarray | None[source]

Format text values to utf-8.

Parameters:

values – The values to format.

Returns:

The formatted values.

geoh5py.data.unknown_data module

class geoh5py.data.unknown_data.UnknownData(association: DataAssociationEnum = DataAssociationEnum.OBJECT, modifiable: bool = True, visible: bool = False, values: Any | None = None, **kwargs)[source]

Bases: Data

classmethod primitive_type() PrimitiveTypeEnum[source]

Abstract method to return the primitive type of the class.

validate_values(values: Any | None) Any[source]

Validate values for UnknownData.

geoh5py.data.visual_parameters module

class geoh5py.data.visual_parameters.VisualParameters(association: DataAssociationEnum = DataAssociationEnum.OBJECT, modifiable: bool = True, visible: bool = False, values: Any | None = None, **kwargs)[source]

Bases: TextData

property colour: None | list

Colour of the object in [Red, Green, Blue] format.

Each value is an integer between 0 and 255. The colour value is stored as a single integer converted from a byte string of the form ‘RRGGBB’ where ‘BB’ is the blue value, ‘GG’ is the green value, ‘RR’ is the red converted from hexadecimal format.

get_tag(tag: str) None | Element[source]

Recover the tag element.

Parameters:

tag – The name of the tag.

Returns:

The xml element.

set_tag(tag: str, value: str)[source]

Set the value for the tag.

Parameters:
  • tag – The name of the tag.

  • value – the value to set.

property values: str | None

Data values

property xml: Element

str XML string.

Module contents