+2
Completed

Creating zero-depth downhole survey records

anonymous 9 years ago in Scripting updated by anonymous 9 years ago 7
Sometimes users ask whether Micromine requires downhole survey files to have a record at 0m depth, and a record at the end of hole depth...


You don’t need a survey record at the end of the hole.


If you have no surveys at zero depth then MM will assume the hole direction is vertically down. Micromine only projects downwards, so it needs a zero depth measurement. You can copy the first existing survey and paste it into the survey file as a zero-depth measurement.


(And if you have no survey records for a drillhole that you consider straight then you can specify an azimuth and inclination via the collar. Those angles are optional fields for collar file usage.)


Here's a Python script that creates zero-depth downhole survey records (by copying the first known record for that hole and giving it zero depth). Use the script as follows:

1. Save the script (e.g. into your current project directory)
2. Use the menu option Scripting | Open Script Editor to open the script
3. Modify lines 13 to 17 to match your Survey file (That is assumed to be in current project directory)

4. Make sure that the Survey file is closed.

5. Run the script (a shortcut for that is CTRL+F5)
6. To see the changes, view the Script Output window pane and/or “ZeroDepthRepairFile.DAT”
7. Check that the changes to the survey file are correct, to be sure.


Create_zero_depth_survey_points.py

Also, here's a script for creating Missing Intervals in a downhole interval file. Use it as follows:


1. Save the script (for example into your current project directory)

2. Use the menu option Scripting | Open Script Editor to open the script

3. Modify lines 19 to 24 to match your Interval file (That is assumed to be in current project directory)

4. Make sure that the Interval file is closed.

5. Run the script (a shortcut for that is CTRL+F5)

6. To see the changes, view the Script Output window pane and/or “MissingIntervalsRepairFile.DAT”

7. Check that the changes to the Interval file are correct, to be sure.


Create missing-intervals.py <= (this is outdated, use the one below)

Thanks for these scripts. Work a treat. It'd be nice though with the create-missing-intervals script if it could check max depth in the collar file and create an interval to end of hole.


I'll play around and see what happens.

+1

Basic Example

I thought this would be helpful for others learning like me. I took the code posted by the moderators for inserting missing intervals and used it as a guide to write a really simple script that makes basic calculations in a .dat file. I don't know if there are others out there like me but I need to start really basic and work my way up. I was really excited about Python scripting in MicroMine and thought instantly of calculations between columns in .dat files. The below code shows a beginner how to do this.

A few improvements on this code would are:

-Applying a filter, so only perform calculations where a condition is true, or doing different calculations for different conditions, currently working on this for extra credit,

-And having a resulting calculation populate a newly created column, I couldn't figure this out.


I used the table below saved in the root of the project and named it "IntervalFile.dat"


HOLE

FROM

TO

Interval

A

20

30

10.0

A

30

40

10.0

A

40

50

10.0

B

0

5

5.0

B

5

20

15.0

B

20

30

10.0

B

75

100

25.0

C

0

10

10.0

C

10

75

65.0

Paste into script editor, I couldn't figure out how to insert a file.

IntervalFile = "IntervalFile.DAT"
CurrentProject = MMpy.Project() #Makes a variable that points to the current project
CurrentProjectPath = CurrentProject.path() #Gets the path of the current project
IntervalFile = CurrentProjectPath + IntervalFile #Assumes the file is in the project directory

#Establishes file that is being worked with
MyFile = MMpy.File() #Make a variable to point to the Interval file
MyFile.open(IntervalFile) #'Opens' file, makes it 'active'

#Counts number of records not counting head row, row 0
record_count = MyFile.records_count
print('The file contains', record_count, 'records.')
print( )

#Tells you what the numeric field ID of a column of interest is
	#Resulting field ID will later be used as a parameter
FieldName = "HOLE"
Field_Id = MyFile.get_field_id(FieldName)
print('The Field ID for', FieldName, 'is', Field_Id)
FieldName = "FROM"
Field_Id = MyFile.get_field_id(FieldName)
print('The Field ID for', FieldName, 'is', Field_Id)
FieldName = "TO"
Field_Id = MyFile.get_field_id(FieldName)
print('The Field ID for', FieldName, 'is', Field_Id)
print( )

#Field Calculation Example
for record in range(1, record_count+1): #Not clear why for loop goes to records +1 but only works with +1
	From = MyFile.get_num_field_value(1,record)
	print('From: ',From)
	To = MyFile.get_num_field_value(2,record)
	print('To: ',To)
	Interval = To-From
	MyFile.set_field_value(3,record,Interval)
	print(To, "-", From, "=", Interval)
print('Complete')
#By not indenting I am no longer under the influence of the for loop

Hey Geoff,


Your script looks nice, but here are some advice and tips:


  1. Be sure to always close an MMpy.File that you opened (in your case MMpy.File.close()). By not closing the file, it might stay lock and read only for the next time you try to open it.
  2. MMpy.Project.path() is a static function. This means that you don't need to create a MMpy.Project object (in your case CurrentProject) to call this function; you can just call MMpy.Project.path() and you will get the path.
  3. The loop goes to records+1 because of the range function. Looking at the definition of the function here, it tells us that the sequence created always include the first argument and exclude the last one. For example range(1,10) will create {1,2,3,4,5,6,7,8,9} ( you can try print(range(1,10)) do see the result). Usually, loops always start at index 0. In the case of the records, we wanted to be able to map the index of a record in the editor to the index used in python. This is why the range starts at 1.

To add or change fields in a file, use the menu functionality File | New and File | Modify File.