Skip to content

Commit

Permalink
added option to input df for sulfur comparison paper
Browse files Browse the repository at this point in the history
  • Loading branch information
PennyWieser committed Mar 17, 2024
1 parent 41b9e65 commit fa9e86d
Show file tree
Hide file tree
Showing 11 changed files with 580 additions and 139 deletions.

Large diffs are not rendered by default.

Binary file modified docs/Examples/Mantle_Melting_Lee_Wieser/Cu_Ba_behavoir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
203 changes: 195 additions & 8 deletions docs/Examples/Mantle_Melting_Lee_Wieser/Simple_Melting_Cu_S_Ba.ipynb

Large diffs are not rendered by default.

28 changes: 2 additions & 26 deletions docs/Examples/Other_Useful_Functions/Converting_S_values.ipynb

Large diffs are not rendered by default.

318 changes: 231 additions & 87 deletions docs/Examples/S6_S2_Corrections/CalcS6ST_Muth.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@
"id": "9dd0ca09-cd2a-44c5-9b5a-9da83451e353",
"metadata": {},
"source": [
"## Now lets plot to match the figure of Rezeau et al. (2015)"
"## Now lets plot to match the figure of Rezeau et al. (2023)"
]
},
{
Expand Down
71 changes: 71 additions & 0 deletions docs/worked_examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
================
Worked examples
================

This page summarizes the different examples available. If you want a specific example, we can always include more.

Importing data
=====================

This :doc:`example <Examples\Data_Input\Importing_Spreadsheet>` shows how to load in data from a spreadsheet

This :doc:`example <Examples\Data_Input\Importing_Petrolog>` shows how to load in data from a Petrolog3 crystallization path

This :doc:`example <Examples\Data_Input\Importing_MeltsTBL>` shows how to load in data from different MELTS paths


Integrating PySulfSat and Petrolog3
==========================================

This :doc:`example <Examples\Intro_Example_Petrolog_FC\FC_Petrolog>` shows how to calculate the SCSS and SCAS for a petrolog3 fractionation path using a wide range of models.
It also shows how to perform corrections using different models for S6+/ST



Integrating PySulfSat and MELTS calculations
==========================================

This :doc:`example <Examples\Integrating_with_PetThermoTools\Single_FC_Model>` shows how to run a single MELTS crystallization model in PeTThermoTools
and then perform SCSS calculations. To run a FC calculation with more water, see this :doc:`example <Examples\Integrating_with_PetThermoTools\Single_FC_Model_morewaterrich>`


This :doc:`example <Examples\Integrating_with_PetThermoTools\Polybaric_FC_Model>` shows how to run FC models at multiple pressures, and then calculate the SCSS


Modelling Mantle Melting
==========================

This :doc:`example <Examples\Mantle_Melting_Lee_Wieser\Simple_Melting_Cu_S_Ba>` shows how to model S, chalcophile and lithophile elements during mantle melting, following an adaptation of the model of Lee et al. (2012). We keep the S content of the melt fixed for simplicity. We show how to perform calculations at different S6/ST ratios

This :doc:`example <Examples\Mantle_Melting_Lee_Wieser\Complex_melt_changing_SCSS>` is a more complex example. It loads a Thermocalc melting path (e.g. major elements of mantle melts), and uses this to calculate a SCSS at each step in the model. It also accounts for changing silicate modes.

Calculating and correcting for S6
==========================
This :doc:`example <Examples\S6_S2_Corrections\S6_S2_Corrections_Nash_Jugo_Kleinsasser>` shows how to calculate SCSS2- and SCSSTot and SCAS6+ and SCASTot, and make the plot shown in the PySulfSat paper of total S vs. QFM. It also shows how to perfrom corrections for different s6+ models to a petrolog3 fractionation path.



This :doc:`example <Examples\S6_S2_Corrections\CalcS6ST_Muth>` shows how to calculate S6/St using different models, including how to propagate uncertainty using monte-carlo methods based on errors in input major element contents, for both S6/ST and SCSS

This :doc:`example <Examples\S6_S2_Corrections\CS6_S6ST_Correction>` shows how to calculate S6/St from lnC6, lnCS2 etc. using Oneill and Mavrogenes (2022) and Boulling and wood (2022) for comparison.

Icelandic case study
=======================
This This :doc:`example <Examples\Sulf_Evolution_During_FC\Sulfide_sat_magma_evolution_Iceland>` show how to model the SCSS following the method used in Liu et al. (2024) examining sulfide saturation at Holuhraun, Iceland. Calculated SCSS sulfide compositions are compared to measured compositions, and the amount of sulfide removed at each step is also calculated.


Other useful functions
==========================
This :doc:`example <Examples\Other_Useful_Functions\Calculating_KDs_Kiseeva>` shows how to use the KD model of Kiseeva and Wood (2015) and Brenan (2015).

This :doc:`example <Examples\Other_Useful_Functions\Converting_S_values>` shows how to convert between different S isotope notation, and convert SO3 and SO2 to S in ppm etc.

This :doc:`example <Examples\Other_Useful_Functions\Plotting_Cali_Datasets>` shows how to plot the calibration range of each model against your data.


This :doc:`example <Examples\S_isotope_Fractionation_Models\Frac_factors>` shows how to calculate sulfide-melt fractionation factors following Miyoshi et al. (1984), Fiege et al. (2015). We benchmark to Rezeau et al. (2023)



This :doc:`example <Examples/Liquid_Ol_Liq_Themometry/Olivine_Liquid_thermometry>` shows:

2 changes: 1 addition & 1 deletion src/PySulfSat/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# 1) we don't load dependencies by storing it in __init__.py
# 2) we can import it in setup.py for the same reason
# 3) we can import it into your module
__version__ = '1.0.5'
__version__ = '1.0.6'

70 changes: 70 additions & 0 deletions src/PySulfSat/import_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,73 @@
'FeOt_Liq', 'MnO_Liq', 'MgO_Liq', 'CaO_Liq', 'Na2O_Liq', 'K2O_Liq',
'P2O5_Liq', 'H2O_Liq', 'Fe3Fet_Liq', 'Ni_Liq_ppm', 'Cu_Liq_ppm'])

