pyrolite.util.classification

Utilities for rock chemistry and mineral abundance classification.

Todo

  • Petrological classifiers: QAPF (aphanitic/phaneritic), gabbroic Pyroxene-Olivine-Plagioclase, ultramafic Olivine-Orthopyroxene-Clinopyroxene

class pyrolite.util.classification.PolygonClassifier(name=None, axes=None, fields=None, scale=1.0, transform=None, mode=None, **kwargs)[source]

A classifier model built form a series of polygons defining specific classes.

Parameters:
  • name (str) – A name for the classifier model.

  • axes (dict) – Mapping from plot axes to variables to be used for labels.

  • fields (dict) – Dictionary describing indiviudal polygons, with identifiers as keys and dictionaries containing ‘name’ and ‘fields’ items.

  • scale (float) – Default maximum scale for the axes. Typically 100 (wt%) or 1 (fractional).

  • xlim (tuple) – Default x-limits for this classifier for plotting.

  • ylim (tuple) – Default y-limits for this classifier for plotting.

predict(X, data_scale=None)[source]

Predict the classification of samples using the polygon-based classifier.

Parameters:
Returns:

Series containing classifer predictions. If a dataframe was input, it inherit the index.

Return type:

pandas.Series

property axis_components

Get the axis components used by the classifier.

Returns:

Ordered names for axes used by the classifier.

Return type:

tuple

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=None, **kwargs)[source]

Add the fields from the classifier to an axis.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to add the polygons to.

  • fill (bool) – Whether to fill the polygons.

  • axes_scale (float) – Maximum scale for the axes. Typically 100 (for wt%) or 1 (fractional).

  • add_labels (bool) – Whether to add labels for the polygons.

  • which_labels (str) – Which data to use for field labels - field ‘name’ or ‘ID’.

  • which_ids (list) – List of field IDs corresponding to the polygons to add to the axes object. (e.g. for TAS, [‘F’, ‘T1’] to plot the Foidite and Trachyte fields). An empty list corresponds to plotting all the polygons.

Returns:

ax

Return type:

matplotlib.axes.Axes

class pyrolite.util.classification.TAS(which_model=None, **kwargs)[source]

Total-alkali Silica Diagram classifier from Middlemost (1994) [1], a closed-polygon variant after Le Bas et al. (1992) [2].

Parameters:
  • name (str) – A name for the classifier model.

  • axes (list | tuple) – Names of the axes corresponding to the polygon coordinates.

  • fields (dict) – Dictionary describing indiviudal polygons, with identifiers as keys and dictionaries containing ‘name’ and ‘fields’ items.

  • scale (float) – Default maximum scale for the axes. Typically 100 (wt%) or 1 (fractional).

  • xlim (tuple) – Default x-limits for this classifier for plotting.

  • ylim (tuple) – Default y-limits for this classifier for plotting.

  • which_model (str) – The name of the model variant to use, if not Middlemost.

References

add_to_axes(ax=None, fill=False, axes_scale=100.0, add_labels=False, which_labels='ID', which_ids=None, label_at_centroid=True, **kwargs)[source]

Add the TAS fields from the classifier to an axis.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to add the polygons to.

  • fill (bool) – Whether to fill the polygons.

  • axes_scale (float) – Maximum scale for the axes. Typically 100 (for wt%) or 1 (fractional).

  • add_labels (bool) – Whether to add labels for the polygons.

  • which_labels (str) – Which labels to add to the polygons (e.g. for TAS, ‘volcanic’, ‘intrusive’ or the field ‘ID’).

  • which_ids (list) – List of field IDs corresponding to the polygons to add to the axes object. (e.g. for TAS, [‘F’, ‘T1’] to plot the Foidite and Trachyte fields). An empty list corresponds to plotting all the polygons.

  • label_at_centroid (bool) – Whether to label the fields at the centroid (True) or at the visual center of the field (False).

Returns:

ax

Return type:

matplotlib.axes.Axes

property axis_components

Get the axis components used by the classifier.

Returns:

Ordered names for axes used by the classifier.

Return type:

tuple

predict(X, data_scale=None)

Predict the classification of samples using the polygon-based classifier.

Parameters:
Returns:

