Skip to content

BlockModel

Regular or masked grid of blocks, 2D or 3D, optionally rotated.

bounds property

bounds

(min, max) corners, None without rows.

column_names property

column_names

Names of the attribute columns.

coords property

coords

(n, 3) cell centers in world coordinates.

corners property

corners

(n, 8, 3) world-space corners of each row's box: vertex c (0..8) takes the row's minimum extent on axis a if bit a of c is 0, its maximum if 1.

extents property

extents

(n, 6) sub-block extents as fractions of the parent cell [u0, v0, w0, u1, v1, w1], or None when not sub-blocked.

index property

index

Parent cell index of each row (masked or sub-blocked), or None when regular.

length_unit property

length_unit

Unit of the coordinates, such as m or ft; None when not declared.

units property

units

Units of the attributes that have one; see Table.units.

volumes property

volumes

Volume of each row (area with unit height in 2D).

x property

x

x of each row's coordinates.

y property

y

y of each row's coordinates.

z property

z

z of each row's coordinates.

convert_units method descriptor

convert_units(column, *, to)

New model with column converted to unit to; see Table.convert_units.

discretize method descriptor

discretize(n)

Nodes discretizing every block, e.g. targets for simulate(blocks=).

Parameters:

Name Type Description Default
n int or sequence of int

Nodes per axis inside each block; an int applies to x, y and z, or to x and y only in a 2D model.

required

Returns:

Type Description
BlockModel

A masked grid n times finer, or for a sub-blocked model each sub-block split into n per axis. Its one column, block, is the row in this model of each node.

drop_null

drop_null(*columns)

Rows with a value in every one of columns, all columns by default.

filter method descriptor

filter(mask)

Rows where mask is true; the result is masked.

from_extents staticmethod

from_extents(
    *objects,
    size,
    buffer=Ellipsis,
    rotation=None,
    snap=Ellipsis,
    crs=None,
    length_unit=None,
)

Smallest regular grid holding every object plus a buffer.

Parameters:

Name Type Description Default
*objects (PointSet, Drillholes, Mesh, Polylines, BlockModel or array_like)

What the grid must cover: points, drill hole paths, mesh or line vertices, the corners of another grid, or (n, 2)/(n, 3) coordinates.

required
size sequence of float

(dx, dy, dz) block size. With (dx, dy) or dz=None the grid is 2D: one layer spanning the buffered z range.

required
buffer float or sequence of float

Margin added on each side, one value or one per grid axis.

0.0
rotation tuple of float

Azimuth, dip and rake in degrees; the extents are measured along the rotated grid axes.

None
snap bool, float or sequence of float

Put the origin on a multiple of this step, measured along the grid axes, so grids built from different data line up; True snaps to the block size.

False
crs str
None

Returns:

Type Description
BlockModel

A regular model without attributes, with the fewest blocks along each axis that hold every point.

from_meshes staticmethod

from_meshes(
    origin,
    size,
    count,
    meshes,
    subgrid,
    *,
    rotation=Ellipsis,
    column="domain",
    fill=None,
    crs=None,
    length_unit=None,
)

Sub-blocked model of the grid origin, size, count and rotation from prioritized meshes; see subblock.

grid

grid(column)

column (a name or one value per row) on the full grid as an (nz, ny, nx) array, NaN (None for text) in absent cells; for regular and masked models.

regularize method descriptor

regularize(target, *, min_fraction=0.0)

Columns of this model averaged onto the blocks of target.

Each row of this model counts in a target block by the volume they share, from exact box overlaps, so it works both ways between regular, masked and sub-blocked models: to a coarser grid, sub-blocks to their parents, or a regular estimate onto sub-blocks.

Parameters:

Name Type Description Default
target BlockModel

Blocks to average onto, with the same rotation (the origin and sizes may differ). Its own columns are kept.

required
min_fraction float

Blocks less covered than this are null.

0.0

Returns:

Type Description
BlockModel

target with every column of this model: floats as volume-weighted means of the non-null rows, other columns (text, integers) as the value filling the most volume, ties to the smallest, nulls not voting. fraction is the share of each block covered by this model, so volumes * fraction * grade sums to this model's volumes * grade.

row_at method descriptor

row_at(points)

Row holding each point.

Parameters:

Name Type Description Default
points array_like

(n, 3) or (n, 2) world coordinates.

required

Returns:

Type Description
ndarray

int64 row of each point, -1 outside the model or in a missing block.

sample

sample(points, column)

Value of column (a name or one value per row) at each point; NaN, or None for text, outside the model or in a missing block.

subblock method descriptor

subblock(meshes, subgrid, *, column='domain', fill=None)

Sub-blocks every block by prioritized meshes.

Each block is split on a regular subgrid; each sub-cell takes the label of the first domain holding its center. Blocks of one label stay whole, others keep runs of sub-cells merged along x, then y.

Parameters:

Name Type Description Default
meshes sequence of (Mesh or Polylines, str, str)

(mesh, rule, label) in priority order, the first match winning. rule is "inside" a closed mesh, or "below" or "above" a surface such as topography, along world z; off the surface's footprint neither matches. Polylines take "inside" only: the vertical prism over their features, as Polylines.contains.

required
subgrid int or sequence of int

Sub-cells per axis, which sets the smallest sub-block; an int applies to x, y and z, or to x and y only in a 2D model.

required
column str

Name of the label column.

"domain"
fill str

Label of the sub-cells no domain holds; without it they are dropped.

None

Returns:

Type Description
BlockModel

Sub-blocked model on subgrid with the label column and the columns of each sub-block's parent block.

subblocked staticmethod

subblocked(
    origin,
    size,
    count,
    parent,
    extents,
    *,
    rotation=Ellipsis,
    subgrid=None,
    attributes=None,
    crs=None,
    length_unit=None,
)

Sub-blocked model: parent cell of each sub-block (sorted) and its (n, 6) extent as fractions of that cell; subgrid (e.g. (4, 4, 8)) requires corners on that subdivision.

to_length_unit method descriptor

to_length_unit(unit, *, crs=None)

A copy with the coordinates converted to unit, the new length unit.

Parameters:

Name Type Description Default
unit str

A length unit, such as m or ft.

required
crs str

The CRS of the converted coordinates; required when the coordinates have a CRS, which a change of unit changes.

None

Raises:

Type Description
InvalidInput

Without a length unit to convert from, or with a CRS and no crs.

to_regular method descriptor

to_regular()

Every parent cell, absent cells null. Sub-blocks merge into their parent as in regularize, without the fraction column: floats as volume-weighted means, other columns by volume majority.

to_table method descriptor

to_table()

Attributes preceded by centroid x, y, z.

with_attributes method descriptor

with_attributes(table)

New model with table as the attributes, one row per block.

with_column method descriptor

with_column(name, values, *, unit=None)

New model with the attribute name added or replaced: numbers (NaN is null) or text (None is null). The column takes unit, or else the unit values carries.

with_columns method descriptor

with_columns(data)

New model with the columns of data, a dict or table, added or replaced.

with_units method descriptor

with_units(units)

New model with the units of units, column name to unit; None removes one.

used in