MiningMath

MiningMath

Loading...

One of the unavoidable steps for the next generation of Data Science and Artificial Intelligence technologies applied to mining

Imperial System

Estimated reading: 4 minutes 1081 views

For importing databases, MiningMath uses the metric system exclusively. In case your database is in the imperial system, it should be modified to a counterpart in the metric system. This page provides a script and further instructions for you to do this conversion successfully.

For this process, python and pandas packages are required (see installation guidelines below). In case you find any issues using the script, or if you make any modifications to it that could be useful for the community as a whole, please share your discoveries at our Forum

Script download

If you’re already familiar with python scripts, just copy or download this simple python script and run it in your machine. Otherwise, keep scrolling for further instructions.

DOWNLOAD SCRIPT HERE.

				
					import pandas

# define conversion consts
# foot to metter const
ft_to_m = 0.3048
# short tonne to metric tonne const
st_to_t = 0.907184
# ounce to gram const
oz_to_g = 28.34952

# import imperial model
imperial_model = pandas.read_csv("imperial_model.csv")

# create metric model
metric_model = pandas.DataFrame(columns=['X', 'Y', 'Z'])

# set coordinates to metric model (foot to meter)
metric_model['X'] = imperial_model['X'] * ft_to_m
metric_model['Y'] = imperial_model['Y'] * ft_to_m
metric_model['Z'] = imperial_model['Z'] * ft_to_m

# set dimension to metric model (foot to meter)
metric_model['!DIM_X'] = imperial_model['DIM_X'] * ft_to_m
metric_model['!DIM_Y'] = imperial_model['DIM_Y'] * ft_to_m
metric_model['!DIM_Z'] = imperial_model['DIM_Z'] * ft_to_m

# set mass to metric model (short tonne to metric tonne)
metric_model['!MASS'] = imperial_model['MASS'] * st_to_t

# set volume to metric model (cubic metter)
metric_model['!VOLUME'] = metric_model['!DIM_X'] * metric_model['!DIM_Y'] * metric_model['!DIM_Z']

# set density to metric model (metric tonne per cubic metter)
metric_model['%DENSITY'] = metric_model['!MASS'] / metric_model['!VOLUME']

# set grades to metric model (ounces per short tonne to grams per metric tonne or ppm)
metric_model['@GRADE_AU'] = imperial_model['GRADE_AU'] * oz_to_g / st_to_t
metric_model['@GRADE_CU'] = imperial_model['GRADE_CU'] * oz_to_g / st_to_t

# set recovery values to metric model
metric_model['*REC_AU'] = imperial_model['REC_AU']
metric_model['*REC_CU'] = imperial_model['REC_CU']

# set economic values to metric model
metric_model['$PROCESS'] = imperial_model['PROCESS']
metric_model['$WASTE'] = imperial_model['WASTE']

# export metric model to csv
metric_model.to_csv("metric_model.csv", index = False)

				
			

1) Installing Python

  1. Download Python's lastest version at https://www.python.org/downloads/.

    Python download webpage
    Python download webpage
  2. Once the download is complete, open the .exe and follow the instructions for a default installation. Make sure to select "Add Python to Path" before proceeding, as depicted below. 

    Python installation screen
    Python installation screen
  3. At this point, the installation should be concluded. You can check if Python has been correctly installed by running the command python --version at Windows PowerShell. 

    Python version on Windows shell
    Python version on Windows PowerShell

2) Installing Pandas

Pandas is an open source data analysis and manipulation tool, built on top of Python. Follow the steps below to install it:

  1. Open the Windows PowerShell and run the command "pip install pandas".

    Pandas install command
    Pandas install command
  2. Once the installation is complete, you're able to run Pandas inside your Python programs. You can check if Pandas has been correctly installed by running the command "pip show pandas" at Windows PowerShell.

    Pandas version
    Pandas version

3) Converting your database

This script can be used to convert foot to meter; short tonne to metric tonne; and ounce to gram.
It works with the columns: X, Y, Z, DIM_X, DIM_Y, DIM_Z, MASS, VOLUME, DENSITY, GRADE_AU, GRADE_CU, REC_AU, REC_CU, PROCESS, WASTE.

Follow the steps below:

  1. Save your database in a file named imperial_model.csv, at the same folder where your script is located.

  2. Run the command python imperial.py at the Windows PowerShell from the folder where the script is located. The example below shows the script in the Downloads folder.

    Run script example
    Run script example
  3. Open the output file named metric_model.csv, and that's it! Your data has been converted to the metric system. 

    Output file example
    Output file example
Share this Doc

Imperial System

Or copy link

CONTENTS
Chat Icon

Hi, it's Mima here 😇 Ask me any questions!