4. Block Model

4.1. Block Model

In-progress Block Model Class with some functionalities.

param dx:

dimension in x-direction column

type dx:

str

param dy:

dimension in y-direction column

type dy:

str

param dz:

dimension in z-direction column

type dz:

str

resourcegeo.blockmodel.blockmodel.BlockModel.report(self, vars, density_col, mined_out=None, classif_code=None, otype_code=None, mass_col='mass', below_cutoff=False)

Calculate resource report from a block model. User must ensure dx, dy, and dz units meet density_col units. Values < cutoff are trimmed out.

Parameters:
  • vars (dict/list) – If dictionary is given, keys: grade variables column names. If list is given, items are column names in df

  • density_col (str) – density column

  • mined_out (dict,optional) – Key(str): column name of the mined out values. Value(list[str or float]): Codes

  • classif_code (dict,optional) – Key(str): column name for classification values Value(list[str or float]): Codes

  • otype_code (dict,optional) – Key(str): column name of the ore type values Value(list[str or float]): Codes

  • mass_col (str,optional) – column name was mass to be considered in the output

Returns:

Resource reporting

Examples:

import resourcegeo as rs
bm  = rs.BaseData('bm').data
model = rs.BlockModel(bm,dx='dx',dy='dy',dz='dz')

grades = {'grade1':{'cutoff':10}}
mined_out = {'mined':[['mined'], ['mined','unmined']]}
otype_code = {'otype':[['Oxide'],['Sulfide']]}
classif = {'classification':[[1,2]]}

model.report(vars=grades,density_col='density',mined_out=mined_out,
                        classif_code=classif, otype_code=otype_code)

Return type:

self.summary(pd.DataFrame)

4.2. Flattening

resourcegeo.blockmodel.flatten.project_points(points, bm, keys, xcol, ycol, zcol, projected_axis, offset=0)

Flatten 3D coordinates by re-assigning coordinates of one axis towards a major plane (e.g. XY). It uses a dictionary to map the flattened coordinates. All keys must be in points keys.

Parameters:
  • points (pd.DataFrame) – DataFrame containing columns columns for x,y and z

  • bm (np.array) – array containing multiple xyz coordinates

  • keys (dict) – Obtained from project_model. Keys: pair of coordinates, Values: minimum coordinate at the projected axis

  • xcol (str) – x-coordinate column in points

  • ycol (str) – y-coordinate column in points

  • zcol (str) – z-coordinate column in points

  • projected_axis (str) – Projection happens perpendicular to this axis to the minimum direction. x, y or z

  • offset (float) – additional delta added after projection

resourcegeo.blockmodel.flatten.project_model(grid, xcol, ycol, zcol, projected_axis, offset=0, minimum=True)

Flatten a block model by projecting coordinates of one axis (x,y or z) towards a major plane (e.g. XY) in direction of the minimum coordinates. The result is a block model flat in a face perpendicular to the direction of projection.

Parameters:
  • grid (pd.DataFrame) – Grid Model

  • xcol (str) – x-coordinate column in the grid

  • ycol (str) – y-coordinate column in the grid

  • zcol (str) – z-coordinate column in the grid

  • projected_axis (str) – Projection happens perpendicular to this axis to the minimum direction. Valids are x, y or z

  • offset (float) – additional delta added after projection

  • min (bool) – Projects to the direction of minimum (if True) or maximum coordinates (if False)

Returns:

Block Model with flattened coordinates

Return type:

model(pd.DataFrame)

resourcegeo.blockmodel.flatten.upscale_bm(df, grid_in, grid_out, x, y, z, var)

Upscale a block model. It imposes coarse block indexes to df coordinates -> xin yin zin = 1. It potentially give (1,0,1) if using external coarse blocks outside of df coordinates

Parameters:
  • df (pd.DataFrame) –

  • grid_in (gs.GridDef) – Fine Grid Definition

  • grid_out (gs.GridDef) – Coarse Grid Definition

  • x (str) – x-coordinate column in df

  • y (str) – y-coordinate column in df

  • z (str) – z-coordinate column in df

  • var (str) – variable column to average up in df

Returns:

Upscaled model to grid_out.

Return type:

upscaled (pd.DataFrame)

resourcegeo.blockmodel.flatten.gslib2coord(df, var, griddef)

Convert a gslib model into xyz coordinates model. Unlike gslib addcoord, it is vectorized.

Parameters:
  • df (gs.DataFile) – GSLIB model

  • var (str) – variable in df

  • griddef (gs.GridDef) – grid definition

resourcegeo.blockmodel.flatten.coord2gslib(df, x, y, z, griddef)

Convert an XYZ model into GSLIB model

Parameters:
  • df (pd.DataFrame) –

  • x (str) – x-coordinate column in df

  • y (str) – y-coordinate column in df

  • z (str) – z-coordinate column in df

  • griddef (gs.GridDef) – Grid definition

Returns:

GSLIB model where indexes

align with GSLIB griddefinition

Return type:

gslib_model (pd.DataFrame)