Table of Contents
This library provides a set of functions for making working with the reserves dictionary easier (see grail.ip.reserves).
Throughout this module there is a reference to the Reserves Dictionary. The dictionary is returned when working with the grail.ip.reserves module. Specifically it is the dictionary returned by the following two function calls,
hres = reserves.hGetCurResRef()
dres = reserves.dGetRes(hres)
When working with the Reserves Dictionary, in your typical IP script you should also make a call to ordergrades as in,
hres = reserves.hGetCurResRef()
dres = reserves.dGetRes(hres)
reslib.ordergrades(dres)
that ensures the control grade is set and the grade lists between different cuts and areas match in their respective binning within the Reserves Dictionary.
Some of the get functions within reslib return reference to the contents of the Reserves Dictionary. What does this mean? This means that if you modify a reference to a Dictionary or List retrieved by a get function, you are in fact modifying the Reserves Dictionary directly. However, if your get function only returns a string, real, or integer value, then do not need to worry about references.
Sometimes modifying the Reserves Dictionary directly is useful and efficient; however, sometimes it will lead to unintentional side-effects. An example of an unintentional side-effect is the illustrated below,
When you request the unordered grade list via getgradelist, you get a reference to the grade list within the Reserves Dictionary. When your print the grade list at (1) you will see an unordered grade list. After you order the Reserves Dictionary grade list with ordergrades, you will have an ordered grade list. The new ordered grade list in the Reserves Dictionary is the same grade list as the one you referenced with getgradelist. This means that your Unordered_Grade_List in (2) will now be ordered.
If your intention was to get a copy and not a reference to the grade list, then you should use Python's copy module [1]. The above code snippet could be re-written as,
Now your Unordered_Grade_List at step (2) will be the same as the copy of the grade list you got with your call to getgradelist. This is because the Unordered_Grade_List is not a reference to the Reserves Dictionary internal grade list, but a new list onto itself.
In practice, if you intend to quickly read data from the Reserves Dictionary, you do not need to worry about the reference mechanics. If you intend to read and do work with the results, then you need to worry about references with Python's List and Dictionary objects returned by the reslib get functions. If you intend to read/write to the reserves dictionary, then you will need to continue to operate with the same reference to a Python List or Dictionary object. If your get function returns an string, real or integer, then you do not need to worry about references.
The functions defined in reslib can be broken down into the following broad categories,
Functions that are useful for all purpose reserves work with the Reserves Dictionary.
Functions that work with the attributes defined within the Reserves Dictionary.
Functions used to work with the Areas within a Reserves Dictionary.
Functions used to work with the cutoff bins within the Reserves Dictionary. When you divide a grade into a set of cutoff, the range between cutoffs is considered a bin.
Simple functions that perform simple calculations based on the contents of the Reserves Dictionary.
Functions dedicated to working with the cuts within the Reserves Dictionary.
Functions dedicated to working with the grades within the Reserves Dictionary.
Functions dedicated to working with the materials within the Reserves Dictionary.
Functions that work with material sets within the Reserves Dictionary.
Functions relating to the Open Database Connectivity interface with MineSight® Interactive Planner.
Functions relating to pathing information with the active Interactive Planner object.
Functions that are useful for all purpose reserves work with the Reserves Dictionary.
New in version 4.70
Scans through dRes and returns a list of cut dictionaries for all the cuts, except the current cut.
New in version 4.70
Returns the current cut within the dRes. If there is no current cut it will return -1.
New in version 4.70
Returns True if there is a current cut. This is the same as checking that get_current_cut_idx does not return -1.
Returns the controlling grade, if an area index is not specified it is assumed that there is only one area.
Note
The results of this function call are undefined if reslib.ordergrades has not be called prior to calling this function.
Returns 0 if the metric, 1 if imperial. The value is based on the value of the flag stored within the Interactive Plan database only, not the units used for you MineSight® 3D project.
The grail.ms3d.project module provides details about the MineSight® 3D project and its units.
Sets control grade and ensures grade lists are in proper order. In a typical IP script, this will be your third function call,
Default file writing logger.
Will append a messages, msg, to the the file, fname, or if desired, another filename. Default file name is scripterr.txt.
Returns a one if custom attribute exists otherwise returns none. Takes a cut and the custom attribute name as an argument.
Takes a cut and the custom attributeName as an argument.
Returns custom attribute value if it exists in the given cut. The attrname is case sensitive. The cut should be a cut dictionary as retrieved from dRes. For example, to print all custom attribute for all cuts given dRes you would do the following,
Functions used to work with the cutoff bins within the Reserves Dictionary. When you divide a grade into a set of cutoff, the range between cutoffs is considered a bin.
Returns the number of bins for a materialindex. The areaindex will default to 0.
Note
That this only works if your IP plan only has one material set.
Returns the number of bins within the Reserves Dictionary, dRes, for the areaindex. The areaindex defaults to 0.
Note
That this only works if your IP plan only has one material set.
Simple functions that perform simple calculations based on the contents of the Reserves Dictionary.
New in version 4.70
Returns the segment id for the given cut. This ID can be used with the plan ID to look back into the MSPD. A currently active, new cut, will not have a segement id until that cut is saved to the MSPD.
New in version 4.70
Returns the field "Geom Info" field for a given cut. This is also known as "geometry creation info", or "geomcreation".
Return list of grade dictionaries, which includes name, and accumulation flag. See also Using reslib Get Functions.
Note
You are working with a reference to the grade list within the Reserves Dictionary. If you intend to operate with a entirely new structure use Python's copy module instead [1].
Returns 1 if the accumulation are performed with the special thickness case.
The thickness case is a special case on how to average. In MineSight® Interactive Planner we can sum up our grades in two ways,
- We can do a weighted average based on the specific gravity. For example with copper grades.
- We can do a straight accumulation. For example with dollar values of barrels of oil.
Thickness is the exception to the above to methods. If one wants to the know the average thickness of a the cut, you can not sum and you can not do a weighted average based on the specific gravity. You have to do a weighted average based on how many blocks were considered. In other words, how much area the average considers.
Functions related to the Open Database Connectivity (ODBC) interface.
This returns a string for use with the python odbc module. It can be used to open a connection to a database with a properly defined ODBC name.
As an example, this function will convert the following result of a call to db_odbc_connection_str,
to the following value for use in the python odbc module,
notice, that if there was a username and password you would have gotten the following,
See the warning in db_odbc_obj for issues regarding using the python odbc module directly.
This returns the results of calling the python odbc module with the db_odbc_str function. The odbc Object returned can let you make queries against the underlying database.
where the resulting message window would have something like this,
Warning
Extreme caution should be taken when using this Database connection and issuing SQL statements against the DB. By circumnavigating the standard interfaces you are risking corrupting your data. Furthermore, we can not guarantee that the underlying definitions will remain consistent from release to release.
Returns the connection string used for the current database.
Deprecated alias getODBCconnection since v4.00.
Returns the query used for the currently active view into the database. The active view is defined by open 'plan'. Specifically this returns the contents of the WHERE clause within a SQL SELECT statement. For instance, with the following SQL statement,
this function would return "OBJECTID = 'PLAN23'".
Deprecated alias getODBCquery since v4.00.
Functions used to returning pathing information for a given Interactive Plan. All paths are returned as absolute paths.
Alias: get_model_path starting in 4.60.
Returns the absolute path to the model for the given area index. Default area index is 0. The model path will only have a value if the area type is a AREATYPE_MODEL. See get_area_type for more details.
Alias: get_pcf_path starting in 4.60.
Returns the absolute path to the Project Control File (PCF) for a given area. Default area index is 0.
New in version 4.60.
Returns the either AREATYPE_DH or AREATYPE_MODEL depending on what type of model is used for the underlying area. A AREATYPE_DH corresponds to drillhole data, and the AREATYPE_MODEL corresponds to modeling data. The default area is 0.
New in version 4.60.
Returns the absolute path for the survey file if the area type for area is AREATYPE_DH (drillhole). See get_area_type for more details. If the area is not a drillhole area, this will return a blank string. The default area is 0. Call get_survey_type, to get its file number in the MineSight(r) system.
New in version 4.60.
Returns the absolute path for the assay file if the area type for area is AREATYPE_DH (drillhole). See get_area_type for more details.If the area is not a drillhole area, this will return a blank string. The default area is 0. Call get_survey_type, to get its file number in the MineSight(r) system.
New in version 4.60.
Returns the file number in the MineSight(r) system as an integer for the survey file define for the area. If the area is not a drillhole area, this will return 0. The default area is 0.
New in version 4.60.
Returns the file number in the MineSight(r) system as an integer for the assay file define for the area. If the area is not a drillhole area, this will return 0. The default area is 0.
[1] | (1, 2) "copy -- Shallow and deep copy operations". 21 December 2001. 6 June 2005. <http://www.python.org/doc/2.2/lib/module-copy.html> |