grail.data.torq Module

Version: 16.2

Table of Contents

Overview

This module provides access to drillholes (i.e. sample sites) in a MineSight Torque database.

Warning

This module can only be used with embedded scripts (scripts designed to be run from within MineSight 3-D).

Examples

The following snippet illustrates how to connect to a Torque database, load a drillhole set, retrieve a drillhole, and set the value of a Sample Attribute for all intervals.

sqlserver = "MYCOMP\\SQLEXPRESS"
database = "GRADE_CNTRL"
conn = torq.connect(sqlserver, database)

dhset = torq.openDHSet(conn)

dh = dhset.getDrillholeByName('1200-001-333')
numIntervals = dh.getIntervalCount()
for idx in range(numIntervals):
    
dh.setIntervalDataAt("GC", idx, "TOTALCOPPER", 0.14)

dh.save()               #save changes to the individual drillhole
dhset.saveChanges()     #commit all changes to database

dhset.close()
torq.disconnect(conn)

The following snippet illustrates how to connect to a Torque database and load a filtered drillhole set.

sqlserver = "MYCOMP\\SQLEXPRESS"
database = "GRADE_CNTRL"
conn = torq.connect(sqlserver, database)

#create a compound filter for Names that begin with "2010" and ShotNumber exceeding 40
nameFilter = (torq.filterCategory_STANDARD, "Name", comparisonOp_EQ, "2010*", torq.logicalOp_AND)
customFilter = (torq.filterCategory_CUSTOM, "ShotNumber", torq.comparisonOp_GT, 40, torq.logicalOp_AND)

filterList=[nameFilter, customFilter]
coverageName = "Assays"
dhset = torq.openDHSetFiltered(conn, coverageName, filterList, torq.typeBLASTHOLE)

#do something here

dhset.close()
torq.disconnect(conn)

The following snippet illustrates how to connect to a Torque database and create/save a new Drillhole.

sqlserver = "MYCOMP\\SQLEXPRESS"
database = "GRADE_CNTRL"
conn = torq.connect(sqlserver, database)
dhset = torq.openDHSet(conn, loaddata=False)

#declare parameters for new drillhole
type          = torq.typeBLASTHOLE
coverage      = "Assays"
sampprogram   = "Original"
unit          = "Foot"
bhname        = "DH1"
legacyname    = 1
azimuth       = 348.0
dip           = -90.0
depth         = 39.0
easting       = 12548.0
northing      = 689556.0
elev          = 2950.0

dh = dhset.createDrillhole(type, coverage, sampprogram, unit, bhname, legacyname, azimuth, dip, depth, True)
dh.setCollar([easting,northing,elev])

dh.save()               #save the new drillhole
dhset.saveChanges()     #commit all changes to database

dhset.close()
torq.disconnect(conn)

Functions

connect(sqlserver, database, username=None, password=None)
This function connects to the Torque database and returns a Connection object. Keep a reference to this object as it will be needed to disconnect. The function raises an IOError if a valid license cannot be located, or if there is a connection error.
disconnect(conn)
This function disconnects from the Torque database.
openDHSet(conn, loaddata=True)
This function creates and returns a DHSet object. By default, all drillholes in the project will be loaded. If the loaddata parameter is set to False, then no drillholes will be loaded. The function raises an IOError if the specified database is not a valid Torque database.
openDHSetFiltered(conn, coverageName, filterset, filterType=typeBLASTHOLE)

This function is used to load a filtered subset of drillholes. It creates and returns a DHSet object. The parameter filterset is a list of one or more tuples containing the following five elements:

filterCategory: the filter category. See Constants section.

fieldName: the field or attribute name (String)

comparisonOp: comparison operator. See Constants section.

value: the field/attribute value to compare to.

logicalOp: logical operator used to connect two or more filter sets. See Constants section.

DHSet Class

This class provides the main access point for a Torque project.

DHSet

Use openDHSet or openDHSetFiltered to create a DHSet object.

close()
Closes the DHSet and removes it from memory.
compareVersion(major, minor)
Compares the project version to the version specified by the arguments. Returns 1 if project is greater than the specified version; 0 if project is the same as the specified version; or -1 if the project is less than the specified version.
createDrillhole(type, coverageName, sampleProgramName, unitName, name, legacyName, azimuth, dip, length, overwrite=True)

Creates a new Drillhole with a single interval and returns the Drillhole object. Raises a ValueError if Legacy Name already exists in set.

