pyrolite.geochem.pyrochem (Pandas Interface)
- class pyrolite.geochem.pyrochem(obj)[source]
- property list_elements
Get the subset of columns which are element names.
- Return type
Notes
The list will have the same ordering as the source DataFrame.
- property list_isotope_ratios
Get the subset of columns which are isotope ratios.
- Return type
Notes
The list will have the same ordering as the source DataFrame.
- property list_REE
Get the subset of columns which are Rare Earth Element names.
- Return type
Notes
The returned list will reorder REE based on atomic number.
- property list_REY
Get the subset of columns which are Rare Earth Element names.
- Return type
Notes
The returned list will reorder REE based on atomic number.
- property list_oxides
Get the subset of columns which are oxide names.
- Return type
Notes
The list will have the same ordering as the source DataFrame.
- property list_compositional
- property elements
Get an elemental subset of a DataFrame.
- Return type
pandas.Dataframe
- property REE
Get a Rare Earth Element subset of a DataFrame.
- Return type
pandas.Dataframe
- property REY
Get a Rare Earth Element + Yttrium subset of a DataFrame.
- Return type
pandas.Dataframe
- property oxides
Get an oxide subset of a DataFrame.
- Return type
pandas.Dataframe
- property isotope_ratios
Get an isotope ratio subset of a DataFrame.
- Return type
pandas.Dataframe
- property compositional
Get an oxide & elemental subset of a DataFrame.
- Return type
pandas.Dataframe
Notes
This wil not include isotope ratios.
- parse_chem(abbrv=['ID', 'IGSN'], split_on='[\\s_]+')[source]
Convert column names to pyrolite-recognised elemental, oxide and isotope ratio column names where valid names are found.
- check_multiple_cation_inclusion(exclude=['LOI', 'FeOT', 'Fe2O3T'])[source]
Returns cations which are present in both oxide and elemental form.
- to_molecular(renorm=True)[source]
Converts mass quantities to molar quantities.
- Parameters
renorm (
bool
,True
) – Whether to renormalise the dataframe after converting to relative moles.Notes
Does not convert units (i.e. mass% –> mol%; mass-ppm –> mol-ppm).
- Returns
Transformed dataframe.
- Return type
- to_weight(renorm=True)[source]
Converts molar quantities to mass quantities.
- Parameters
renorm (
bool
,True
) – Whether to renormalise the dataframe after converting to relative moles.Notes
Does not convert units (i.e. mol% –> mass%; mol-ppm –> mass-ppm).
- Returns
Transformed dataframe.
- Return type
- devolatilise(exclude=['H2O', 'H2O_PLUS', 'H2O_MINUS', 'CO2', 'LOI'], renorm=True)[source]
Recalculates components after exclusion of volatile phases (e.g. H2O, CO2).
- Parameters
- Returns
Transformed dataframe.
- Return type
- elemental_sum(component=None, to=None, total_suffix='T', logdata=False, molecular=False)[source]
Sums abundance for a cation to a single series, starting from a dataframe containing multiple componnents with a single set of units.
- Parameters
- Returns
Series with cation aggregated.
- Return type
- aggregate_element(to, total_suffix='T', logdata=False, renorm=False, molecular=False)[source]
Aggregates cation information from oxide and elemental components to either a single species or a designated mixture of species.
- Parameters
to (
str
|Element
|Formula
|dict
) – Component(s) to convert to. If one component is specified, the element will be converted to the target species.If more than one component is specified with proportions in a dictionary (e.g.
{'FeO': 0.9, 'Fe2O3': 0.1}
), the components will be split as a fraction of the elemental sum.renorm (
bool
,True
) – Whether to renormalise the dataframe after recalculation.total_suffix (
str
, ‘T’) – Suffix of ‘total’ variables. E.g. ‘T’ for FeOT, Fe2O3T.logdata (
bool
,False
) – Whether the data has been log transformed.molecular (
bool
,False
) – Whether to perform a sum of molecular data.Notes
This won’t convert units, so need to start from single set of units.
- Returns
Series with cation aggregated.
- Return type
- recalculate_Fe(to='FeOT', renorm=False, total_suffix='T', logdata=False, molecular=False)[source]
Recalculates abundances of iron, and normalises a dataframe to contain either a single species, or multiple species in certain proportions.
- Parameters
to (
str
|Element
|Formula
|dict
) – Component(s) to convert to.If one component is specified, all iron will be converted to the target species.
If more than one component is specified with proportions in a dictionary (e.g.
{'FeO': 0.9, 'Fe2O3': 0.1}
), the components will be split as a fraction of Fe.renorm (
bool
,False
) – Whether to renormalise the dataframe after recalculation.total_suffix (
str
, ‘T’) – Suffix of ‘total’ variables. E.g. ‘T’ for FeOT, Fe2O3T.logdata (
bool
,False
) – Whether the data has been log transformed.molecular (
bool
,False
) – Flag that data is in molecular units, rather than weight units.- Returns
Transformed dataframe.
- Return type
- get_ratio(ratio: str, alias: Optional[str] = None, norm_to=None, molecular=False)[source]
Add a ratio of components A and B, given in the form of string ‘A/B’. Returned series be assigned an alias name.
- Parameters
ratio (
str
) – String decription of ratio in the form A/B[_n].alias (
str
) – Alternate name for ratio to be used as column name.norm_to (
str
|pyrolite.geochem.norm.Composition
, None) – Reference composition to normalise to.molecular (
bool
,False
) – Flag that data is in molecular units, rather than weight units.- Returns
Dataframe with ratio appended.
- Return type
See also
- add_ratio(ratio: str, alias: Optional[str] = None, norm_to=None, molecular=False)[source]
Add a ratio of components A and B, given in the form of string ‘A/B’. Returned series be assigned an alias name.
- Parameters
ratio (
str
) – String decription of ratio in the form A/B[_n].alias (
str
) – Alternate name for ratio to be used as column name.norm_to (
str
|pyrolite.geochem.norm.Composition
, None) – Reference composition to normalise to.molecular (
bool
,False
) – Flag that data is in molecular units, rather than weight units.- Returns
Dataframe with ratio appended.
- Return type
See also
- add_MgNo(molecular=False, use_total_approx=False, approx_Fe203_frac=0.1, name='Mg#')[source]
Append the magnesium number to a dataframe.
- Parameters
molecular (
bool
,False
) – Whether the input data is molecular.use_total_approx (
bool
,False
) – Whether to use an approximate calculation using total iron rather than just FeO.approx_Fe203_frac (
float
) – Fraction of iron which is oxidised, used in approximation mentioned above.name (
str
) – Name to use for the Mg Number column.- Returns
Dataframe with ratio appended.
- Return type
See also
add_ratio()
- lambda_lnREE(norm_to='ChondriteREE_ON', exclude=['Pm', 'Eu', 'Ce', 'Eu', 'Eu', 'Ce'], params=None, degree=4, scale='ppm', sigmas=None, **kwargs)[source]
Calculates orthogonal polynomial coefficients (lambdas) for a given set of REE data, normalised to a specific composition 1. Lambda factors are given for the radii vs. ln(REE/NORM) polynomial combination.
- Parameters
norm_to (
str
|Composition
|numpy.ndarray
) – Which reservoir to normalise REE data to (defaults to"ChondriteREE_ON"
).exclude (
list
,["Pm", "Eu"]
) – Which REE elements to exclude from the fit. May wish to include Ce for minerals in which Ce anomalies are common.params (
list
|str
,None
) – Pre-computed parameters for the orthogonal polynomials (a list of tuples). Optionally specified, otherwise defaults the parameterisation as in O’Neill (2016). If a string is supplied,"O'Neill (2016)"
or similar will give the original defaults, while"full"
will use all of the REE (including Eu) as a basis for the orthogonal polynomials.degree (
int
, 4) – Maximum degree polynomial fit component to include.scale (
str
) – Current units for the REE data, used to scale the reference dataset.sigmas (
float
|numpy.ndarray
|pandas.Series
) – Value or 1D array of fractional REE uncertaintes (i.e. \(\sigma_{REE}/REE\)).References
- 1
O’Neill HSC (2016) The Smoothness and Shapes of Chondrite-normalized Rare Earth Element Patterns in Basalts. J Petrology 57:1463–1508. doi: 10.1093/petrology/egw047
See also
get_ionic_radii()
,calc_lambdas()
,orthogonal_polynomial_constants()
,REE_radii_plot()
- convert_chemistry(to=[], logdata=False, renorm=False, molecular=False)[source]
Attempts to convert a dataframe with one set of components to another.
- Parameters
to (
list
) – Set of columns to try to extract from the dataframe.Can also include a dictionary for iron speciation. See
pyrolite.geochem.recalculate_Fe()
.logdata (
bool
,False
) – Whether chemical data has been log transformed. Necessary for aggregation functions.renorm (
bool
,False
) – Whether to renormalise the data after transformation.molecular (
bool
,False
) – Flag that data is in molecular units, rather than weight units.- Returns
Dataframe with converted chemistry.
- Return type
Todo
Check for conflicts between oxides and elements
Aggregator for ratios
Implement generalised redox transformation.
Add check for dicitonary components (e.g. Fe) in tests
- normalize_to(reference=None, units=None, convert_first=False)[source]
Normalise a dataframe to a given reference composition.
- Parameters
reference (
str
|Composition
|numpy.ndarray
) – Reference composition to normalise to.units (
str
) – Units of the input dataframe, to convert the reference composition.convert_first (
bool
) – Whether to first convert the referenece compostion before normalisation. This is useful where elements are presented as different components (e.g. Ti, TiO2).- Returns
Dataframe with normalised chemistry.
- Return type
Notes
This assumes that dataframes have a single set of units.
- denormalize_from(reference=None, units=None)[source]
De-normalise a dataframe from a given reference composition.
- Parameters
reference (
str
|Composition
|numpy.ndarray
) – Reference composition which the composition is normalised to.units (
str
) – Units of the input dataframe, to convert the reference composition.- Returns
Dataframe with normalised chemistry.
- Return type
Notes
This assumes that dataframes have a single set of units.