DiadFit 0.0.85__py3-none-any.whl → 0.0.88__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- DiadFit/CO2_EOS.py +2 -2
- DiadFit/CO2_H2O_EOS.py +8 -8
- DiadFit/CO2_in_bubble_error.py +190 -112
- DiadFit/Highrho_polyfit_dataUCB_1117_1400.pkl +0 -0
- DiadFit/Highrho_polyfit_dataUCB_1117_1447.pkl +0 -0
- DiadFit/Highrho_polyfit_dataUCB_1220_1400.pkl +0 -0
- DiadFit/Highrho_polyfit_dataUCB_1220_1447.pkl +0 -0
- DiadFit/Highrho_polyfit_dataUCB_1220_1567.pkl +0 -0
- DiadFit/Highrho_polyfit_data_CMASS_24C.pkl +0 -0
- DiadFit/Lowrho_polyfit_dataUCB_1117_1400.pkl +0 -0
- DiadFit/Lowrho_polyfit_dataUCB_1117_1447.pkl +0 -0
- DiadFit/Lowrho_polyfit_dataUCB_1220_1400.pkl +0 -0
- DiadFit/Lowrho_polyfit_dataUCB_1220_1447.pkl +0 -0
- DiadFit/Lowrho_polyfit_dataUCB_1220_1567.pkl +0 -0
- DiadFit/Lowrho_polyfit_data_CMASS_24C.pkl +0 -0
- DiadFit/Mediumrho_polyfit_dataUCB_1117_1400.pkl +0 -0
- DiadFit/Mediumrho_polyfit_dataUCB_1117_1447.pkl +0 -0
- DiadFit/Mediumrho_polyfit_dataUCB_1220_1400.pkl +0 -0
- DiadFit/Mediumrho_polyfit_dataUCB_1220_1447.pkl +0 -0
- DiadFit/Mediumrho_polyfit_dataUCB_1220_1567.pkl +0 -0
- DiadFit/_version.py +1 -1
- DiadFit/densimeter_fitting.py +7 -1
- DiadFit/densimeters.py +182 -40
- DiadFit/density_depth_crustal_profiles.py +37 -5
- DiadFit/diads.py +26 -13
- DiadFit/error_propagation.py +137 -226
- DiadFit/importing_data_files.py +81 -15
- DiadFit/ne_lines.py +51 -23
- {DiadFit-0.0.85.dist-info → DiadFit-0.0.88.dist-info}/METADATA +1 -1
- DiadFit-0.0.88.dist-info/RECORD +50 -0
- DiadFit-0.0.85.dist-info/RECORD +0 -42
- {DiadFit-0.0.85.dist-info → DiadFit-0.0.88.dist-info}/WHEEL +0 -0
- {DiadFit-0.0.85.dist-info → DiadFit-0.0.88.dist-info}/top_level.txt +0 -0
DiadFit/CO2_EOS.py
CHANGED
@@ -829,7 +829,7 @@ def calculate_SP19942(T_K, target_pressure_MPa):
|
|
829
829
|
target_p=np.array(target_pressure_MPa)
|
830
830
|
Density=calculate_Density_Sterner_Pitzer_1994(T_K=T_K, target_pressure_MPa=target_p)
|
831
831
|
else:
|
832
|
-
Density=np.
|
832
|
+
Density=np.zeros(len(target_pressure_MPa))
|
833
833
|
for i in range(0, len(target_pressure_MPa)):
|
834
834
|
Density[i]=calculate_Density_Sterner_Pitzer_1994(T_K=T_K, target_pressure_MPa=target_pressure_MPa[i])
|
835
835
|
return Density
|
@@ -860,7 +860,7 @@ def calculate_SP1994_Temp(CO2_dens_gcm3, target_pressure_MPa):
|
|
860
860
|
target_p=np.array(target_pressure_MPa)
|
861
861
|
Density=calculate_Temp_Sterner_Pitzer_1994(CO2_dens_gcm3=CO2_dens_gcm3, target_pressure_MPa=target_p)
|
862
862
|
else:
|
863
|
-
Density=np.
|
863
|
+
Density=np.zeros(len(target_pressure_MPa))
|
864
864
|
for i in range(0, len(target_pressure_MPa)):
|
865
865
|
Density[i]=calculate_Temp_Sterner_Pitzer_1994(CO2_dens_gcm3=CO2_dens_gcm3, target_pressure_MPa=target_pressure_MPa[i])
|
866
866
|
return Density
|
DiadFit/CO2_H2O_EOS.py
CHANGED
@@ -925,7 +925,7 @@ def calculate_molar_volume_DZ2006(*, P_kbar, T_K, XH2O):
|
|
925
925
|
raise ValueError("All input Pandas Series must have the same length.")
|
926
926
|
|
927
927
|
# Set up loop
|
928
|
-
mol_vol=np.
|
928
|
+
mol_vol=np.zeros(len(P_kbar), float)
|
929
929
|
|
930
930
|
for i in range(0, len(P_kbar)):
|
931
931
|
mol_vol[i]=calculate_molar_volume_ind_DZ2006(P_kbar=P_kbar.iloc[i].astype(float), T_K=T_K.iloc[i].astype(float), XH2O=XH2O.iloc[i].astype(float))
|
@@ -999,7 +999,7 @@ def calculate_Pressure_DZ2006(*, mol_vol=None, density=None, T_K, XH2O):
|
|
999
999
|
raise ValueError("All input Pandas Series must have the same length.")
|
1000
1000
|
|
1001
1001
|
# Set up loop
|
1002
|
-
P=np.
|
1002
|
+
P=np.zeros(len(mol_vol), float)
|
1003
1003
|
|
1004
1004
|
for i in range(0, len(mol_vol)):
|
1005
1005
|
P[i]=calculate_Pressure_ind_DZ2006(mol_vol=mol_vol.iloc[i].astype(float), T_K=T_K.iloc[i].astype(float), XH2O=XH2O.iloc[i].astype(float))
|
@@ -1025,12 +1025,12 @@ def mix_fugacity(*, P_kbar, T_K, XH2O, Vmix):
|
|
1025
1025
|
if len(set(lengths)) != 1:
|
1026
1026
|
raise ValueError("All input Pandas Series must have the same length.")
|
1027
1027
|
|
1028
|
-
f=np.
|
1029
|
-
a_CO2=np.
|
1030
|
-
a_H2O=np.
|
1031
|
-
f_CO2=np.
|
1032
|
-
f_H2O=np.
|
1033
|
-
Zmix=np.
|
1028
|
+
f=np.zeros(len(P_kbar), float)
|
1029
|
+
a_CO2=np.zeros(len(P_kbar), float)
|
1030
|
+
a_H2O=np.zeros(len(P_kbar), float)
|
1031
|
+
f_CO2=np.zeros(len(P_kbar), float)
|
1032
|
+
f_H2O=np.zeros(len(P_kbar), float)
|
1033
|
+
Zmix=np.zeros(len(P_kbar), float)
|
1034
1034
|
for i in range(0, len(P_kbar)):
|
1035
1035
|
|
1036
1036
|
f_H2O[i], f_CO2[i], a_H2O[i], a_CO2[i], Zmix[i]=mix_fugacity_ind(P_kbar=P_kbar.iloc[i].astype(float), T_K=T_K.iloc[i].astype(float), XH2O=XH2O.iloc[i].astype(float), Vmix=Vmix.iloc[i].astype(float))
|
DiadFit/CO2_in_bubble_error.py
CHANGED
@@ -2,10 +2,22 @@ import numpy as np
|
|
2
2
|
import pandas as pd
|
3
3
|
import matplotlib.pyplot as plt
|
4
4
|
|
5
|
+
# Lets use a generic function for getting a panda series value or not.
|
6
|
+
|
7
|
+
def get_value(variable, i):
|
8
|
+
""" This function returns the value if its not a series, otherwise returns the right row in the series
|
9
|
+
"""
|
10
|
+
if isinstance(variable, pd.Series):
|
11
|
+
return variable.iloc[i]
|
12
|
+
else:
|
13
|
+
return variable
|
14
|
+
|
15
|
+
const=(4/3)*np.pi
|
5
16
|
|
6
17
|
def propagate_CO2_in_bubble(*, N_dup=1000, sample_ID, vol_perc_bub=None, error_vol_perc_bub=None, error_type_vol_perc_bub='Abs',
|
7
18
|
MI_x=None, MI_y=None,MI_z=None,VB_x=None, VB_y=None,VB_z=None,
|
8
|
-
|
19
|
+
error_MI_x=None, error_MI_y=None,error_MI_z=None,error_VB_x=None, error_VB_y=None, error_VB_z=None,
|
20
|
+
error_type_dimension='Abs', error_dist_dimension='normal',
|
9
21
|
melt_dens_kgm3, CO2_bub_dens_gcm3,
|
10
22
|
error_dist_vol_perc_bub='normal',
|
11
23
|
error_CO2_bub_dens_gcm3=0, error_type_CO2_bub_dens_gcm3='Abs', error_dist_CO2_bub_dens_gcm3='normal',
|
@@ -45,7 +57,11 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
45
57
|
error_MI_x, error_MI_y, error_MI_Z, error_VB_x, error_VB_y, error_VB_Z: int, float, pd.Series
|
46
58
|
Error on x, y, z dimension meausurement
|
47
59
|
|
60
|
+
error_type_dimension: 'Abs' or 'Perc'
|
61
|
+
Whether errors on all x-y-z are perc or abs
|
48
62
|
|
63
|
+
error_dist_dimension: 'normal' or 'uniform'
|
64
|
+
Whether errors on all x-y-z are normally or uniformly distributed.
|
49
65
|
|
50
66
|
|
51
67
|
melt_dens_kgm3:int, float, pd.series
|
@@ -73,17 +89,21 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
73
89
|
|
74
90
|
"""
|
75
91
|
# Constant for sphere calcs
|
76
|
-
|
77
|
-
# Lets check what they entered for volume
|
92
|
+
|
93
|
+
# Lets check what they entered for volume - if they didnt enter a volume % Bubble, lets calculate it
|
78
94
|
if vol_perc_bub is None:
|
79
95
|
Vol_VB_sphere=const*VB_x*VB_y*VB_z
|
80
96
|
Vol_MI_sphere=const*MI_x*MI_y*MI_z
|
81
|
-
|
82
|
-
|
83
|
-
|
97
|
+
vol_perc_bub=100* Vol_VB_sphere/Vol_MI_sphere
|
98
|
+
|
99
|
+
# Now lets check how they entered error in volume
|
100
|
+
if not ((error_vol_perc_bub is not None and all(v is None for v in [error_MI_x, error_MI_y, error_MI_z, error_VB_x, error_VB_y, error_VB_z])) or (error_vol_perc_bub is None and all(v is not None for v in [error_MI_x, error_MI_y, error_MI_z, error_VB_x, error_VB_y, error_VB_z]))):
|
101
|
+
raise ValueError('Specify either error_vol_perc_bub or non-None values for all of error_MI_x, error_MI_y, error_MI_z, error_VB_x, error_VB_y, and error_VB_z.')
|
84
102
|
|
85
|
-
# Set up empty things to fill up.
|
86
103
|
|
104
|
+
|
105
|
+
|
106
|
+
# Set up empty things to fill up.
|
87
107
|
if type(vol_perc_bub) is pd.Series:
|
88
108
|
len_loop=len(vol_perc_bub)
|
89
109
|
|
@@ -92,18 +112,22 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
92
112
|
|
93
113
|
|
94
114
|
|
95
|
-
mean_CO2_eq_melt = np.
|
96
|
-
mean_CO2_eq_melt_ind = np.
|
97
|
-
med_CO2_eq_melt = np.
|
98
|
-
std_CO2_eq_melt = np.
|
99
|
-
preferred_val_CO2_melt= np.
|
100
|
-
std_IQR_CO2_eq_melt= np.
|
101
|
-
|
115
|
+
mean_CO2_eq_melt = np.zeros(len_loop, dtype=float)
|
116
|
+
mean_CO2_eq_melt_ind = np.zeros(len_loop, dtype=float)
|
117
|
+
med_CO2_eq_melt = np.zeros(len_loop, dtype=float)
|
118
|
+
std_CO2_eq_melt = np.zeros(len_loop, dtype=float)
|
119
|
+
preferred_val_CO2_melt= np.zeros(len_loop, dtype=float)
|
120
|
+
std_IQR_CO2_eq_melt= np.zeros(len_loop, dtype=float)
|
121
|
+
Q84= np.zeros(len_loop, dtype=float)
|
122
|
+
Q16= np.zeros(len_loop, dtype=float)
|
123
|
+
Sample=np.zeros(len_loop, dtype=np.dtype('U100') )
|
102
124
|
|
103
125
|
|
104
126
|
All_outputs=pd.DataFrame([])
|
105
127
|
|
106
128
|
|
129
|
+
|
130
|
+
|
107
131
|
#This loops through each sample
|
108
132
|
for i in range(0, len_loop):
|
109
133
|
if i % 20 == 0:
|
@@ -113,67 +137,76 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
113
137
|
# If user has entered a pandas series for error, takes right one for each loop
|
114
138
|
# vol_perc_bub % and error
|
115
139
|
|
116
|
-
# Checking volume right format
|
117
|
-
|
118
|
-
|
119
|
-
else:
|
120
|
-
vol_perc_bub_i=vol_perc_bub
|
121
|
-
|
140
|
+
# Checking volume right format, if panda series or integer
|
141
|
+
vol_perc_bub_i=get_value(vol_perc_bub, i)
|
142
|
+
error_vol_perc_bub_i=get_value(error_vol_perc_bub, i)
|
122
143
|
|
123
|
-
|
124
|
-
|
125
|
-
else:
|
126
|
-
error_vol_perc_bub_i=error_vol_perc_bub
|
127
|
-
|
128
|
-
# Checking bubble dens right form
|
144
|
+
CO2_bub_dens_gcm3_i=get_value(CO2_bub_dens_gcm3, i)
|
145
|
+
error_CO2_bub_dens_gcm3_i=get_value(error_CO2_bub_dens_gcm3, i)
|
129
146
|
|
130
|
-
|
131
|
-
|
132
|
-
else:
|
133
|
-
CO2_bub_dens_gcm3_i=CO2_bub_dens_gcm3
|
147
|
+
melt_dens_kgm3_i=get_value(melt_dens_kgm3, i)
|
148
|
+
error_melt_dens_kgm3_i=get_value(error_melt_dens_kgm3, i)
|
134
149
|
|
135
|
-
# Checking melt density
|
136
150
|
|
137
|
-
if type(error_CO2_bub_dens_gcm3) is pd.Series:
|
138
|
-
error_CO2_bub_dens_gcm3_i=error_CO2_bub_dens_gcm3.iloc[i]
|
139
|
-
else:
|
140
|
-
error_CO2_bub_dens_gcm3_i=error_CO2_bub_dens_gcm3
|
141
151
|
|
142
|
-
# Checking melt density
|
143
152
|
|
153
|
+
# This is the function doing the work to actually make the simulations for each variable.
|
154
|
+
if error_vol_perc_bub is not None:
|
155
|
+
|
156
|
+
df_synthetic=propagate_CO2_in_bubble_ind(
|
157
|
+
N_dup=N_dup,
|
158
|
+
vol_perc_bub=vol_perc_bub_i,
|
159
|
+
melt_dens_kgm3=melt_dens_kgm3_i,
|
160
|
+
CO2_bub_dens_gcm3=CO2_bub_dens_gcm3_i,
|
161
|
+
error_CO2_bub_dens_gcm3=error_CO2_bub_dens_gcm3_i,
|
162
|
+
error_type_CO2_bub_dens_gcm3=error_type_CO2_bub_dens_gcm3,
|
163
|
+
error_dist_CO2_bub_dens_gcm3=error_dist_CO2_bub_dens_gcm3,
|
164
|
+
error_vol_perc_bub=error_vol_perc_bub_i,
|
165
|
+
error_type_vol_perc_bub=error_type_vol_perc_bub,
|
166
|
+
error_dist_vol_perc_bub=error_dist_vol_perc_bub,
|
167
|
+
error_melt_dens_kgm3=error_melt_dens_kgm3_i,
|
168
|
+
error_type_melt_dens_kgm3=error_type_melt_dens_kgm3,
|
169
|
+
error_dist_melt_dens_kgm3=error_dist_melt_dens_kgm3,
|
170
|
+
len_loop=1, neg_values=neg_values)
|
144
171
|
|
145
|
-
if type(melt_dens_kgm3) is pd.Series:
|
146
|
-
melt_dens_kgm3_i=melt_dens_kgm3.iloc[i]
|
147
172
|
else:
|
148
|
-
melt_dens_kgm3_i=melt_dens_kgm3
|
149
|
-
|
150
173
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
174
|
+
# This is the more complex one where we have to account for x-y-z errors on all of them.
|
175
|
+
MI_x_i = get_value(MI_x, i)
|
176
|
+
MI_y_i = get_value(MI_y, i)
|
177
|
+
MI_z_i = get_value(MI_z, i)
|
178
|
+
VB_x_i = get_value(VB_x, i)
|
179
|
+
VB_y_i = get_value(VB_y, i)
|
180
|
+
VB_z_i = get_value(VB_z, i)
|
155
181
|
|
182
|
+
error_MI_x_i = get_value(error_MI_x, i)
|
183
|
+
error_MI_y_i = get_value(error_MI_y, i)
|
184
|
+
error_MI_z_i = get_value(error_MI_z, i)
|
185
|
+
error_VB_x_i = get_value(error_VB_x, i)
|
186
|
+
error_VB_y_i = get_value(error_VB_y, i)
|
187
|
+
error_VB_z_i = get_value(error_VB_z, i)
|
156
188
|
|
157
189
|
|
158
190
|
|
191
|
+
df_synthetic=propagate_CO2_in_bubble_ind(
|
192
|
+
N_dup=N_dup,
|
193
|
+
vol_perc_bub=vol_perc_bub_i,
|
194
|
+
melt_dens_kgm3=melt_dens_kgm3_i,
|
195
|
+
CO2_bub_dens_gcm3=CO2_bub_dens_gcm3_i,
|
196
|
+
error_CO2_bub_dens_gcm3=error_CO2_bub_dens_gcm3_i,
|
197
|
+
error_type_CO2_bub_dens_gcm3=error_type_CO2_bub_dens_gcm3,
|
198
|
+
error_dist_CO2_bub_dens_gcm3=error_dist_CO2_bub_dens_gcm3,
|
199
|
+
error_vol_perc_bub=None,
|
200
|
+
MI_x=MI_x_i, MI_y=MI_y_i,MI_z=MI_z_i,VB_x=VB_x_i, VB_y=VB_y_i,VB_z=VB_z_i,
|
201
|
+
error_MI_x=error_MI_x_i, error_MI_y=error_MI_y_i,error_MI_z=error_MI_z_i,
|
202
|
+
error_VB_x=error_VB_x_i, error_VB_y=error_VB_y_i, error_VB_z=error_VB_z_i,
|
203
|
+
error_type_dimension=error_type_dimension, error_dist_dimension=error_dist_dimension,
|
204
|
+
error_melt_dens_kgm3=error_melt_dens_kgm3_i,
|
205
|
+
error_type_melt_dens_kgm3=error_type_melt_dens_kgm3,
|
206
|
+
error_dist_melt_dens_kgm3=error_dist_melt_dens_kgm3,
|
207
|
+
len_loop=1, neg_values=neg_values)
|
159
208
|
|
160
209
|
|
161
|
-
# This is the function doing the work to actually make the simulations for each variable.
|
162
|
-
df_synthetic=propagate_CO2_in_bubble_ind(
|
163
|
-
N_dup=N_dup,
|
164
|
-
vol_perc_bub=vol_perc_bub_i,
|
165
|
-
melt_dens_kgm3=melt_dens_kgm3_i,
|
166
|
-
CO2_bub_dens_gcm3=CO2_bub_dens_gcm3_i,
|
167
|
-
error_CO2_bub_dens_gcm3=error_CO2_bub_dens_gcm3_i,
|
168
|
-
error_type_CO2_bub_dens_gcm3=error_type_CO2_bub_dens_gcm3,
|
169
|
-
error_dist_CO2_bub_dens_gcm3=error_dist_CO2_bub_dens_gcm3,
|
170
|
-
error_vol_perc_bub=error_vol_perc_bub_i,
|
171
|
-
error_type_vol_perc_bub=error_type_vol_perc_bub,
|
172
|
-
error_dist_vol_perc_bub=error_dist_vol_perc_bub,
|
173
|
-
error_melt_dens_kgm3=error_melt_dens_kgm3_i,
|
174
|
-
error_type_melt_dens_kgm3=error_type_melt_dens_kgm3,
|
175
|
-
error_dist_melt_dens_kgm3=error_dist_melt_dens_kgm3,
|
176
|
-
len_loop=1, neg_values=neg_values)
|
177
210
|
|
178
211
|
|
179
212
|
# Convert to densities for MC
|
@@ -210,12 +243,16 @@ error_dist_melt_dens_kgm3=error_dist_melt_dens_kgm3,
|
|
210
243
|
med_CO2_eq_melt[i]=np.nanmedian(df['CO2_eq_melt_ppm_MC'])
|
211
244
|
std_CO2_eq_melt[i]=np.nanstd(df['CO2_eq_melt_ppm_MC'])
|
212
245
|
var=df['CO2_eq_melt_ppm_MC']
|
246
|
+
Q16[i]=np.percentile(var, 16)
|
247
|
+
Q84[i]=np.percentile(var, 84)
|
213
248
|
std_IQR_CO2_eq_melt[i]=0.5*np.abs((np.percentile(var, 84) -np.percentile(var, 16)))
|
214
249
|
|
215
|
-
preferred_val_CO2_melt[i]=np.nanmean(df['CO2_eq_melt_ppm_noMC'])
|
216
250
|
|
217
251
|
|
218
|
-
|
252
|
+
# Values all the same, so can just take the 1st.
|
253
|
+
preferred_val_CO2_melt[i]=df['CO2_eq_melt_ppm_noMC'].iloc[0]
|
254
|
+
|
255
|
+
|
219
256
|
|
220
257
|
|
221
258
|
|
@@ -226,7 +263,9 @@ error_dist_melt_dens_kgm3=error_dist_melt_dens_kgm3,
|
|
226
263
|
'CO2_eq_in_melt_noMC': preferred_val_CO2_melt,
|
227
264
|
'mean_MC_CO2_equiv_melt_ppm': mean_CO2_eq_melt,
|
228
265
|
'med_MC_CO2_equiv_melt_ppm': med_CO2_eq_melt,
|
229
|
-
'
|
266
|
+
'std_MC_IQR_CO2_equiv_melt_ppm': std_IQR_CO2_eq_melt,
|
267
|
+
'16th_quantile_melt_ppm': Q16,
|
268
|
+
'84th_quantile_melt_ppm': Q84,
|
230
269
|
|
231
270
|
|
232
271
|
|
@@ -262,12 +301,43 @@ error_dist_melt_dens_kgm3=error_dist_melt_dens_kgm3,
|
|
262
301
|
|
263
302
|
|
264
303
|
|
304
|
+
def add_noise_to_variable(original_value, error, error_type, error_dist, N_dup, neg_values, neg_threshold):
|
305
|
+
""" This function adds noise to each variable for the monte-carloing
|
306
|
+
|
307
|
+
"""
|
308
|
+
|
309
|
+
# Depending on the error type, allocates an error
|
310
|
+
if error_type == 'Abs':
|
311
|
+
calculated_error = error
|
312
|
+
elif error_type == 'Perc':
|
313
|
+
calculated_error = original_value * error / 100
|
314
|
+
|
315
|
+
# Generates noise following a distribution
|
316
|
+
if error_dist == 'normal':
|
317
|
+
noise_to_add = np.random.normal(0, calculated_error, N_dup)
|
318
|
+
elif error_dist == 'uniform':
|
319
|
+
noise_to_add = np.random.uniform(-calculated_error, calculated_error, N_dup)
|
320
|
+
|
321
|
+
# adds this noise to original value
|
322
|
+
value_with_noise = noise_to_add + original_value
|
323
|
+
|
324
|
+
if not neg_values:
|
325
|
+
value_with_noise[value_with_noise < neg_threshold] = neg_threshold
|
326
|
+
|
327
|
+
return value_with_noise
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
265
332
|
|
266
333
|
|
267
334
|
|
268
335
|
def propagate_CO2_in_bubble_ind(sample_i=0, N_dup=1000, vol_perc_bub=None,
|
269
336
|
CO2_bub_dens_gcm3=None, melt_dens_kgm3=None,
|
270
|
-
|
337
|
+
MI_x=None, MI_y=None,MI_z=None,VB_x=None, VB_y=None,VB_z=None,
|
338
|
+
error_MI_x=None, error_MI_y=None,error_MI_z=None,error_VB_x=None, error_VB_y=None, error_VB_z=None,
|
339
|
+
error_type_dimension='Abs', error_dist_dimension='normal',
|
340
|
+
error_vol_perc_bub=None, error_type_vol_perc_bub='Abs', error_dist_vol_perc_bub='normal',
|
271
341
|
error_CO2_bub_dens_gcm3=0, error_type_CO2_bub_dens_gcm3='Abs', error_dist_CO2_bub_dens_gcm3='normal',
|
272
342
|
error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kgm3='normal', len_loop=1, neg_values=True):
|
273
343
|
|
@@ -324,7 +394,7 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
324
394
|
|
325
395
|
"""
|
326
396
|
|
327
|
-
|
397
|
+
# If only a single sample, set up an output dataframe with an index.
|
328
398
|
if len_loop==1:
|
329
399
|
df_c=pd.DataFrame(data={
|
330
400
|
'vol_perc_bub': vol_perc_bub,
|
@@ -340,64 +410,56 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
340
410
|
|
341
411
|
|
342
412
|
|
343
|
-
# Volume error distribution
|
413
|
+
# Volume error distribution - if they give a volume percentage rather than dimensions
|
414
|
+
if error_vol_perc_bub is not None:
|
415
|
+
# Easy peasy
|
416
|
+
Vol_with_noise=add_noise_to_variable(vol_perc_bub, error_vol_perc_bub,
|
417
|
+
error_type_vol_perc_bub, error_dist_vol_perc_bub, N_dup, neg_values, neg_threshold=0.0000000001)
|
344
418
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
error_Vol=df_c['vol_perc_bub'].iloc[sample_i]*error_vol_perc_bub/100
|
349
|
-
if error_dist_vol_perc_bub=='normal':
|
350
|
-
Noise_to_add_Vol = np.random.normal(0, error_Vol, N_dup)
|
351
|
-
if error_dist_vol_perc_bub=='uniform':
|
352
|
-
Noise_to_add_Vol = np.random.uniform(- error_Vol, +
|
353
|
-
error_Vol, N_dup)
|
419
|
+
else:
|
420
|
+
x_MI_with_noise=add_noise_to_variable(MI_x, error_MI_x,
|
421
|
+
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
354
422
|
|
355
|
-
|
356
|
-
|
357
|
-
Vol_with_noise[Vol_with_noise < 0.000000000000001] = 0.000000000000001
|
423
|
+
y_MI_with_noise=add_noise_to_variable(MI_y, error_MI_y,
|
424
|
+
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
358
425
|
|
359
|
-
|
426
|
+
z_MI_with_noise=add_noise_to_variable(MI_z, error_MI_z,
|
427
|
+
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
360
428
|
|
361
|
-
|
429
|
+
x_VB_with_noise=add_noise_to_variable(VB_x, error_VB_x,
|
430
|
+
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
362
431
|
|
363
|
-
|
364
|
-
|
365
|
-
if error_type_CO2_bub_dens_gcm3 =='Perc':
|
366
|
-
error_CO2_bub_dens_gcm3=df_c['vol_perc_bub'].iloc[sample_i]*error_CO2_bub_dens_gcm3/100
|
367
|
-
if error_dist_CO2_bub_dens_gcm3=='normal':
|
368
|
-
Noise_to_add_CO2_bub_dens_gcm3 = np.random.normal(0, error_CO2_bub_dens_gcm3, N_dup)
|
369
|
-
if error_dist_CO2_bub_dens_gcm3=='uniform':
|
370
|
-
Noise_to_add_CO2_bub_dens_gcm3 = np.random.uniform(- error_CO2_bub_dens_gcm3, +
|
371
|
-
error_CO2_bub_dens_gcm3, N_dup)
|
432
|
+
y_VB_with_noise=add_noise_to_variable(VB_y, error_VB_y,
|
433
|
+
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
372
434
|
|
373
|
-
|
374
|
-
|
375
|
-
CO2_bub_dens_gcm3_with_noise[CO2_bub_dens_gcm3_with_noise < 0.000000000000001] = 0.000000000000001
|
435
|
+
z_VB_with_noise=add_noise_to_variable(VB_z, error_VB_z,
|
436
|
+
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
376
437
|
|
377
|
-
# Volume error distribution
|
378
438
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
error_melt_dens_kgm3=df_c['vol_perc_bub'].iloc[sample_i]*error_melt_dens_kgm3/100
|
383
|
-
if error_dist_melt_dens_kgm3=='normal':
|
384
|
-
Noise_to_add_melt_dens_kgm3 = np.random.normal(0, error_melt_dens_kgm3, N_dup)
|
385
|
-
if error_dist_melt_dens_kgm3=='uniform':
|
386
|
-
Noise_to_add_melt_dens_kgm3 = np.random.uniform(- error_melt_dens_kgm3, +
|
387
|
-
error_melt_dens_kgm3, N_dup)
|
439
|
+
Vol_VB_sphere_with_noise=const*x_VB_with_noise*y_VB_with_noise*z_VB_with_noise
|
440
|
+
Vol_MI_sphere_with_noise=const*x_MI_with_noise*y_MI_with_noise*z_MI_with_noise
|
441
|
+
Vol_with_noise=100* Vol_VB_sphere_with_noise/Vol_MI_sphere_with_noise
|
388
442
|
|
389
|
-
|
390
|
-
|
391
|
-
|
443
|
+
|
444
|
+
# Bubble density
|
445
|
+
CO2_bub_dens_gcm3_with_noise=add_noise_to_variable(CO2_bub_dens_gcm3, error_CO2_bub_dens_gcm3,
|
446
|
+
error_type_CO2_bub_dens_gcm3, error_dist_CO2_bub_dens_gcm3, N_dup, neg_values, neg_threshold=0.0000000001)
|
447
|
+
|
448
|
+
# Melt density
|
449
|
+
melt_dens_kgm3_with_noise=add_noise_to_variable(melt_dens_kgm3, error_melt_dens_kgm3,
|
450
|
+
error_type_melt_dens_kgm3, error_dist_melt_dens_kgm3, N_dup, neg_values, neg_threshold=0.0000000001)
|
451
|
+
|
452
|
+
# Now lets calculate the equilibrium CO2 content of the melt
|
392
453
|
CO2_eq_melt_ind=10**4 * (df_c['vol_perc_bub']*df_c['CO2_bub_dens_gcm3'])/(df_c['melt_dens_kgm3']/1000)
|
393
|
-
|
454
|
+
|
455
|
+
if error_vol_perc_bub is not None:
|
456
|
+
df_out=pd.DataFrame(data={
|
394
457
|
|
395
458
|
'vol_perc_bub_with_noise': Vol_with_noise,
|
396
459
|
'CO2_bub_dens_gcm3_with_noise': CO2_bub_dens_gcm3_with_noise,
|
397
460
|
'melt_dens_kgm3_with_noise': melt_dens_kgm3_with_noise,
|
398
461
|
'vol_perc_bub': df_c['vol_perc_bub'].iloc[sample_i],
|
399
462
|
'CO2_bub_dens_gcm3': CO2_bub_dens_gcm3,
|
400
|
-
'Absolute_error_Vol': error_Vol,
|
401
463
|
'error_type_vol_perc_bub': error_type_vol_perc_bub,
|
402
464
|
'error_dist_Vol': error_dist_vol_perc_bub,
|
403
465
|
'error_CO2_bub_dens_gcm3': error_CO2_bub_dens_gcm3,
|
@@ -405,6 +467,27 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
405
467
|
'error_dist_CO2_bub_dens_gcm3': error_dist_CO2_bub_dens_gcm3,
|
406
468
|
})
|
407
469
|
|
470
|
+
else:
|
471
|
+
df_out=pd.DataFrame(data={
|
472
|
+
|
473
|
+
'vol_perc_bub_with_noise': Vol_with_noise,
|
474
|
+
'CO2_bub_dens_gcm3_with_noise': CO2_bub_dens_gcm3_with_noise,
|
475
|
+
'melt_dens_kgm3_with_noise': melt_dens_kgm3_with_noise,
|
476
|
+
'vol_perc_bub': df_c['vol_perc_bub'].iloc[sample_i],
|
477
|
+
'CO2_bub_dens_gcm3': CO2_bub_dens_gcm3,
|
478
|
+
'error_CO2_bub_dens_gcm3': error_CO2_bub_dens_gcm3,
|
479
|
+
'error_type_CO2_bub_dens_gcm3': error_type_CO2_bub_dens_gcm3,
|
480
|
+
'error_dist_CO2_bub_dens_gcm3': error_dist_CO2_bub_dens_gcm3,
|
481
|
+
'Vol_VB_with_noise': Vol_VB_sphere_with_noise,
|
482
|
+
'Vol_MI_with_noise': Vol_MI_sphere_with_noise,
|
483
|
+
'VB_x_with_noise': x_VB_with_noise,
|
484
|
+
'VB_y_with_noise':y_VB_with_noise,
|
485
|
+
'VB_z_with_noise': z_VB_with_noise,
|
486
|
+
'MI_x_with_noise': x_MI_with_noise,
|
487
|
+
'MI_y_with_noise': y_MI_with_noise,
|
488
|
+
'MI_z_with_noise': z_MI_with_noise,
|
489
|
+
})
|
490
|
+
|
408
491
|
CO2_eq_melt=10**4*((df_out['vol_perc_bub_with_noise']*df_out['CO2_bub_dens_gcm3_with_noise']))/(df_out['melt_dens_kgm3_with_noise']/1000)
|
409
492
|
|
410
493
|
df_out.insert(0, 'CO2_eq_melt_ppm_MC',CO2_eq_melt)
|
@@ -412,10 +495,5 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
412
495
|
df_out.insert(1, 'CO2_eq_melt_ppm_noMC',float(CO2_eq_melt_ind.values))
|
413
496
|
|
414
497
|
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
498
|
return df_out
|
421
499
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
DiadFit/_version.py
CHANGED
DiadFit/densimeter_fitting.py
CHANGED
@@ -113,7 +113,7 @@ def plot_and_save_CO2cali_pickle(*, cali_data, CO2_dens_col='rho',Split_col='Spl
|
|
113
113
|
Whether to save the plot as an image (default: False).
|
114
114
|
|
115
115
|
eq_division (str, optional):
|
116
|
-
Method for dividing the data based on density ('ccmr' or '
|
116
|
+
Method for dividing the data based on density ('ccmr', 'cmass', or 'cmass_24C', default: 'ccmr'). CCMR corresponds to the limits for each section as shown in DeVitre et al., 2021 (Chem. Geo), cmass is for those in DeVitre et al., 2023 (J. Volcanica).
|
117
117
|
|
118
118
|
save_suffix (str, optional):
|
119
119
|
Suffix to be added to the saved file names (default: '').
|
@@ -134,6 +134,12 @@ def plot_and_save_CO2cali_pickle(*, cali_data, CO2_dens_col='rho',Split_col='Spl
|
|
134
134
|
midcut_low=0.13
|
135
135
|
midcut_high=0.70
|
136
136
|
highcut=0.65
|
137
|
+
|
138
|
+
elif eq_division=='cmass_24C':
|
139
|
+
lowcut=0.24
|
140
|
+
midcut_low=0.24
|
141
|
+
midcut_high=0.65
|
142
|
+
highcut=0.65
|
137
143
|
if density_range == 'Low':
|
138
144
|
cali_data = cali_data[cali_data[CO2_dens_col] < lowcut]
|
139
145
|
|