Table of Contents
A drillhole set has three components:
- drillhole or blasthole files: a PCF, an assay or composite file (called the interval file), and possibly a survey file.
- a method of naming the drillholes or blastholes.
- a method of defining the drillhole or blasthole geometry.
All three of the above components must be specified when defining a drillhole set.
A drillhole set is analogous to a drillhole view in MineSight®.
Methods are provided for defining (opening) a drillhole set (See Opening a Drillhole Set) and for querying each of its attributes, and reading and writing data to the drillhole files (See Manipulating Drillhole Data).
Relevant functions:
- opendhset
- opentypicaldhset
- duplicateiddhcount
- totaldhcount
- totaldhlist
There are six ways a drillhole name can be defined and five methods for defining the set geometry (see ID Naming Methods and Geometry Definitions below). The allowed file-ID-geometry configurations are summarized below (see Set Configurations).
Sets are defined (opened) using one of two functions: opendhset or opentypicaldhset.
opendhset is the more flexible function allowing a set to be defined using any possible configuration. For most sets (eg, just an assay and survey file with the usual drillhole naming), this function is cumbersome. opentypicaldhset will define a set using the usual configuration based on the chosen interval and survey file. It is much, much easier to open your drillhole set using opentypicaldhset.
Both ways of opening a drillhole set produce a DHSet object.
opendhset
The opendhset function is the most generalized way to define a drillhole set. Each of the above three components (files, ID, geometry) is specified as an argument of opendhset.
If opendhset cannot define a set using the information an exception is set.
Arguments to opendhset:
argument type description PCF path string path (relative or absolute) to the PCF interval file string file name of the assay or composite file survey file string file name of the survey file or None if not used ID type int constant specifying naming method ID items list item names (strings) used for naming geometry type int constant specifying geometry method geometry items list item names (strings) used for defining the set geometry
Each set requires a PCF path and at least an interval file and possibly a survey file. Enter the interval and survey file names, not their paths. The interval and survey file must exist in the same directory as the PCF. See Set Configurations for required files.
The drillhole name or ID can come from items in the survey file or items in the interval file. Below are the six methods for defining the drillhole naming method.
constant items dh.idSURVEY None (use empty item list) dh.idSURVEY_ALPHA1 alpha survey file item dh.idSURVEY_ALPHA2 first then second alpha survey file items dh.idREF alpha or integer composite file item dh.idDHID1 first sixbit composite file item dh.idDHID2 first then second sixbit composite file items
You may or may not choose to have interval geometry computed for loaded drillholes in your set.
If you choose to compute the geometry, the XYZ locations of the interval start and end points are computed for each loaded drillhole. Note that some methods are only available for blasthole sets. Also, all the geometry items must be float items, not alpha. The XYZ location is computed using one of several methods:
constant description dh.geomNONE No geometry dh.geomSURVEY Geometry is computed using the surveys defined in the survey file. This is the usual method for defining geometry from drillhole (as opposed to blasthole) sets. dh.geomSTART_END Use items in the composite file to define the starting and ending interval locations dh.geomEND_BENCH Use items in the blasthole composite file to define the end of a blasthole and use the bench height to compute the top of the blasthole. This is the usual method for determining geometry for a blasthole set. dh.geomEND_LENGTH Use items in the blasthole composite file to define the end of a blasthole and a length item to determine the top of the blasthole.
The geometry type and corresponding geometry item list must be one of the following. The order of the items is important. If no items are required, use an empty list ([]) as the argument.
constant items dh.geomNONE None (use empty item list) dh.geomSURVEY None (use empty item list) dh.geomSTART_END The interval starting easting, northing, and elevation items followed by the interval ending easting, northing, and elevation items. dh.geomEND_BENCH The interval ending easting, northing, and elevation items. dh.geomEND_LENGTH The interval ending easting, northing, and elevation items followed by the interval length item.
The following is a list of available configurations for each file combination. Each line represents an allowed configuration. Note that dh.geomNONE can always be substituted for the geometry method regardless of the file combination or chosen ID naming method. Note the configurations are ordered by drillhole and blasthole groups.
Drillhole assay and survey files
ID Naming Method Geometry Method dh.idSURVEY dh.geomSURVEY dh.idSURVEY_ALPHA1 dh.geomSURVEY dh.idSURVEY_ALPHA2 dh.geomSURVEY Drillhole composite and survey files
ID Naming Method Geometry Method dh.idSURVEY dh.geomSURVEY dh.idSURVEY dh.geomSTART_END dh.idSURVEY_ALPHA1 dh.geomSURVEY dh.idSURVEY_ALPHA1 dh.geomSTART_END dh.idSURVEY_ALPHA2 dh.geomSURVEY dh.idSURVEY_ALPHA2 dh.geomSTART_END Drillhole composite file only
ID Naming Method Geometry Method dh.idREF dh.geomSTART_END dh.idDHID1 dh.geomSTART_END dh.idDHID2 dh.geomSTART_END Blasthole composite and survey files
ID Naming Method Geometry Method dh.idSURVEY dh.geomSTART_END dh.idSURVEY dh.geomEND_BENCH dh.idSURVEY dh.geomEND_LENGTH Blasthole composite file only
ID Naming Method Geometry Method dh.idREF dh.geomSTART_END dh.idREF dh.geomEND_BENCH dh.idREF dh.geomEND_LENGTH dh.idDHID1 dh.geomSTART_END dh.idDHID1 dh.geomEND_BENCH dh.idDHID1 dh.geomEND_LENGTH dh.idDHID2 dh.geomSTART_END dh.idDHID2 dh.geomEND_BENCH dh.idDHID2 dh.geomEND_LENGTH
Examples:
Open a stand-alone drillhole composite file using REF# for the drillhole ID and composite file items to determine the interval starting and ending points.
geom = ['XTOP', 'YTOP', 'ZTOP', 'XBOT', 'YBOT', 'ZBOT']
drillhole_set = dh.opendhset(
'd:\\cow\\comp10.dat', 'comp09.dat', None,
dh.idREF, ['REF#'], dh.idSTART_END, geom)
Open a blasthole composite and survey file using the shot names in the survey file. Don't bother with geometry
bhset = dh.opendhset('mbhs10.dat', 'mbhs09.dat', 'mbhs12.dat',
dh.idSURVEY, [], dh.geomNONE, [])
opentypicaldhset
Use opentypicaldhset to define the usual drillhole set configurations. These are the configurations to use if your drillhole files were built using the default options in MS-Compass. The arguments to opentypicaldhset are:
argument type description PCF path string path (relative or absolute) to the PCF interval file string file name of the assay or composite file survey file string file name of the survey file. CANNOT be None.
For a drillhole assay or composite file plus a survey file, opentypicaldhset is equivalent to
opendhset(pcfpath, intervalFile, surveyFile, dh.idSURVEY,
[], dh.geomSURVEY, [])
For a blasthole composite plus survey file, opentypicaldhset is equivalent to
opendhset(pcfpath, intervalFile, surveyFile, dh.idSURVEY,
[], dh.geomEND_BENCH,
['EAST', 'NORTH', 'ELEV.'])
If the set could not be defined using the typical configuration corresponding to the file combination as specified in the argument list, NULL will be returned and an error raised. The set will then need to be constructed using opendhset.
As in MineSight®, drillhole names must be unique. It is possible using some of the more exotic drillhole naming mechanisms (especially dh.idREF) that duplicate IDs can be generated. After opening the drillhole set, use duplicateiddhcount to count the number of drillholes that were not included in the set because they had non-unique IDs.
Drillhole data is accessed via its drillhole name. Use totaldhlist to generate a list of drillhole names in the set.
The functions found with the DHSet object can be grouped into five broad categories: Loading Drillholes, Accessing Drillhole Data, Storing Drillhole Data, Accessing Item Parameters, and Miscellaneous functions.
In general, after a drillhole set is opened, some or all of the drillholes are 'loaded' at which point their data can be accessed, manipulated, and stored using the functions described in this section.
Drillhole data is accessed on an individual drillhole basis. Functions that operate on individual drillholes begin with the letters 'dh' and always take the drillhole name (string) and the first argument. Use totaldhlist to generate a list of all the drillholes in the set.
Relevant functions:
- dhload
- dhloaded
- loadalldhs
- loaddhsbyextent
- dhunload
- unloadalldhs
- dhbytes
- intervalloaditems
Drillhole data is available to the set from two places:
- the survey file (if any)
- the interval file
If a survey file is specified as part of the set and used to define the geometry (ie, dh.geomSURVEY was the Geometry type), then the survey coordinates for each drillhole are always available in the drillhole set. If when the survey file was initialized (eg, in MS-Compass), additional survey items were specified, then these additional survey items are also available in the drillhole set. You cannot access, nor should you need to access, the default survey items (eg, LOC09, DLAB1) via the drillhole set.
To conserve memory, data from the interval file (item data and interval coordinates) is not stored in the drillhole set until a drillhole is 'loaded'. With sufficient memory, all drillhole data can be loaded. Or you can choose to load a subset of the drillholes or a subset of the available item data.
Use dhbytes to determine the bytes required to load an individual drillhole.
If you want to limit the items for which interval data is retrieved, use intervalloaditems before loading the drillholes. By default, item values are available for all items except those used to define the drillhole ID for ID types dh.idDHID1 and dh.idDHID2 (ie, special composite file sixbit items).
Although almost all item values are loadable, items used to define the drillhole ID or geometry, plus several specially named items, are not storable. See Accessing Item Parameters for determining the storable items.
Drillholes can be loaded individually (dhload), by the location of their survey (loaddhsbyextent), or en masse (loadalldhs).
dhloaded returns dh.TRUE if a dh is loaded.
All the drillholes can be unloaded using unloadalldhs or individual drillholes can be unloaded using dhunload.
Relevant functions:
- dhsurveydataat
- dhsurveycoordsat
- dhsurveycount
- dhsurveysetfloatdataat
- dhsurveysetalphadataat
- dhintervaldataat
- dhintervalcoordsat
- dhintervalcount
- dhintervalsetfloatdataat
- dhintervalsetalphadataat
- badintervaldhcount
- dhbadintervalcount
- dhbadintervalat
All drillhole data access functions operate on a single drillhole and thus a drillhole name is required in the argument list. Functions that retrieve coordinate data operate on a single survey or interval and require the survey or interval index (offset from one). Functions that retrieve item data also operate on a single survey or interval and additionally require the item name in the argument list.
Values for items used to define the drillhole ID or geometry can be retrieved and modified, but cannot be stored back to the drillhole files. This means that the drillhole names and geometry cannot be modified either in the drillhole set or in the drillhole files. See Accessing Item Parameters for more details.
Coordinates are retrieved as python float values. Item values that are missing have values equivalent to dh.MISSING.
Data is retrieved as either a python float or a python string depending on the item's data type.
Float and string values can be set for survey and interval item data. The setalphadataat functions automatically convert strings to exactly four characters (how they are stored in and retrieved from the files) by truncating or padding with blanks as necessary. You can set float item values to missing using dh.MISSING. Alpha values are never missing.
If a drillhole has multiple surveys, each survey has the same data as the collar survey. You can modify the non-collar survey data but when the data is stored back to the file, only collar data will be stored.
Note that the values in the drillhole set are not permanently stored in the data files until the drillhole is explicitly stored using dhstore or storealldhs.
When a drillhole is loaded, it is possible that its geometry is badly specified. For example, say the item EAST was used to define the interval's easting, but the value for EAST was missing. In this case the interval coordinates cannot be computed and are set to dh.MISSING. Such drillholes should not be used in operations that require well-specified geometry.
Use badintervaldhcount to see if any drillholes have bad geometry.
Individual intervals in a specific drillhole can be checked for bad geometry by using dhbadintervalcount or dhbadintervalat.
Relevant functions:
- dhstore
- storealldhs
It's a good idea to backup your files before storing data, especially if you are debugging a script.
Data for all drillholes can be stored using storealldhs or data for an individual drillhole can be stored via dhstore. If the drillhole is not loaded, then only survey data (if any) will be stored.
Relevant functions:
- surveyitemcount
- surveyitemlist
- surveystorableitemlist
- intervalitemcount
- intervalitemlist
- intervalloadeditemcount
- intervalloadeditemlist
- intervalstorableitemlist
- surveyitemstorable
- surveyitemmin
- surveyitemmax
- surveyitemmaxstorable
- surveyitemprecision
- surveyitemalpha
- intervalitemstorable
- intervalitemmin
- intervalitemmax
- intervalitemmaxstorable
- intervalitemprecision
- intervalitemalpha
There are differences between the way survey and interval items are handled in the drillhole set. These differences cause some peculiarities in the way the item parameter functions work.
First, if the set has a survey file and the survey file has additional items (eg, you defined items in addition to the default items when the file was initialized in MS-Compass), then values for the additional items are accessible from the drillhole set regardless of the drillhole's load state. The default survey file items are not accessible; you cannot get data for them or query their parameters in any way.
So surveyitemlist returns a list of the additional survey file items.
In contrast, intervalitemlist returns a list of all interval file items.
Secondly, you can limit the interval items for which data is retrieved. Thus interval items can be loaded or not, whereas additional survey items are always loaded. Use intervalloadeditemlist to see which interval items are loaded.
Note that all interval file items can be loaded except any special sixbit items used to define the drillhole ID with ID types dh.idDHID1 or dh.idDHID2. These special items cannot be loaded.
Since all additional survey file items are always loaded, there is no corresponding function to return a list of the loaded survey file items.
Common to both survey and interval items is storability. Although all items (except the special sixbit items noted above) can be retrieved and modified, not all items can be stored back to the survey and interval files.
Any item used to define the drillhole ID or geometry cannot be stored back to the file. Additionally, any items with the following names are also not storable:
- REF#
- FROM
- -TO-
- -AI-
- EAST
- NORTH
- DHTOE
- ELEV.
- BHS#
- ELVBH
- LNGTH
This means that you cannot edit the drillhole name or geometry in the drillhole file. Neither will modifying ID or geometry items in the set have an affect on drillhole's name or geometry in the set. The drillhole name and geometry are computed directly from the values in the file.
Functions to query the item parameters (like the item's minimum value) work the same for both survey and interval items. All functions take a string containing the item name as the argument.
surveyitemstorable and intervalitemstorable:
Returns dh.TRUE if this is a storable item. Note that for an interval item, the item must be loaded in order to be storable.surveyitemalpha and intervalitemalpha:
Returns dh.TRUE if this is an alpha item. Otherwise the item is a float.surveyitemmin and intervalitemmin:
Returns the minimum value for the item. If you try to store a float value less than the item minimum, dh.MISSING will be stored in the file.surveyitemmax and intervalitemmax:
Returns the value requested as the item maximum when the file was initialized.surveyitemmaxstorable and intervalitemmaxstorable:
Returns the maximum storable value for this item which, because of the item packing algorithm, is usually slightly larger than the maximum initialized value. Stored float values will be limited by the maximum storable value for the item.surveyitemprecision and intervalitemprecision:
The precision of the item.
Relevant functions:
- epsilon
- setepsilon
- bh
- intervaltype
- idtype
- geometrytype
- iditemlist
- geometryitemlist
- intervalfile
- surveyfile
- survey
Each set carries an epsilon value. By default epsilon is 0.1. Epsilon is used internally in the drillhole set functions to determine if drillhole (not blasthole) surveys and intervals are contiguous. If the starting point of a survey or interval is within epsilon of the previous survey or interval's end point, then the end point coordinates are set exactly equal to the start point coordinates of the subsequent survey or interval.
Also, if using the dh.geomEND_BENCH geometry type, end points within epsilon of a bench are assumed to be on that bench.
The epsilon value can be retrieved using the epsilon function or the value can be set using the setepsilon function.
Function bh will return dh.TRUE for a blasthole set.
Function intervaltype returns the type of interval file, either 9 or 11.
Function idtype returns the constant specifying the ID naming method and function iditemlist returns a list of the items used to name the drillholes.
Function geometrytype returns the constant specifying the geometry definition method and function geometryitemlist returns a list of the items used to define the geometry.
intervalfile and surveyfile return the path to the interval and survey file used by the set. surveyfile will return an empty string if the set does not have a survey file.
function survey returns dh.TRUE if this set has a survey file.
Defining a DHSet object
Define a drillhole set. See details above under Opening a Drillhole Set.
Arguments:
- pcf : string
- path (relative or absolute) to the pcf.
- intvFile: string
- interval file name.
- survFile : string
- survey file name.
- idType : int
- dh naming method. See Constants
- idList : list of strings
- items used in the dh naming method.
- geomType : int
- geometry definition method. See Constants
- geomList : list of strings
- items used to define dh geometry.
Returns a DHSet object.
Define a drillhole set. See details above under Opening a Drillhole Set.
Arguments:
- pcf : string
- path (relative or absolute) to the pcf.
- intvFile: string
- interval file name.
- survFile : string
- survey file name.
Returns a DHSet object.
MineSight® drillhole and blasthole data is accessed in Python via a drillhole set object (DHSet). See details under Opening a Drillhole Set and Manipulating Drillhole Data.
Check if the specified interval has bad coordinates.
Arguments:
- dh : string
- drillhole name
- intv : int
- interval (from 1 to dhintervalcount)
Returns dh.TRUE or dh.FALSE
Determine the number of intervals in this dh having bad geometry coordinates.
Arguments:
- dh : string
- drillhole name
Returns (int) the number of intervals with bad geometry coordinates.
Determine the estimated number of bytes required to load a drillhole.
Arguments:
- dh : string
- drillhole name
Returns (int) estimated bytes required to load dh.
Returns the starting xyz and ending xyz coordinates for one interval in a loaded dh.
Arguments:
- dh : string
- drillhole name
- intv : int
- interval (from 1 to dhintervalcount)
Returns (list of floats) start and end interval coordinates of loaded dh.
Determine the number of intervals in a loaded dh.
Arguments:
- dh : string
- drillhole name
Returns (int) the number of intervals in a loaded dh.
Returns the data for the specified interval and item.
The data is either a float or a string depending on the item.
Arguments:
- dh : string
- drillhole name
- intv : int
- interval (from 1 to dhintervalcount)
- item : string
- item
Returns (float or string) item data for an interval.
Set an alpha value for the specified interval and item.
The string will be converted to exactly 4 char.
Arguments:
- dh : string
- drillhole name
- intv : int
- interval (from 1 to dhintervalcount)
- item : string
- item
- val : string
- the alpha value to set
Set a float value for the specified interval and item.
Arguments:
- dh : string
- drillhole name
- intv : int
- interval (from 1 to dhintervalcount)
- item : string
- item
- val : float
- the float value to set
Loads a dh.
If the dh is loaded, it will be unloaded then loaded. This function only affects interval data.
Arguments:
- dh : string
- drillhole name
Check if a drillhole is loaded.
Arguments:
- dh : string
- drillhole name
Returns dh.TRUE if the dh is loaded.
Stores interval and survey (if any) data for a dh.
Arguments:
- dh : string
- drillhole name
Returns the starting xyz and ending xyz coordinates for one survey in a dh.
Arguments:
- dh : string
- drillhole name
- survey : int
- survey (from 1 to dhsurveycount)
Returns (list of floats) start and end survey coordinates of a dh.
Determine the number of surveys in a dh.
Arguments:
- dh : string
- drillhole name
Returns (int) the number of surveys in a dh.
Returns the data for the specified survey and item.
The data is either a float or a string depending on the item.
Arguments:
- dh : string
- drillhole name
- survey : int
- survey (from 1 to dhsurveycount)
- item : string
- item
Returns (float or string) item data for an survey.
Reloads survey data for a dh.
Arguments:
- dh : string
- drillhole name
Set an alpha value for the specified survey and item.
The string will be converted to exactly 4 char.
Arguments:
- dh : string
- drillhole name
- survey : int
- survey (from 1 to dhsurveycount)
- item : string
- item
- val : string
- the alpha value to set
Set a float value for the specified survey and item.
Arguments:
- dh : string
- drillhole name
- survey : int
- survey (from 1 to dhsurveycount)
- item : string
- item
- val : float
- the float value to set
Unloads a dh
Arguments:
- dh : string
- drillhole name
Check if this interval item is alpha.
Arguments:
- item : string
- item
Returns dh.TRUE if this is an interval alpha item.
Determine the maximum initialized value for this interval item.
Arguments:
- item : string
- item
Returns (float) the max value for the specified interval item or dh.ITEM_MAX for alpha and fullword items.
Determine the maximum storable value for this interval item. In general, the maximum storable value is slightly larger than the initialized value.
Arguments:
- item : string
- item
Returns (float) the max value for the specified interval item or dh.ITEM_MAX for alpha and fullword items.
Determine the minimum value for this interval item.
Arguments:
- item : string
- item
Returns (float) the min value for the specified interval item or dh.ITEM_MIN for alpha and fullword items.
intervalitemprecision(item)
Arguments:
- item : string
- item
Returns (float) the precision for the specified interval item.
Check if an interval item is storable.
Note that only loaded items are storable.
Arguments:
- item : string
- item
Returns dh.TRUE is a specified interval item is storable.
Resets the loaded interval items to include all file items.
Loaded drillholes will be unloaded and loaded. If drillhole values have changed in the set, store the drillholes before resetting the items or the changes will be lost.
Resets the loaded interval items to the items in the list.
Loaded drillholes will be unloaded and loaded. If drillhole values have changed in the set, store the drillholes before resetting the items or the changes will be lost.
Arguments:
- list : list of strings
- item names
Loads all the dhs with surveys intersecting a given cube.
The dhset survey type must be dh.geomSURVEY.
Arguments:
- collaronly : integer
- dh.TRUE will only check if the survey collar intersects the cube.
- xmin : double
- cube xmin
- xmax : double
- cube xmax
- ymin : double
- cube ymin
- ymax : double
- cube ymax
- zmin : double
- cube zmin
- zmax : double
- cube zmax
Set the epsilon value for the set.
Arguments:
epsilon : float
Check if a survey item is alpha.
Arguments:
- item : string
- item
Returns dh.TRUE if this is an alpha item
This function is provided for symmetry. All survey items are alpha or fullword and thus have maximum value dh.ITEM_MAX.
Arguments:
- item : string
- item
Returns dh.ITEM_MAX
This function is provided for symmetry. All survey items are alpha or fullword and thus have maximum value dh.ITEM_MAX.
Arguments:
- item : string
- item
Returns dh.ITEM_MAX
This function is provided for symmetry. All survey items are alpha or fullword and thus have minimum value dh.ITEM_MIN.
Arguments:
- item : string
- item
Returns dh.ITEM_MIN
surveyitemprecision(item)
Arguments:
- item : string
- item
Returns (float) the precision for the specified survey item.
surveyitemstorable(item)
Arguments:
- item : string
- item
Returns dh.TRUE if the specified survey item is storable.
The following two examples should help provide details on accessing the drillholes via Python scripts.
The following example will loop over all drillhole data and perform the following calculation,
EQCU = TOTCU + 10 * MOLY
It assumes that we have a drillhole project called "SAMP".
The following example illustrates how you can save memory during drillhole access. Instead of loading intervals containing all the available items, we will just load intervals containing the items of interest. We will perform the same calculation shown in the Simple Drillhole Access above.
In addition, we will use the generalized open function discussed in Open Drillhole Sets (Generalized).
True/False constants
FALSE TRUE
Defines 0 for False and 1 for True.
Constant for missing data
MISSING
Constants for defining drillhole IDs
idCOUNT idDHID1 idDHID2 idREF idSURVEY idSURVEY_ALPHA1 idSURVEY_ALPHA2 idUNKNOWN
Constants for defining drillhole Geometry
geomCOUNT geomEND_BENCH geomEND_LENGTH geomNONE geomSTART_END geomSURVEY geomUNKNOWN
Constants for item range
ITEM_MAX ITEM_MIN