parq_blockmodel.geometry.RegularGeometry

class parq_blockmodel.geometry.RegularGeometry(corner, block_size, shape=<property object>, axis_u=(1, 0, 0), axis_v=(0, 1, 0), axis_w=(0, 0, 1), srs=None)[source]

Regular geometry data class.

__init__(corner, block_size, shape=<property object>, axis_u=(1, 0, 0), axis_v=(0, 1, 0), axis_w=(0, 0, 1), srs=None)

Methods

__init__(corner, block_size[, shape, ...])

centroid_i([dtype])

Return the unique i (axis u) indices of the centroids.

centroid_j([dtype])

Return the unique j (axis v) indices of the centroids.

centroid_k([dtype])

Return the unique k (axis w) indices of the centroids.

from_centroids(centroids)

Create a RegularGeometry from centroids.

from_extents(extents, block_size[, axis_u, ...])

Create a RegularGeometry from extents.

from_json(json_str)

Deserialize a JSON string to a full geometry object.

from_multi_index(index[, axis_azimuth, ...])

Create a RegularGeometry or SparseRegularGeometry instance from a pandas MultiIndex.

from_parquet(filepath[, axis_azimuth, ...])

is_compatible(other)

Check if the geometry is compatible with another RegularGeometry.

nearest_centroid_lookup(x, y, z)

Find the nearest centroid for provided x, y, z points.

to_dataframe()

Convert a RegularGeometry to a DataFrame using the cached centroids.

to_ijk_multi_index([dtype])

Convert the geometry to a MultiIndex with (i, j, k) indices using the c-index.

to_json()

Convert the full geometry to a JSON string.

to_json_file(json_filepath)

Write the Geometry to a JSON file.

to_multi_index()

Convert the geometry to a MultiIndex using the c-index as the base.

to_pyvista()

to_spatial_index()

Convert a RegularGeometry to an encoded integer index

to_summary_json()

Convert the geometry to a JSON string.

Attributes

axis_angles

Return (azimuth, dip, plunge) corresponding to axis_u, axis_v, axis_w.

axis_u

axis_v

axis_w

bounding_box

c_index

Compute the zero-based C-order (tabular) index for the dense grid.

centroid_x

Return the x coordinates of the centroids.

centroid_y

Return the y coordinates of the centroids.

centroid_z

Return the z coordinates of the centroids.

extents

is_regular

is_rotated

Check if the geometry is rotated.

is_sparse

Indicates whether the geometry is sparse.

num_blocks

shape

srs

summary

corner

block_size

property axis_angles

Return (azimuth, dip, plunge) corresponding to axis_u, axis_v, axis_w.

property c_index: ndarray

Compute the zero-based C-order (tabular) index for the dense grid. :returns: A 1D array of C-order indices. :rtype: np.ndarray

centroid_i(dtype='int32')[source]

Return the unique i (axis u) indices of the centroids.

Return type:

ndarray

centroid_j(dtype='int32')[source]

Return the unique j (axis v) indices of the centroids.

Return type:

ndarray

centroid_k(dtype='int32')[source]

Return the unique k (axis w) indices of the centroids.

Return type:

ndarray

property centroid_x: ndarray

Return the x coordinates of the centroids.

property centroid_y: ndarray

Return the y coordinates of the centroids.

property centroid_z: ndarray

Return the z coordinates of the centroids.

classmethod from_centroids(centroids)[source]

Create a RegularGeometry from centroids.

Typically, this is used to create a RegularGeometry from a (3, N) array of centroids, where each row corresponds to x, y, z coordinates of the centroids, perhaps from a pyvista grid or similar.

Parameters:

centroids (np.ndarray) – A (3, N) array of centroids.

Returns:

The created RegularGeometry object.

Return type:

RegularGeometry

classmethod from_extents(extents, block_size, axis_u=(1, 0, 0), axis_v=(0, 1, 0), axis_w=(0, 0, 1))[source]

Create a RegularGeometry from extents.

Return type:

RegularGeometry

classmethod from_json(json_str)[source]

Deserialize a JSON string to a full geometry object.

Return type:

RegularGeometry

classmethod from_multi_index(index, axis_azimuth=0.0, axis_dip=0.0, axis_plunge=0.0, srs=None)[source]

Create a RegularGeometry or SparseRegularGeometry instance from a pandas MultiIndex.

Parameters:
  • index (pd.MultiIndex) – A MultiIndex containing the levels ‘x’, ‘y’, and ‘z’.

  • axis_azimuth (float) – The azimuth angle in degrees for rotation. Defaults to 0.0.

  • axis_dip (float) – The dip angle in degrees for rotation. Defaults to 0.0.

  • axis_plunge (float) – The plunge angle in degrees for rotation. Defaults to 0.0.

  • srs (Optional[str]) – The spatial reference system (e.g., EPSG code). Defaults to None.

Returns:

An instance of RegularGeometry or SparseRegularGeometry.

Return type:

Union[RegularGeometry, SparseRegularGeometry]

is_compatible(other)[source]

Check if the geometry is compatible with another RegularGeometry.

Parameters:

other (RegularGeometry) – The other RegularGeometry to check compatibility with.

Returns:

True if the geometries are compatible, False otherwise.

Return type:

bool

nearest_centroid_lookup(x, y, z)[source]

Find the nearest centroid for provided x, y, z points.

Parameters:
  • x (float) – X coordinate.

  • y (float) – Y coordinate.

  • z (float) – Z coordinate.

Returns:

The coordinates of the nearest centroid.

Return type:

Point3

to_dataframe()[source]

Convert a RegularGeometry to a DataFrame using the cached centroids.

Returns:

The DataFrame representing the blockmodel element geometry.

Return type:

pd.DataFrame

to_ijk_multi_index(dtype=<class 'numpy.int32'>)[source]

Convert the geometry to a MultiIndex with (i, j, k) indices using the c-index.

Return type:

MultiIndex

to_json()[source]

Convert the full geometry to a JSON string.

Return type:

str

to_multi_index()[source]

Convert the geometry to a MultiIndex using the c-index as the base.

Return type:

MultiIndex

to_spatial_index()[source]

Convert a RegularGeometry to an encoded integer index

The integer index is encoded to preserve the spatial position.

Use the coordinate_hashing.hashed_index_to_multiindex function to convert it back to x, y, z pd.MultiIndex

Returns:

Return type:

Index