pyrolite icon indicating copy to clipboard operation
pyrolite copied to clipboard

Fe oxidation ratio calculation based on Middlemost (1989) [Feature]

Open bomtuckle opened this issue 2 years ago • 8 comments

Is your feature request related to a problem? Please describe. The normative calculation currently implements the Le Maitre method of calculating Fe oxidation ratios. Another method is the by classification of the sample on a TAS diagram and then using a set of standard ratios per classification.

Describe the solution you'd like Add in a function within the current normative function, that implements this method of determining Fe oxidation ratio

Relevant References Middlemost 1989

bomtuckle avatar Mar 28 '22 11:03 bomtuckle

@bomtuckle I've added a draft correction for the Middlemost Fe-correction based on TAS here but haven't tested it just yet. If you have a few minutes to look over it that'd be handy. I've added a note on the docs page too, as well as split the volcanic/non-volcanic samples there.

morganjwilliams avatar Mar 31 '22 14:03 morganjwilliams

MWE for accessing the Middlemost correction, and using it in the CIPW Norm:

import pandas as pd
import pyrolite.geochem
from pyrolite.mineral.normative import CIPW_norm, Middlemost_Fe_correction
from pyrolite.util.meta import pyrolite_datafolder

df = (
    pd.read_csv(pyrolite_datafolder() / "testing" / "CIPW_Verma_Test.csv")
    .dropna(how="all", axis=1)
    .pyrochem.parse_chem()
)
df.pyrochem.compositional = df.pyrochem.compositional.apply(
    pd.to_numeric, errors="coerce"
).fillna(0)
df.loc[:, [c for c in df.columns if "NORM" in c]] = df.loc[
    :, [c for c in df.columns if "NORM" in c]
].apply(pd.to_numeric, errors="coerce")
#%%
Middlemost_Fe_correction(df)
#%%
CIPW_norm(df, Fe_correction="Middle")

morganjwilliams avatar Apr 01 '22 03:04 morganjwilliams

Thanks @morganjwilliams . I've had a quick look and seems fine to me, and it runs ok. I will try and do a comparison with the output of IgRoCs to confirm the pyrolite output.

bomtuckle avatar Apr 06 '22 16:04 bomtuckle

@bomtuckle that'd be great! If things look OK after that, it'll be time for v0.3.2!

morganjwilliams avatar Apr 07 '22 01:04 morganjwilliams

@morganjwilliams unfortunately I don't think it is working correctly. The adjusted Fe values are quite different from those out of igrocs. I think it actually looks like the FeO and Fe2O3 values are reversed, but not sure looking at your code at what point this has happened.

bomtuckle avatar Apr 11 '22 14:04 bomtuckle

@bomtuckle I'll take a look today; if I got the ratios in the wrong order somewhere that'll do it.

Edit: I think I did indeed have the ratio around the wrong way when converting from Fe2O3/FeO to Fe2O3/(Fe2O3+FeO). I've fixed this specifically and added a test to formally check the outputs of these are as expected (100cb1c44b0d5ff11262dde78fdcdc8d8d73555b).

morganjwilliams avatar Apr 12 '22 02:04 morganjwilliams

@morganjwilliams looks better now! Compared to the igrocs output its broadly ok now, but there are still some discrepancies. I suspect this may be coming from a few differences in the TAS classification? I will try and investigate, but the igrocs is a bit confusing to understand

bomtuckle avatar Apr 12 '22 13:04 bomtuckle

OK, good! If you spy some samples that are particularly bad let me know their compositions/TAS classification and I'll debug a bit. The TAS diagram in Middlemost's paper is slightly different to the one I'm using by default in pyrolite, but most things transfer over fine. The main complication is for a few low-SiO2 fields which have additional boundaries, some fields in the TAS diagram which are split (e.g. Ba/Bs instead of the single Basalt field; these are easily dealt with using two entries with the same value), but Middlemost does point to additional fields below 41% SiO2 which don't line up well (the upper one is within Foidite, the lower one is ~picrobasalt but less SiO2).

morganjwilliams avatar Apr 13 '22 01:04 morganjwilliams