You must call Drillhole::save() followed by DHSet::saveChanges() in order to permanently store this drillhole in the project.

getAreaEnumValues()
Returns a list containing the enumeration values (Strings) for Area.
getBlastholeTypeEnumValues()
Returns a list containing the enumeration values (Strings) for Blasthole Type.
getCoverages()
Returns a list containing all coverage names in the project.
getCustomFieldNames()
Returns a list containing all Custom Field names in the project. This includes SampleSite custom fields (shared) and custom fields specific to both Drillholes and Blastholes.
getCustomFieldType(customFieldName)
Returns the Custom Field datatype. See Constants section.
getDrillholeAt(index)
Creates and returns a Drillhole object for the drillhole at the specified index.
getDrillholeByName(name)
Creates and returns a Drillhole object for the drillhole with the specified name.
getDrillholeCount()
Returns the number of loaded drillholes in the set.
getDrillholeNames()
Returns a list of names for the drillholes loaded in the set.
getDrillholesInPointList2d(pointlist, endpoints=False)

Returns a list of drillhole names with collars (or toes) inside the 2-dimensional geometry of the pointlist.

Warning

This function is for Sample Sites of type Blasthole only.

Warning

This function considers X and Y coordinates only. To include elevation, test the Bench Toe value (or Collar Z value) of the drillholes returned.

getExistingNames()
Returns a list containing all drillhole names in the project (regardless of the DHSet filters).
getExistingLegacyNames()
Returns a list containing all drillhole legacy names in the project (regardless of the DHSet filters).
getIntervalTypeEnumValues()
Returns a list containing the enumeration values (Strings) for Interval Type.
getSampleAttribNames()
Returns a list containing all Sample Attribute names in the project.
getSampleAttribEnumValues(sampleAttribName)
Returns a list containing the enumeration values (Strings) for the specified Sample Attribute. This function raises a TypeError if the Sample Attribute is not an enumerated type.
getSampleAttribType(sampleAttribName)
Returns the data type of the specified Sample Attribute. See Constants section.
getSamplePrograms()
Returns a list of sample programs.
getVersion()
Returns a tuple containing the major and minor version numbers of the project.
saveChanges()

Deprecated alias: storeAll().

Writes all changes made to drillholes back to the database. Returns the number of holes saved.

Drillhole Class

This class provides the main access point for a single drillhole (i.e. sample site).

Drillhole

Use createDrillhole or getDrillholeAt or getDrillholeByName to create a Drillhole object.

delete()
Removes the Drillhole from the project. Note that you must subsequently call DHSet::saveChanges() to commit the change.
getArea()
Returns the value of the standard field "Area".
getBenchToe()
Returns the value of the standard field "Bench Toe". Raises a TypeError if drillhole is not of type Blasthole.
getBlastholeType()
Returns the value of the standard field "Blasthole Type". Raises a TypeError if drillhole is not of type Blasthole.
getCollar()
Returns the collar location as a list of co-ordinates: [x, y, z].
getComment()
Returns the value of the comment field.
getCoordinateSystem()
Returns the drillhole coordinate system.
getCoverages()
Returns a list containing all coverage names for this drillhole.
getCustomField(customFieldName)
Returns the value of the specified Custom Field.
getCustomFieldNames()
Returns a list containing all Custom Field names for this drillhole.
getCustomFieldType(customFieldName)
Returns the Custom Field datatype. See Constants section.
getDate()
Returns the value of the date field as a string. The format of the date returned depends on the machine's region settings (short date format).
getGeometryType()
Returns the geometry type. See Constants section.
getIntervalCount()
Returns the number of intervals in the drillhole.
getIntervalDataAt(coverageName, interval_idx, sampleAttribName)
Returns the value of the Sample Attribute for the specified interval.
getIntervalFromTo(coverageName, interval_idx)
Returns a (from,to) tuple representing the downhole depth of the start and end of the interval.
getIntervalType()
Returns the Interval Type of the drillhole.
getLegacyName()
Returns the legacy name of the drillhole.
getLength()
Returns the drillhole length.
getMineType()
Returns the value of the standard field "Mine Type". Raises a TypeError if drillhole is not of type Blasthole.
getName()
Returns the drillhole name.
getShotLabel()
Returns the value of the standard field "Shot Label". Raises a TypeError if drillhole is not of type Blasthole.
getSurveyAzimuth(surveyPointIdx)
Returns the azimuth for the survey point index.
getSurveyPointCount()
Returns the number of survey points in the drillhole.
getSurveyDepth(surveyPointIdx)
Returns the depth for the survey point index.
getSurveyDip(surveyPointIdx)
Returns the dip for the survey point index.
getType()
Returns the drillhole type. See Constants section.
getUnit()
Returns the drillhole unit.
save()