def import_dataframe(df, suffix=None):
""" This function takes a user dataframe, and reforms the columns into the format required by PySulfSat,
In many cases this involves renaming columns to get into the format SiO2_Liq, TiO2_Liq, etc
Parameters
--------------
df: pandas Dataframe
suffix: str
Suffix which is appended onto all columns. E.g. if you have EPMA data, and you cant be bothered to add
'_Liq' to each column manually, it will do so here (but for all columns, not just the oxides)
"""
my_input=df

if suffix is not None:
if any(my_input.columns.str.contains(suffix)):
w.warn('We notice you have specified a suffix, but some of your columns already have this suffix. '
'e.g., If you already have _Liq in the file, you shouldnt specify suffix="_Liq" during the import')

my_input_c = my_input.copy()

if "Sample_ID_Liq" not in my_input_c:
my_input_c['Sample_ID_Liq'] = my_input.index

if suffix is not None:
if any(my_input.columns.str.contains("FeOT")) and (all(my_input.columns.str.contains("FeOt")==False)):
raise ValueError("No FeOt column found. You've got a column heading with FeOT. Change to a lower case t")

my_input_c=my_input_c.add_suffix(suffix)

if any(my_input.columns.str.contains("FeO_")) and (all(my_input.columns.str.contains("FeOt_")==False)):
raise ValueError("No FeOt found. You've got a column heading with FeO. To avoid errors based on common EPMA outputs"
" thermobar only recognises columns with FeOt for all phases except liquid"
" where you can also enter a Fe3Fet_Liq heading used for equilibrium tests")

if any(my_input.columns.str.contains("Fe2O3_")) and (all(my_input.columns.str.contains("FeOt_")==False)):
raise ValueError("No FeOt column found. You've got a column heading with Fe2O3. To avoid errors based on common EPMA outputs"
" thermobar only recognises columns with FeOt for all phases except liquid"
" where you can also enter a Fe3Fet_Liq heading used for equilibrium tests")

if any(my_input.columns.str.contains("FeOT_")) and (all(my_input.columns.str.contains("FeOt_")==False)):
raise ValueError("No FeOt column found. You've got a column heading with FeOT. Change to a lower case t")



myLiquids1 = my_input_c.reindex(df_ideal_liq.columns, axis=1).fillna(0)
myLiquids1 = myLiquids1.apply(pd.to_numeric, errors='coerce').fillna(0)
myLiquids1[myLiquids1 < 0] = 0
print('We have replaced all missing liquid oxides and strings with zeros. ')

cols2=myLiquids1.columns
#my_input_c=my_input.copy()
for col in cols2:
if col in my_input_c.columns:
my_input_c=my_input_c.drop(columns=col)

out=pd.concat([myLiquids1, my_input_c], axis=1)
return out





def import_data(filename, sheet_name=None, Petrolog=False, MELTS=False, MELTS_txt=False, suffix=None):
""" This function takes a user input, and reforms the columns into the format required by PySulfSat,
In many cases this involves renaming columns to get into the format SiO2_Liq, TiO2_Liq, etc
Expand All @@ -21,6 +88,7 @@ def import_data(filename, sheet_name=None, Petrolog=False, MELTS=False, MELTS_tx
filename: str
File name (e.g. 'Test1.xlsx')
Petrolog: bool
True if output from Petrolog3 software, False (default) if not
Expand Down Expand Up @@ -151,6 +219,8 @@ def import_data(filename, sheet_name=None, Petrolog=False, MELTS=False, MELTS_tx
#my_input[my_input < 0] = 0




if suffix is not None:
if any(my_input.columns.str.contains(suffix)):
w.warn('We notice you have specified a suffix, but some of your columns already have this suffix. '
Expand Down
2 changes: 1 addition & 1 deletion src/PySulfSat/mantle_melting.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def Lee_Wieser_sulfide_melting(*, M_Max=0.01, Modes, KDs,
if isinstance(S_Melt_SCSS_2_ppm, float) or isinstance(S_Melt_SCSS_2_ppm, int):
S_Melt_SCSS_2_ppm=np.repeat(S_Melt_SCSS_2_ppm, len(M))

S_Melt = S_Melt_SCSS_2_ppm/(1+Prop_S6)
S_Melt = S_Melt_SCSS_2_ppm/(1-Prop_S6) # Was wrong in previous version.

# Setting up variables to be filled in loop
#These ones have only 1 dimension for different M steps, as they do not vary with different mantle S contents
Expand Down

0 comments on commit fa9e86d

Please sign in to comment.