Grade Tonnage

The “Grade Tonnage” curve is often used to characterise an entire deposit. It is a cumulative view that presents the “mass (tonnes) and head grade” with increasing cut-off grade.

They are useful in comparing deposits.

import pandas as pd
import plotly

from elphick.mass_composition import MassComposition
from elphick.mass_composition.datasets.sample_data import iron_ore_sample_data

import xarray as xr

Create a MassComposition object

We get some demo data in the form of a pandas DataFrame

df_data: pd.DataFrame = iron_ore_sample_data()
name = 'A072391'
df_data.drop(columns=['Na2O', 'CaO', 'MnO', 'TiO2', 'P', 'K2O', 'MgO'], inplace=True)

print(df_data.shape)
df_data.head()
(126, 8)
mass_dry H2O Al2O3 Fe SiO2 DHID interval_from interval_to
index
6 2.12 0.35 1.48 64.30 3.23 CBS02 26.60 26.85
7 2.06 0.23 1.28 64.91 2.90 CBS02 26.85 27.10
9 1.91 0.23 1.01 65.09 2.39 CBS02 27.70 28.00
10 1.96 0.36 0.99 65.03 2.22 CBS02 28.00 28.30
12 2.06 0.40 0.75 65.87 1.69 CBS02 28.60 28.95


obj_mc: MassComposition = MassComposition(df_data, name=name)

Demonstrate the aggregate function

i.e. weight average of the dataset, a.k.a. head grade

print(obj_mc.aggregate())
print(obj_mc.aggregate(as_dataframe=False))

res: xr.Dataset = obj_mc.binned_mass_composition(cutoff_var='Fe', bin_width=1.0, cumulative=True, as_dataframe=False)
res
            mass_wet  mass_dry       H2O     Al2O3         Fe     SiO2
name
A072391  2029.617808  1981.688  2.361519  1.773585  60.443938  2.82721
<xarray.Dataset> Size: 48B
Dimensions:   (index: 1)
Dimensions without coordinates: index
Data variables:
    mass_wet  (index) float64 8B 2.03e+03
    mass_dry  (index) float64 8B 1.982e+03
    H2O       (index) float64 8B 2.362
    Al2O3     (index) float64 8B 1.774
    Fe        (index) float64 8B 60.44
    SiO2      (index) float64 8B 2.827
Attributes:
    mc_name:            Aggregate of A072391
    mc_vars_mass:       ['mass_wet', 'mass_dry']
    mc_vars_chem:       ['Al2O3', 'Fe', 'SiO2']
    mc_vars_attrs:      []
    mc_interval_edges:  {}
/home/runner/work/mass-composition/mass-composition/elphick/mass_composition/mc_xarray.py:157: FutureWarning:

The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.
<xarray.Dataset> Size: 560B
Dimensions:   (Fe_bins: 10)
Coordinates:
  * Fe_bins   (Fe_bins) object 80B (57.0, 58.0] (58.0, 59.0] ... (66.0, 67.0]
Data variables:
    mass_wet  (Fe_bins) float64 80B 2.03e+03 1.966e+03 1.832e+03 ... 23.58 5.575
    mass_dry  (Fe_bins) float64 80B 1.982e+03 1.921e+03 1.791e+03 ... 23.44 5.52
    H2O       (Fe_bins) float64 80B 2.362 2.321 2.27 ... 0.6308 0.5975 0.9911
    Al2O3     (Fe_bins) float64 80B 1.774 1.722 1.665 ... 1.039 0.8941 0.873
    Fe        (Fe_bins) float64 80B 60.44 60.54 60.68 ... 65.17 65.69 66.19
    SiO2      (Fe_bins) float64 80B 2.827 2.778 2.689 2.545 ... 2.304 2.049 2.0
Attributes:
    mc_name:            Aggregate of A072391 with group Fe
    mc_vars_mass:       ['mass_wet', 'mass_dry']
    mc_vars_chem:       ['Al2O3', 'Fe', 'SiO2']
    mc_vars_attrs:      []
    mc_interval_edges:  {}


Tabular Grade bin data

res: pd.DataFrame = obj_mc.binned_mass_composition(cutoff_var='Fe', bin_width=1.0, cumulative=True,
                                                   direction='ascending', as_dataframe=True)
res
/home/runner/work/mass-composition/mass-composition/elphick/mass_composition/mc_xarray.py:157: FutureWarning:

The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.
mass_wet mass_dry H2O Al2O3 Fe SiO2
Fe_bins
(57.0, 58.0] 63.373676 61.080 3.619288 3.398666 57.288222 4.365437
(58.0, 59.0] 197.213295 190.880 3.211394 2.791020 58.217789 4.124492
(59.0, 60.0] 756.382411 732.370 3.174639 2.091473 59.282386 3.308385
(60.0, 61.0] 1549.120855 1509.310 2.569900 1.912236 59.863876 2.975221
(61.0, 62.0] 1839.092713 1793.010 2.505731 1.829265 60.132412 2.872413
(62.0, 63.0] 1935.262623 1887.908 2.446935 1.805108 60.247486 2.853999
(63.0, 64.0] 1978.485263 1930.878 2.406248 1.792921 60.319538 2.840970
(64.0, 65.0] 2006.036920 1958.248 2.382255 1.784113 60.381189 2.836520
(65.0, 66.0] 2024.042550 1976.168 2.365294 1.776101 60.427875 2.829521
(66.0, 67.0] 2029.617808 1981.688 2.361519 1.773585 60.443938 2.827210


res: pd.DataFrame = obj_mc.binned_mass_composition(cutoff_var='Fe', bin_width=1.0, cumulative=True,
                                                   direction='descending', as_dataframe=True)
res
/home/runner/work/mass-composition/mass-composition/elphick/mass_composition/mc_xarray.py:157: FutureWarning:

The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.
mass_wet mass_dry H2O Al2O3 Fe SiO2
Fe_bins
(57.0, 58.0] 2029.617808 1981.688 2.361519 1.773585 60.443938 2.827210
(58.0, 59.0] 1966.244132 1920.608 2.320980 1.721904 60.544297 2.778291
(59.0, 60.0] 1832.404512 1790.808 2.270051 1.665138 60.681220 2.688934
(60.0, 61.0] 1273.235397 1249.318 1.878474 1.587234 61.124858 2.545138
(61.0, 62.0] 480.496952 472.378 1.689699 1.330578 62.297312 2.354296
(62.0, 63.0] 190.525095 188.678 0.969476 1.244456 63.404374 2.397650
(63.0, 64.0] 94.355184 93.780 0.609595 1.138988 64.398758 2.287915
(64.0, 65.0] 51.132545 50.810 0.630802 1.038770 65.171391 2.304296
(65.0, 66.0] 23.580887 23.440 0.597464 0.894091 65.686199 2.049416
(66.0, 67.0] 5.575258 5.520 0.991126 0.872989 66.194583 1.999819


Plot the Grade Bins

fig = obj_mc.plot_bins(variables=['mass_dry', 'Fe', 'SiO2', 'Al2O3'],
                       cutoff_var='Fe',
                       bin_width=1.0,
                       cumulative=True,
                       direction='descending')
# noinspection PyTypeChecker
plotly.io.show(fig)  # this call to show will set the thumbnail for the gallery
/home/runner/work/mass-composition/mass-composition/elphick/mass_composition/mc_xarray.py:157: FutureWarning:

The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.

Total running time of the script: ( 0 minutes 0.654 seconds)

Gallery generated by Sphinx-Gallery