Series containing classifer predictions. If a dataframe was input, it inherit the index.

Return type:

pandas.Series

class pyrolite.util.classification.USDASoilTexture(**kwargs)[source]

United States Department of Agriculture Soil Texture classification model [4] [5].

Parameters:
  • name (str) – A name for the classifier model.

  • axes (list | tuple) – Names of the axes corresponding to the polygon coordinates.

  • fields (dict) – Dictionary describing indiviudal polygons, with identifiers as keys and dictionaries containing ‘name’ and ‘fields’ items.

References

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=None, **kwargs)

Add the fields from the classifier to an axis.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to add the polygons to.

  • fill (bool) – Whether to fill the polygons.

  • axes_scale (float) – Maximum scale for the axes. Typically 100 (for wt%) or 1 (fractional).

  • add_labels (bool) – Whether to add labels for the polygons.

  • which_labels (str) – Which data to use for field labels - field ‘name’ or ‘ID’.

  • which_ids (list) – List of field IDs corresponding to the polygons to add to the axes object. (e.g. for TAS, [‘F’, ‘T1’] to plot the Foidite and Trachyte fields). An empty list corresponds to plotting all the polygons.

Returns:

ax

Return type:

matplotlib.axes.Axes

property axis_components

Get the axis components used by the classifier.

Returns:

Ordered names for axes used by the classifier.

Return type:

tuple

predict(X, data_scale=None)

Predict the classification of samples using the polygon-based classifier.

Parameters:
Returns:

Series containing classifer predictions. If a dataframe was input, it inherit the index.

Return type:

pandas.Series

class pyrolite.util.classification.QAP(**kwargs)[source]

IUGS QAP ternary classification [6] [7].

Parameters:
  • name (str) – A name for the classifier model.

  • axes (list | tuple) – Names of the axes corresponding to the polygon coordinates.

  • fields (dict) – Dictionary describing indiviudal polygons, with identifiers as keys and dictionaries containing ‘name’ and ‘fields’ items.

References

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=None, **kwargs)

Add the fields from the classifier to an axis.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to add the polygons to.

  • fill (bool) – Whether to fill the polygons.

  • axes_scale (float) – Maximum scale for the axes. Typically 100 (for wt%) or 1 (fractional).

  • add_labels (bool) – Whether to add labels for the polygons.

  • which_labels (str) – Which data to use for field labels - field ‘name’ or ‘ID’.

  • which_ids (list) – List of field IDs corresponding to the polygons to add to the axes object. (e.g. for TAS, [‘F’, ‘T1’] to plot the Foidite and Trachyte fields). An empty list corresponds to plotting all the polygons.

Returns:

ax

Return type:

matplotlib.axes.Axes

property axis_components

Get the axis components used by the classifier.

Returns:

Ordered names for axes used by the classifier.

Return type:

tuple

predict(X, data_scale=None)

Predict the classification of samples using the polygon-based classifier.

Parameters:
Returns:

Series containing classifer predictions. If a dataframe was input, it inherit the index.

Return type:

pandas.Series

class pyrolite.util.classification.FeldsparTernary(**kwargs)[source]

Simplified feldspar diagram classifier, based on a version printed in the second edition of ‘An Introduction to the Rock Forming Minerals’ (Deer, Howie and Zussman).

Parameters:
  • name (str) – A name for the classifier model.

  • axes (list | tuple) – Names of the axes corresponding to the polygon coordinates.

  • fields (dict) – Dictionary describing indiviudal polygons, with identifiers as keys and dictionaries containing ‘name’ and ‘fields’ items.

  • mode (str) – Mode of the diagram to use; two are currently available - ‘default’, which fills the entire ternary space, and ‘miscibility-gap’ which gives a simplified approximation of the miscibility gap.

References

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=None, **kwargs)

Add the fields from the classifier to an axis.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to add the polygons to.

  • fill (bool) – Whether to fill the polygons.

  • axes_scale (float) – Maximum scale for the axes. Typically 100 (for wt%) or 1 (fractional).

  • add_labels (bool) – Whether to add labels for the polygons.

  • which_labels (str) – Which data to use for field labels - field ‘name’ or ‘ID’.

  • which_ids (list) – List of field IDs corresponding to the polygons to add to the axes object. (e.g. for TAS, [‘F’, ‘T1’] to plot the Foidite and Trachyte fields). An empty list corresponds to plotting all the polygons.