Deprecated alias: store().

Saves the new/modified Drillhole to the DHSet. Note that you must subsequently call DHSet::saveChanges() to commit the change.

setArea(value)
Sets the value of the standard field "Area". Raises a ValueError if the value is not an existing Area enumeration.
setBenchToe(value)
Sets the value of the standard field "Bench Toe". Raises a TypeError if drillhole is not of type Blasthole.
setBlastholeType(value)
Sets the Blasthole Type. Raises a ValueError if the value is not an existing Blasthole Type enumeration. Raises a TypeError if drillhole is not of type Blasthole.
setCollar(point)
Sets the value of the drillhole collar.
setComment(value)
Sets the value of the comment field.
setCoordinateSystem(value)
Sets the drillhole coordinate system. Raises a ValueError if the argument is not a valid coordinate system.
setCustomField(customFieldName, value)
Sets the value of the specified Custom Field. If setting a field of datatypeDATE, the date string must follow format "MM/DD/YYYY".
setDate(value)
Sets the Date field. Raises a ValueError if the date string does not follow format "MM/DD/YYYY".
setIntervalDataAt(coverageName, interval_idx, sampleAttribName, value)
Sets the value of the Sample Attribute for the specified interval. If setting a field of datatypeDATE, the date string must follow format "MM/DD/YYYY".
setIntervalType(value)
Sets the Interval Type. Raises a ValueError if the value is not an existing Interval Type enumeration.
setLegacyName(value)
Sets the drillhole legacy name.
setLength(value)
Sets the drillhole length.
setMineType(value)
Sets the value of the standard field "Mine Type". Raises a TypeError if drillhole is not of type Blasthole.
setName(value)
Sets the drillhole name.
setShotLabel(value)
Sets the value of the standard field "Shot Label". Raises a TypeError if drillhole is not of type Blasthole.
setUnit(value)
Sets the drillhole unit. Raises a ValueError if the argument is not a valid unit.
setIntervalFloatDataAt_direct(coverageName, interval_idx, sampleAttribName, value)
Writes the Float value directly to the Sample Attribute. This function can be used to set datatypeSMALLREAL and datatypeLARGEREAL. A call to function saveChanges() is NOT required to apply the change.
setIntervalIntegerDataAt_direct(coverageName, interval_idx, sampleAttribName, value)
Writes the Integer value directly to the Sample Attribute. This function can be used to set datatypeSMALLINTEGER, datatypeSTANDARDINTEGER, and datatypeBOOLEAN. A call to function saveChanges() is NOT required to apply the change.

Constants

Constant for missing data

MISSING

These type constants are used to define the different drillhole types:

typeDRILLHOLE

typeBLASTHOLE

typeOTHER

typeUNDEFINED

These datatype constants are used to define the different data types:

datatypeSTRING

datatypeDATE

datatypeENUM

datatypeSTANDARDINTEGER

datatypeSMALLINTEGER

datatypeLARGEREAL

datatypeSMALLREAL

datatypeBOOLEAN

datatypeUNDEFINED

These geomtype constants are used to define the different drillhole geometry types:

geomtypeBYPOLYLINE

geomtypeBYSURVEYS

geomtypeBYPOINT

geomtypeUNDEFINED

These filterCategory constants are used to define the different filter types:

filterCategory_STANDARD (filter drillholes by standard MSTorque fields)

filterCategory_CUSTOM (filter drillholes by custom field values)

filterCategory_SAMPLE (filter drillholes by sample attribute values)

These comparisonOp constants are used to define the comparison operators used in filter expressions:

comparisonOp_LT (less than)

comparisonOp_LTE (less than or equal to)

comparisonOp_EQ (equal to)

comparisonOp_NEQ (not equal to)

comparisonOp_GTE (greater than or equal to)

comparisonOp_GT (greater than)

comparisonOp_IN

comparisonOp_NOTIN

comparisonOp_ISNULL

comparisonOp_ISNOTNULL

These logicalOp constants are used to define the logical operators used in filter expressions:

logicalOp_AND

logicalOp_OR