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.
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.
Convert the geometry to a MultiIndex using the c-index as the base.
to_pyvista()Convert a RegularGeometry to an encoded integer index
to_summary_json()Convert the geometry to a JSON string.
Attributes
Return (azimuth, dip, plunge) corresponding to axis_u, axis_v, axis_w.
axis_uaxis_vaxis_wbounding_boxCompute the zero-based C-order (tabular) index for the dense grid.
Return the x coordinates of the centroids.
Return the y coordinates of the centroids.
Return the z coordinates of the centroids.
extentsis_regularis_rotatedCheck if the geometry is rotated.
is_sparseIndicates whether the geometry is sparse.
num_blocksshapesrssummarycornerblock_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:
- 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:
- classmethod from_json(json_str)[source]
Deserialize a JSON string to a full geometry object.
- Return type:
- 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