Skip to content

Commit

Permalink
Further tweaked MC stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
PennyWieser committed Mar 13, 2023
1 parent 5cd7812 commit 0e157c4
Show file tree
Hide file tree
Showing 12 changed files with 7,201 additions and 7 deletions.
2,810 changes: 2,810 additions & 0 deletions docs/Examples/S6St_Testing/CalcS6ST_Muth.ipynb

Large diffs are not rendered by default.

4,302 changes: 4,302 additions & 0 deletions docs/Examples/S6St_Testing/Merge_Muth_Supplements.ipynb

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Examples/S6St_Testing/Muth_2021_EPMA.xlsx
Binary file not shown.
Binary file not shown.
Binary file added docs/Examples/S6St_Testing/Muth_data_Merged.xlsx
Binary file not shown.
Binary file added docs/Examples/S6St_Testing/Muth_outputs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Welcome to PySulfSat's documentation!

youtube

%

.. toctree::
:maxdepth: 2
:caption: Data Input Options
Expand Down Expand Up @@ -74,6 +76,7 @@ Welcome to PySulfSat's documentation!

Examples/S6_S2_Corrections/S6_S2_Corrections_Nash_Jugo_Kleinsasser
Examples/S6_S2_Corrections/CS6_S6ST_Correction
Examples/S6St_Testing/CalcS6ST_Muth

%

Expand Down
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__ = '0.0.12'
__version__ = '0.0.13'

26 changes: 21 additions & 5 deletions src/PySulfSat/error_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

from PySulfSat.core_calcs import *



def add_noise_1var(var, error_var,
error_type="Abs", error_dist="normal", N_dup=1000, sample_i=0):
error_type="Abs", error_dist="normal", N_dup=1000, sample_i=0, df_values=None):

""" Takes 1 row of pd series or a float, returns 1000 duplicates following specified error position
"""
Expand Down Expand Up @@ -39,9 +41,12 @@ def add_noise_1var(var, error_var,

var_with_noise=Noise_to_add_var+df_c['var'].iloc[sample_i]



return var_with_noise

def add_noise_series(var, error_var, error_type="Abs", error_dist="normal", N_dup=1000, Sample_ID=None, no_noise=False):

def add_noise_series(var, error_var, error_type="Abs", error_dist="normal", N_dup=1000, Sample_ID=None, no_noise=False, df_values=None):



Expand Down Expand Up @@ -98,11 +103,19 @@ def add_noise_series(var, error_var, error_type="Abs", error_dist="normal", N_d

return All_outputs

def duplicate_dataframe(df, N_dup=1000):
df_values=df
Dupdf = pd.DataFrame(np.repeat(df_values.values,
N_dup, axis=0))
Dupdf.columns = df_values.columns

return Dupdf

def add_noise_2_dataframes(df_values, df_noise,
error_type="Abs", error_dist="normal", N_dups=10):

df1=df_values
df2=df_noise
df1=df_values.copy()
df2=df_noise.copy()

#def create_noise_2df(df1, df2, error_type="Abs", error_dist="normal", N_dup=3):

Expand Down Expand Up @@ -138,7 +151,10 @@ def add_noise_2_dataframes(df_values, df_noise,
df_noisy

# Get sample names
s=df1['Sample_ID']
if 'Sample_ID' in df1.columns:
s=df1['Sample_ID']
else:
s=df1.index
s_repeated = pd.Series(np.repeat(s.values, N_dups))

# Tile the repeated values to get the end-on-end repetition
Expand Down
61 changes: 61 additions & 0 deletions src/PySulfSat/import_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,64 @@ def import_data(filename, sheet_name=None, Petrolog=False, MELTS=False, sample_l
return out



df_ideal_liq_noise = pd.DataFrame(columns=['SiO2_Liq_Err', 'TiO2_Liq_Err', 'Al2O3_Liq_Err',
'FeOt_Liq_Err', 'MnO_Liq_Err', 'MgO_Liq_Err', 'CaO_Liq_Err', 'Na2O_Liq_Err', 'K2O_Liq_Err',
'P2O5_Liq_Err', 'H2O_Liq_Err', 'Fe3Fet_Liq_Err', 'Ni_Liq_ppm_Err', 'Cu_Liq_ppm_Err'])

def import_data_noise(filename, sheet_name=None, sample_label=None):

if 'csv' in filename:
my_input = pd.read_csv(filename)




if 'xls' in filename:
if sheet_name is not None:
my_input = pd.read_excel(filename, sheet_name=sheet_name)
#my_input[my_input < 0] = 0
else:
my_input = pd.read_excel(filename)
#my_input[my_input < 0] = 0



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 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_noise.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



4 changes: 3 additions & 1 deletion src/PySulfSat/s6_corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def calculate_S6St_Nash2019(T_K, Fe3Fet_Liq):
'''
# First, calculate Fe3/Fe2 from Fe3/Fet
Fe3Fe2=Fe3Fet_Liq/(1-Fe3Fet_Liq)
log_Fe3Fe2=np.log10(Fe3Fe2)
#print(Fe3Fe2)
log_Fe3Fe2=np.log10(Fe3Fe2.astype(float))


log_S6S2=8*log_Fe3Fe2 + 8.7436*10**6/(T_K**2) - 27703/T_K + 20.273
S6S2=10**(log_S6S2)
Expand Down

0 comments on commit 0e157c4

Please sign in to comment.