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 |
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. |
|
| 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
proj = Project() # Connect to default project
# Create empty block model
xd = 5.0 # x - axis block size
yd = 5.0 # y - axis block size
zd = 5.0 # z - axis block size
nx = 2 # number of blocks in x axis
ny = 2 # number of blocks in y axis
nz = 2 # number of blocks in z axis
bm = DenseBlockModel(x_res=xd,y_res=yd,z_res=zd,x_count=nx,y_count=ny,z_count=nz)
# Create model variables
grade = np.array([1.2, 1.5, 6.5, 4.3, 7.3, 8.7, 4.2, 5.5], dtype = np.float32)
bm.save_block_attribute('grade',grade)
weath = np.array(['ox','ox','ox','tr','tr','fr','fr','fr'])
bm.save_block_attribute('weath',weath)
# Display model parameters
print('Number of blocks : {}'.format(bm.block_count))
print('Visiblility : {}'.format(bm.block_visibility))
print('Centroids : {}'.format(bm.block_centroids))
print('Colours : {}'.format(bm.block_colours))
print('Attributes : {}'.format(bm.block_attributes.names))
# Save model
save_as = "/blockmodels/dense_model"
if bm:
#Add bm as object
proj.add_object(save_as, bm, overwrite=True)
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, DenseBlockModel
proj = 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
proj.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
proj = Project() # Connect to default project
# Locate ObjectID of block model
bm_id = proj.find_object("/scrapbook/shawmodel")
if bm_id:
# Convert to DenseBlockModel
bm = DenseBlockModel(bm_id)
print('Block attributes : {}'.format(bm.block_attributes.names))
else:
print("Could not find block model in project")
# 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
proj = Project() # Connect to default project
# Hide blocks with attribute "au" < 5
with proj.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
proj = Project() # Connect to default project
au_price = 1320
cu_price = 3.02
with proj.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