pyrolite.geochem.parse

Functions for parsing, formatting and validating chemical names and formulae.

pyrolite.geochem.parse.is_isotoperatio(s)[source]

Check if text is plausibly an isotope ratio.

Parameters

s (str) – String to validate.

Return type

bool

Todo

  • Validate the isotope masses vs natural isotopes

pyrolite.geochem.parse.repr_isotope_ratio(isotope_ratio)[source]

Format an isotope ratio pair as a string.

Parameters

isotope_ratio (tuple) – Numerator, denominator pair.

Return type

str

Todo

Consider returning additional text outside of the match (e.g. 87Sr/86Sri should include the ‘i’).

pyrolite.geochem.parse.ischem(s)[source]

Checks if a string corresponds to chemical component (compositional). Here simply checking whether it is a common element or oxide.

Parameters

s (str) – String to validate.

Return type

bool

Todo

  • Implement checking for other compounds, e.g. carbonates.

pyrolite.geochem.parse.tochem(strings: list, abbrv=['ID', 'IGSN'], split_on='[\\s_]+')[source]

Converts a list of strings containing come chemical compounds to appropriate case.

Parameters
  • strings (list) – Strings to convert to ‘chemical case’.

  • abbr (list, ["ID", "IGSN"]) – Abbreivated phrases to ignore in capitalisation.

  • split_on (str, “[s_]+”) – Regex for character or phrases to split the strings on.

Return type

list | str

pyrolite.geochem.parse.check_multiple_cation_inclusion(df, exclude=['LOI', 'FeOT', 'Fe2O3T'])[source]

Returns cations which are present in both oxide and elemental form.

Parameters
  • df (pandas.DataFrame) – Dataframe to check duplication within.

  • exclude (list, ["LOI", "FeOT", "Fe2O3T"]) – List of components to exclude from the duplication check.

Returns

Set of elements for which multiple components exist in the dataframe.

Return type

set

Todo

  • Options for output (string/formula).