Dense Block Models

A dense block model is a block model where all the blocks are the same size, meaning that block properties store their values with the same level of detail over the entire extent of the model. The use of a dense block model is appropriate if the data the model is supposed to represent has a similar consistent resolution.

DenseBlockModel properties

The following is a list of properties and methods that are specific to DenseBlockModel:

Name Description

block_visibility

Use this property to set the visibility of a DenseBlockModel for a specified slice, row and column. By default, block_visibility_3d is set to True.

block_selection_3d

Use this property to set the selection of a DenseBlockModel for a specified slice, row and column.

Dense block model examples

Creating a dense block model

Certain properties of a block model can't be modified after creation. As such the DenseBlockModel type requires some additional parameters when using Project.new() that aren't required for several other object types.

from mapteksdk.project import Project
from mapteksdk.data import DenseBlockModel
import numpy as np


project = Project()  # Connect to default project


# Create empty block model
row_size = 5.0  # Size of blocks in the row direction.
column_size = 5.0  # Size of blocks in the column direction.
slice_size = 5.0  # Size of blocks in the slice direction.
row_count = 2  # Number of rows.
column_count = 2  # Number of columns.
slice_count = 2  # Number of slices.


with project.new(
    "blockmodels/dense_model",
    DenseBlockModel(
        row_count=row_count,
        col_count=column_count,
        slice_count=slice_count,
        row_res=row_size,
        col_res=column_size,
        slice_res=slice_size,
    ),
) as model:
    grade = np.array([1.2, 1.5, 6.5, 4.3, 7.3, 8.7, 4.2, 5.5], dtype=np.float32)
    weath = np.array(["ox", "ox", "ox", "tr", "tr", "fr", "fr", "fr"])
    model.save_block_attribute("grade", grade)
    model.save_block_attribute("weath", weath)
    # Display model parameters
    print(f"Number of blocks : {model.block_count}")
    print(f"Visiblility : {model.block_visibility}")
    print(f"Centroids : {model.block_centroids}")
    print(f"Colours : {model.block_colours}")
    print(f"Attributes : {model.block_attributes.names}")

Importing a block model from a BMF file

Note:  For the remaining examples on this page, this sample block model will be used. Download here: shawmodel_reg.zip

from mapteksdk.project import Project
from mapteksdk.data import io

project = Project() # Connect to default project

# The file path to the Vulcan block model to import:
bmf_path = "F:/Python SDK Help/data/shawmodel_reg.bmf"
imported = io.import_bmf(bmf_path)
if imported:
    # Assign a path to the object
    project.rename_object(imported, "/scrapbook/shawmodel", overwrite=True)
else:
    print("Could not import the block model")

Listing block model attributes

from mapteksdk.project import Project
from mapteksdk.data import DenseBlockModel
from mapteksdk.operations import object_pick


project = Project()  # Connect to default project


model_oid = object_pick(
    object_types=DenseBlockModel,
    label="Pick a model to list block attributes of."
)
with project.edit(model_oid) as model:
    print(f"Block attributes : {model.block_attributes.names}")


# Output:
# Block attributes :
#   dict_keys(['au', 'batter', 'bench', 'berm', 'blockid',
#   'cu', 'density', 'ebv', 'equivalent', 'lens',
#   'lg_pit', 'material', 'mined', 'ore_cycle', 'ore_distance',
#   'ore_prod_time', 'pit', 'recovery', 'region', 'tonnage', 'total_au_g',
#   'total_cu_tonnes', 'value0', 'value1', 'value2', 'waste_cycle',
#   'waste_production', 'waste_time', 'zones'])

Filtering block visibility by attribute

from mapteksdk.project import Project

project = Project() # Connect to default project

# Hide blocks with attribute "au" < 5
with project.edit("scrapbook/shawmodel") as bm:
    au_filter = bm.block_attributes["au"]
    # Reset current visibility status
    bm.block_visibility[:] = True
    # Hide all blocks below fitler value
    bm.block_visibility[(au_filter < 5)] = False

Calculating a block model

The code below is an example of using NumPy to calculate the entire models values within a single set of statements.

import numpy as np
from mapteksdk.project import Project
project = Project() # Connect to default project

au_price = 1320
cu_price = 3.02

with project.read("/scrapbook/shawmodel") as bm:
    # np.copy() used as the object arrays will be read only
    # due to use of proj.read()
    au = np.copy(bm.block_attributes["au"])
    cu = np.copy(bm.block_attributes["cu"])

    # Set anything with values less than zero to zero (-99 or -9)
    au[au < 0] = 0
    cu[cu < 0] = 0

    # Calculate the new values
    au_oz = au * (1/31.1035)
    cu_lb = cu * 2240

    # Calculate the new equivalent
    au_eq = (au_oz * au_price + cu_lb * cu_price) / au_price

    print('Average au : {:.3f}'.format(au.mean()))
    print('Average cu : {:.3f}'.format(cu.mean()))
    print('Average au_eq : {:.3f}'.format(au_eq.mean()))

# Output:
# Average au : 0.108
# Average cu : 0.062
# Average au_eq : 0.321