Returns:

ax

Return type:

matplotlib.axes.Axes

property axis_components

Get the axis components used by the classifier.

Returns:

Ordered names for axes used by the classifier.

Return type:

tuple

predict(X, data_scale=None)

Predict the classification of samples using the polygon-based classifier.

Parameters:
Returns:

Series containing classifer predictions. If a dataframe was input, it inherit the index.

Return type:

pandas.Series

class pyrolite.util.classification.PeralkalinityClassifier[source]
predict(df: DataFrame)[source]
class pyrolite.util.classification.JensenPlot(**kwargs)[source]

Jensen Plot for classification of subalkaline volcanic rocks [9].

Parameters:
  • name (str) – A name for the classifier model.

  • axes (list | tuple) – Names of the axes corresponding to the polygon coordinates.

  • fields (dict) – Dictionary describing indiviudal polygons, with identifiers as keys and dictionaries containing ‘name’ and ‘fields’ items.

References

Notes

Diagram used for the classification classification of subalkalic volcanic rocks. The diagram is constructed for molar cation percentages of Al, Fe+Ti and Mg, on account of these elements’ stability upon metamorphism. This particular version uses updated labels relative to Jensen (1976), in which the fields have been extended to the full range of the ternary plot.

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=None, **kwargs)

Add the fields from the classifier to an axis.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to add the polygons to.

  • fill (bool) – Whether to fill the polygons.

  • axes_scale (float) – Maximum scale for the axes. Typically 100 (for wt%) or 1 (fractional).

  • add_labels (bool) – Whether to add labels for the polygons.

  • which_labels (str) – Which data to use for field labels - field ‘name’ or ‘ID’.

  • which_ids (list) – List of field IDs corresponding to the polygons to add to the axes object. (e.g. for TAS, [‘F’, ‘T1’] to plot the Foidite and Trachyte fields). An empty list corresponds to plotting all the polygons.

Returns:

ax

Return type:

matplotlib.axes.Axes

property axis_components

Get the axis components used by the classifier.

Returns:

Ordered names for axes used by the classifier.

Return type:

tuple

predict(X, data_scale=None)

Predict the classification of samples using the polygon-based classifier.

Parameters:
Returns:

Series containing classifer predictions. If a dataframe was input, it inherit the index.

Return type:

pandas.Series

class pyrolite.util.classification.SpinelTrivalentTernary(**kwargs)[source]

Spinel Trivalent Ternary classification - designed for data in atoms per formula unit

Parameters:
  • name (str) – A name for the classifier model.

  • axes (list | tuple) – Names of the axes corresponding to the polygon coordinates.

  • fields (dict) – Dictionary describing indiviudal polygons, with identifiers as keys and dictionaries containing ‘name’ and ‘fields’ items.

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=None, **kwargs)

Add the fields from the classifier to an axis.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to add the polygons to.

  • fill (bool) – Whether to fill the polygons.

  • axes_scale (float) – Maximum scale for the axes. Typically 100 (for wt%) or 1 (fractional).

  • add_labels (bool) – Whether to add labels for the polygons.

  • which_labels (str) – Which data to use for field labels - field ‘name’ or ‘ID’.

  • which_ids (list) – List of field IDs corresponding to the polygons to add to the axes object. (e.g. for TAS, [‘F’, ‘T1’] to plot the Foidite and Trachyte fields). An empty list corresponds to plotting all the polygons.

Returns:

ax

Return type:

matplotlib.axes.Axes

property axis_components

Get the axis components used by the classifier.

Returns:

Ordered names for axes used by the classifier.

Return type:

tuple

predict(X, data_scale=None)

Predict the classification of samples using the polygon-based classifier.

Parameters:
Returns:

Series containing classifer predictions. If a dataframe was input, it inherit the index.

Return type:

pandas.Series

class pyrolite.util.classification.SpinelFeBivariate(**kwargs)[source]

Fe-Spinel classification, designed for data in atoms per formula unit.

