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=[], **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

1

Middlemost, E. A. K. (1994). Naming materials in the magma/igneous rock system. Earth-Science Reviews, 37(3), 215–224. doi: 10.1016/0012-8252(94)90029-9

2

Le Bas, M.J., Le Maitre, R.W., Woolley, A.R. (1992). The construction of the Total Alkali-Silica chemical classification of volcanic rocks. Mineralogy and Petrology 46, 1–22. doi: 10.1007/BF01160698

3

Le Maitre, R.W. (2002). Igneous Rocks: A Classification and Glossary of Terms : Recommendations of International Union of Geological Sciences Subcommission on the Systematics of Igneous Rocks. Cambridge University Press, 236pp. doi: 10.1017/CBO9780511535581

add_to_axes(ax=None, fill=False, axes_scale=100.0, add_labels=False, which_labels='ID', which_ids=[], 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

4

Soil Science Division Staff (2017). Soil Survey Manual. C. Ditzler, K. Scheffe, and H.C. Monger (eds.). USDA Handbook 18. Government Printing Office, Washington, D.C.

5

Thien, Steve J. (1979). A Flow Diagram for Teaching Texture-by-Feel Analysis. Journal of Agronomic Education 8:54–55. doi: 10.2134/jae.1979.0054

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=[], **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

6

Streckeisen, A. (1974). Classification and nomenclature of plutonic rocks: recommendations of the IUGS subcommission on the systematics of Igneous Rocks. Geol Rundsch 63, 773–786. doi: 10.1007/BF01820841

7

Le Maitre,R.W. (2002). Igneous Rocks: A Classification and Glossary of Terms : Recommendations of International Union of Geological Sciences Subcommission on the Systematics of Igneous Rocks. Cambridge University Press, 236pp doi: 10.1017/CBO9780511535581

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=[], **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

8

Deer, W. A., Howie, R. A., & Zussman, J. (2013). An introduction to the rock-forming minerals (3rd ed.). Mineralogical Society of Great Britain and Ireland.

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=[], **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

9

Jensen, L. S. (1976). A new cation plot for classifying sub-alkaline volcanic rocks. Ontario Division of Mines. Miscellaneous Paper No. 66.

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=[], **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=[], **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=[], **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

10

Pettijohn, F. J., Potter, P. E. and Siever, R. (1973). Sand and Sandstone. New York, Springer-Verlag. 618p. doi: 10.1007/978-1-4615-9974-6

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=[], **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

11

Herron, M.M. (1988). Geochemical classification of terrigenous sands and shales from core or log data. Journal of Sedimentary Research, 58(5), pp.820-829. doi: 10.1306/212F8E77-2B24-11D7-8648000102C1865D

add_to_axes(ax=None, fill=False, axes_scale=1.0, add_labels=False, which_labels='ID', which_ids=[], **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