morganjwilliams / pyrolite

A set of tools for getting the most from your geochemical data.
https://pyrolite.readthedocs.io
Other
133 stars 37 forks source link

pyrolite.geochem.transform.get_ratio: norm_to not implemented. #34

Closed morganjwilliams closed 3 years ago

morganjwilliams commented 4 years ago

The function pyrolite.geochem.transform.get_ratio accepts the keyword norm_to for getting normalised ratios, but this is not currently implemented.

Most of the required implementation is there, but it needs to be updated so the correct values will be returned (currently the normalized values are taken from the respective dataframes, but they aren't then assigned to a ratio variable or stored as a column in a dataframe).

morganjwilliams commented 3 years ago

This issue has now been addressed with e9b96ff2a1b9780b047a190222fcd0d337932282 . You can now add normalized ratios by i) specifying the composition/number to normalize to (e.g. "Chondrite_PON", a tuple of abundances (2.1, 3.1), or a single number), ii) appending "_n" to the end of the ratio you request (e.g. "Mg/Fe_n" or "(Mg/Fe)_n") or iii) doing both of these things. For example:

df.pyrochem.add_ratio("(Ce/La)_n", norm_to"'Chondrite_PON", alias="Ce/La_NORM")

will add the column "Ce/La_NORM" to the dataframe after calculating the Chondrite-normalised ratio of Ce to La.