Parameters:
  • name (str) – A name for the classifier model.

  • axes (list | tuple) – Names of the axes corresponding to the polygon coordinates.

  • fields (dict) – Dictionary describing indiviudal polygons, with identifiers as keys and dictionaries containing ‘name’ and ‘fields’ items.

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=None, **kwargs)

Add the fields from the classifier to an axis.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to add the polygons to.

  • fill (bool) – Whether to fill the polygons.

  • axes_scale (float) – Maximum scale for the axes. Typically 100 (for wt%) or 1 (fractional).

  • add_labels (bool) – Whether to add labels for the polygons.

  • which_labels (str) – Which data to use for field labels - field ‘name’ or ‘ID’.

  • which_ids (list) – List of field IDs corresponding to the polygons to add to the axes object. (e.g. for TAS, [‘F’, ‘T1’] to plot the Foidite and Trachyte fields). An empty list corresponds to plotting all the polygons.

Returns:

ax

Return type:

matplotlib.axes.Axes

property axis_components

Get the axis components used by the classifier.

Returns:

Ordered names for axes used by the classifier.

Return type:

tuple

predict(X, data_scale=None)

Predict the classification of samples using the polygon-based classifier.

Parameters:
Returns:

Series containing classifer predictions. If a dataframe was input, it inherit the index.

Return type:

pandas.Series

class pyrolite.util.classification.Pettijohn(**kwargs)[source]

Pettijohn (1973) sandstones classification [10].

Parameters:
  • name (str) – A name for the classifier model.

  • axes (list | tuple) – Names of the axes corresponding to the polygon coordinates.

  • fields (dict) – Dictionary describing indiviudal polygons, with identifiers as keys and dictionaries containing ‘name’ and ‘fields’ items.

References

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=None, **kwargs)

Add the fields from the classifier to an axis.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to add the polygons to.

  • fill (bool) – Whether to fill the polygons.

  • axes_scale (float) – Maximum scale for the axes. Typically 100 (for wt%) or 1 (fractional).

  • add_labels (bool) – Whether to add labels for the polygons.

  • which_labels (str) – Which data to use for field labels - field ‘name’ or ‘ID’.

  • which_ids (list) – List of field IDs corresponding to the polygons to add to the axes object. (e.g. for TAS, [‘F’, ‘T1’] to plot the Foidite and Trachyte fields). An empty list corresponds to plotting all the polygons.

Returns:

ax

Return type:

matplotlib.axes.Axes

property axis_components

Get the axis components used by the classifier.

Returns:

Ordered names for axes used by the classifier.

Return type:

tuple

predict(X, data_scale=None)

Predict the classification of samples using the polygon-based classifier.

Parameters:
Returns:

Series containing classifer predictions. If a dataframe was input, it inherit the index.

Return type:

pandas.Series

class pyrolite.util.classification.Herron(**kwargs)[source]

Herron (1988) sandstones classification [11].

Parameters:
  • name (str) – A name for the classifier model.

  • axes (list | tuple) – Names of the axes corresponding to the polygon coordinates.

  • fields (dict) – Dictionary describing indiviudal polygons, with identifiers as keys and dictionaries containing ‘name’ and ‘fields’ items.

References

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=None, **kwargs)

Add the fields from the classifier to an axis.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to add the polygons to.

  • fill (bool) – Whether to fill the polygons.

  • axes_scale (float) – Maximum scale for the axes. Typically 100 (for wt%) or 1 (fractional).

  • add_labels (bool) – Whether to add labels for the polygons.

  • which_labels (str) – Which data to use for field labels - field ‘name’ or ‘ID’.

  • which_ids (list) – List of field IDs corresponding to the polygons to add to the axes object. (e.g. for TAS, [‘F’, ‘T1’] to plot the Foidite and Trachyte fields). An empty list corresponds to plotting all the polygons.

Returns:

ax

Return type:

matplotlib.axes.Axes

property axis_components

Get the axis components used by the classifier.

Returns:

Ordered names for axes used by the classifier.

Return type:

tuple

predict(X, data_scale=None)

Predict the classification of samples using the polygon-based classifier.

Parameters:
Returns:

Series containing classifer predictions. If a dataframe was input, it inherit the index.

Return type:

pandas.Series