Table of Contents
This document discusses the technique for assigning average grades for a given Interactive Planner cut.
It is assumed that you have a working familiarity with,
- the MineSight® Interactive Planner (MS-IP)
- writing Python scripts
Furthermore, it is assumed that you have a Custom Attribute defined that is called "Avg_Grade". The value should be defined as a real. See the MineSight®-Interactive Planner documentation for more information regarding adding custom attributes.
The script we intend to write will walk across all the atomic reserves for a particular cut. The atomic reserves are defined as the smallest addressable piece of information after a cut was made on a resource model. These atomic reserves are broken down based on rock type and grade cut-offs.
Therefore, our average grades for a cut will walk across each of the possible atomic reserves and compute the average grade for all cut-offs and all rock types within a particular cut.
The process of writing the script can be broken down into the following steps,
- Create the script.
- Fill in the logic for computing average grades.
The following sections discuss the steps required to build a script that assigns average grades.
Afterward, we will review the completed script.
In the $(medexe)\scripts\samples directory there exists a ip-boilerplate.py script. This script serves as a quick, ready to use, template, Interactive Planner (IP) script.
We will use the ip-boilerplate.py script as the basis for creating our own script that will assign average grades.
Copy this script to another file, that we will call averagegrade.py.
The next step involves opening the averagegrade.py script in your favorite Python editor, and start editing it to assign average grades for cuts.
The run_script() function is were we will start, and it should look like,
The first order of business is to determine what the control grade is for a given reserve.
Now it is time to compute the average grade for the control grade, lets start off by creating a separate function that takes a given cut and the control grade and computes the average grade for that cut.
The final step is to take the return value for calc_average_grade and add it to our database via the geometry view. If we do this for all cuts, then we would get something like,
At this point we have computed the average control grade for all the cuts within a given IP plan.
Note
That if you have not defined a custom attribute named "Avg_Grade" then this script will work incorrectly.
The complete script will appear as follows,
The script will compute the average control grade for each cut, and store it under the "Avg_Grade" custom attribute for that cut.
Our script also has the added bonus of creating a generic function that we can import into other scripts. We could either add the calc_average_grade() function to our own Interactive Planner utility module, and import it into other scripts, or we could just import our averagegrade script and use the function.