Note
Click here to download the full example code
Incremental Separation
This method sorts by the provided direction prior to incrementally removing and discarding the first fraction (of the remaining fractions) and recalculating the mass-composition and recovery of the portion remaining. This is equivalent to incrementally applying a perfect separation (partition) at every interval edge.
The returned data can be used to assess the amenability of a fractionated sample (in the dimension of the sample).
This concept is only applicable in a single dimension where the mass-composition (sample) object is an interval index.
The example will use a dataset that represents a sample fractionated by size.
import logging
import pandas as pd
import plotly
from elphick.mass_composition import MassComposition
from elphick.mass_composition.datasets.sample_data import size_by_assay
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)s %(module)s - %(funcName)s: %(message)s',
datefmt='%Y-%m-%dT%H:%M:%S%z')
Create the sample
The sample is a MassComposition object
df_data: pd.DataFrame = size_by_assay()
df_data
The size index is of the Interval type, maintaining the fractional information.
mc_size: MassComposition = MassComposition(df_data, name='Sample')
mc_size.data.to_dataframe
<bound method Dataset.to_dataframe of <xarray.Dataset> Size: 336B
Dimensions: (size: 6)
Coordinates:
* size (size) object 48B [0.85, 2.0) [0.5, 0.85) ... [0.0, 0.045)
Data variables:
mass_wet (size) float64 48B 3.3 9.9 26.5 2.5 8.8 49.0
mass_dry (size) float64 48B 3.3 9.9 26.5 2.5 8.8 49.0
H2O (size) float64 48B 0.0 0.0 0.0 0.0 0.0 0.0
Fe (size) float64 48B 64.15 64.33 64.52 62.65 62.81 55.95
SiO2 (size) float64 48B 2.04 2.05 1.84 2.88 2.12 6.39
Al2O3 (size) float64 48B 2.68 2.23 2.19 3.32 2.25 6.34
Attributes:
mc_name: Sample
mc_vars_mass: ['mass_wet', 'mass_dry']
mc_vars_chem: ['Fe', 'SiO2', 'Al2O3']
mc_vars_attrs: []
mc_interval_edges: {'size': {'left': 'retained', 'right': 'passing'}}>
Incrementally Separate
Leverage the method to return the incremental perfect separation in the size dimension. Here we will “de-slime” by discarding the smallest (lowest) sizes incrementally.
results: pd.DataFrame = mc_size.ideal_incremental_separation(discard_from="lowest")
results
/home/runner/work/mass-composition/mass-composition/elphick/mass_composition/mass_composition.py:1386: 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`.
Repeat the process but by discarding the coarser sizes.
results_2: pd.DataFrame = mc_size.ideal_incremental_separation(discard_from="highest")
results_2
/home/runner/work/mass-composition/mass-composition/elphick/mass_composition/mass_composition.py:1386: 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`.
Plot Grade-Recovery
fig = mc_size.plot_grade_recovery(target_analyte='Fe')
fig.update_layout(height=800)
fig
/home/runner/work/mass-composition/mass-composition/elphick/mass_composition/mass_composition.py:1386: 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`.
Discard the highest (coarsest) sizes. As expected the response differs.
fig = mc_size.plot_grade_recovery(target_analyte='Fe', discard_from="highest")
fig.update_layout(height=800)
/home/runner/work/mass-composition/mass-composition/elphick/mass_composition/mass_composition.py:1386: 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`.
Plot Amenability
The Amenability Index (AI) will generally range between zero and one, but can in fact be legitimately negative. The closer the AI is to 1.0, the more amenable the ore is to separation of that particular gangue component relative to the target analyte. The AI is shown in the legend (in brackets).
The plot below suggests that SiO2 is marginally more amenable than Al2O3 across the spectrum of yield for this sample.
fig = mc_size.plot_amenability(target_analyte='Fe')
fig.update_layout(height=800)
# noinspection PyTypeChecker
plotly.io.show(fig)
/home/runner/work/mass-composition/mass-composition/elphick/mass_composition/mass_composition.py:1386: 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`.
Discard the highest (coarsest) sizes. As expected the response differs. The Amenability indices are negative indicating a downgrade, rather than an upgrade. This demonstrates that desliming is a plausible pathway to beneficiating this sample, while “coarse scalping” is not.
fig = mc_size.plot_amenability(target_analyte='Fe', discard_from="highest")
fig.update_layout(height=800)
fig
/home/runner/work/mass-composition/mass-composition/elphick/mass_composition/mass_composition.py:1386: 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 1.361 seconds)