DiadFit 0.0.84__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 +173 -90
- DiadFit/CO2_in_bubble_error.py +217 -115
- 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 +85 -48
- DiadFit/error_propagation.py +141 -229
- DiadFit/importing_data_files.py +81 -15
- DiadFit/lookup_table.csv +64001 -0
- DiadFit/lookup_table_noneg.csv +63707 -0
- DiadFit/ne_lines.py +58 -29
- {DiadFit-0.0.84.dist-info → DiadFit-0.0.88.dist-info}/METADATA +1 -1
- DiadFit-0.0.88.dist-info/RECORD +50 -0
- {DiadFit-0.0.84.dist-info → DiadFit-0.0.88.dist-info}/WHEEL +1 -1
- DiadFit-0.0.84.dist-info/RECORD +0 -40
- {DiadFit-0.0.84.dist-info → DiadFit-0.0.88.dist-info}/top_level.txt +0 -0
DiadFit/CO2_in_bubble_error.py
CHANGED
@@ -2,9 +2,24 @@ 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.
|
5
6
|
|
6
|
-
def
|
7
|
-
|
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
|
16
|
+
|
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',
|
18
|
+
MI_x=None, MI_y=None,MI_z=None,VB_x=None, VB_y=None,VB_z=None,
|
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',
|
21
|
+
melt_dens_kgm3, CO2_bub_dens_gcm3,
|
22
|
+
error_dist_vol_perc_bub='normal',
|
8
23
|
error_CO2_bub_dens_gcm3=0, error_type_CO2_bub_dens_gcm3='Abs', error_dist_CO2_bub_dens_gcm3='normal',
|
9
24
|
error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kgm3='normal',
|
10
25
|
plot_figure=True, fig_i=0, neg_values=True):
|
@@ -23,9 +38,32 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
23
38
|
N_dup: int
|
24
39
|
Number of duplicates when generating errors for Monte Carlo simulations
|
25
40
|
|
41
|
+
Now, either you know the vol% of the bubble and the associated error, in which case enter these two arguements:
|
42
|
+
|
26
43
|
vol_perc_bub: int, float, pd.series
|
27
44
|
Volume proportion of sulfide in melt inclusion
|
28
45
|
|
46
|
+
error_vol_perc_bub, CO2_bub_dens_gcm3, error_melt_dens_kgm3: int, float, pd.Series
|
47
|
+
Error for each variable, can be absolute or %
|
48
|
+
|
49
|
+
error_type_vol_perc_bub, error_type_bub_dens_gcm3, error_type_melt_dens_kgm3: 'Abs' or 'Perc'
|
50
|
+
whether given error is perc or absolute
|
51
|
+
|
52
|
+
Or, you have measured the x-y-z dimensions of the MI and VB (e.g. by perpendicular polishing).
|
53
|
+
|
54
|
+
MI_x, MI_y, MI_Z, VB_x, VB_y, VB_Z: int, float, pd.Series
|
55
|
+
x, y, z dimensions of vapour bubble and melt inclusion
|
56
|
+
|
57
|
+
error_MI_x, error_MI_y, error_MI_Z, error_VB_x, error_VB_y, error_VB_Z: int, float, pd.Series
|
58
|
+
Error on x, y, z dimension meausurement
|
59
|
+
|
60
|
+
error_type_dimension: 'Abs' or 'Perc'
|
61
|
+
Whether errors on all x-y-z are perc or abs
|
62
|
+
|
63
|
+
error_dist_dimension: 'normal' or 'uniform'
|
64
|
+
Whether errors on all x-y-z are normally or uniformly distributed.
|
65
|
+
|
66
|
+
|
29
67
|
melt_dens_kgm3:int, float, pd.series
|
30
68
|
Density of the silicate melt in kg/m3, e.g. from DensityX
|
31
69
|
|
@@ -33,13 +71,7 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
33
71
|
Density of the vapour bubble in g/cm3
|
34
72
|
|
35
73
|
|
36
|
-
|
37
|
-
Error for each variable, can be absolute or %
|
38
|
-
|
39
|
-
error_type_vol_perc_bub, error_type_bub_dens_gcm3, error_type_melt_dens_kgm3: 'Abs' or 'Perc'
|
40
|
-
whether given error is perc or absolute
|
41
|
-
|
42
|
-
error_dist_vol_perc_bub, error_dist_bub_dens_gcm3, error_dist_melt_dens_kgm3: 'normal' or 'uniform'
|
74
|
+
error_dist_vol_perc_bub, error_dist_bub_dens_gcm3, error_dist_melt_dens_kgm3, error_dist_dimension: 'normal' or 'uniform'
|
43
75
|
Distribution of simulated error
|
44
76
|
|
45
77
|
plot_figure: bool
|
@@ -56,30 +88,46 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
56
88
|
df_step has average and standard deviation for each sample
|
57
89
|
|
58
90
|
"""
|
91
|
+
# Constant for sphere calcs
|
92
|
+
|
93
|
+
# Lets check what they entered for volume - if they didnt enter a volume % Bubble, lets calculate it
|
94
|
+
if vol_perc_bub is None:
|
95
|
+
Vol_VB_sphere=const*VB_x*VB_y*VB_z
|
96
|
+
Vol_MI_sphere=const*MI_x*MI_y*MI_z
|
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.')
|
59
102
|
|
60
103
|
|
61
104
|
|
62
|
-
# Set up empty things to fill up.
|
63
105
|
|
106
|
+
# Set up empty things to fill up.
|
64
107
|
if type(vol_perc_bub) is pd.Series:
|
65
108
|
len_loop=len(vol_perc_bub)
|
109
|
+
|
66
110
|
else:
|
67
111
|
len_loop=1
|
68
112
|
|
69
113
|
|
70
114
|
|
71
|
-
mean_CO2_eq_melt = np.
|
72
|
-
mean_CO2_eq_melt_ind = np.
|
73
|
-
med_CO2_eq_melt = np.
|
74
|
-
std_CO2_eq_melt = np.
|
75
|
-
preferred_val_CO2_melt= np.
|
76
|
-
std_IQR_CO2_eq_melt= np.
|
77
|
-
|
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') )
|
78
124
|
|
79
125
|
|
80
126
|
All_outputs=pd.DataFrame([])
|
81
127
|
|
82
128
|
|
129
|
+
|
130
|
+
|
83
131
|
#This loops through each sample
|
84
132
|
for i in range(0, len_loop):
|
85
133
|
if i % 20 == 0:
|
@@ -89,67 +137,76 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
89
137
|
# If user has entered a pandas series for error, takes right one for each loop
|
90
138
|
# vol_perc_bub % and error
|
91
139
|
|
92
|
-
# Checking volume right format
|
93
|
-
|
94
|
-
|
95
|
-
else:
|
96
|
-
vol_perc_bub_i=vol_perc_bub
|
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)
|
97
143
|
|
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)
|
98
146
|
|
99
|
-
|
100
|
-
|
101
|
-
else:
|
102
|
-
error_vol_perc_bub_i=error_vol_perc_bub
|
147
|
+
melt_dens_kgm3_i=get_value(melt_dens_kgm3, i)
|
148
|
+
error_melt_dens_kgm3_i=get_value(error_melt_dens_kgm3, i)
|
103
149
|
|
104
|
-
# Checking bubble dens right form
|
105
150
|
|
106
|
-
if type(CO2_bub_dens_gcm3) is pd.Series:
|
107
|
-
CO2_bub_dens_gcm3_i=CO2_bub_dens_gcm3.iloc[i]
|
108
|
-
else:
|
109
|
-
CO2_bub_dens_gcm3_i=CO2_bub_dens_gcm3
|
110
151
|
|
111
|
-
# Checking melt density
|
112
|
-
|
113
|
-
if type(error_CO2_bub_dens_gcm3) is pd.Series:
|
114
|
-
error_CO2_bub_dens_gcm3_i=error_CO2_bub_dens_gcm3.iloc[i]
|
115
|
-
else:
|
116
|
-
error_CO2_bub_dens_gcm3_i=error_CO2_bub_dens_gcm3
|
117
|
-
|
118
|
-
# Checking melt density
|
119
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)
|
120
171
|
|
121
|
-
if type(melt_dens_kgm3) is pd.Series:
|
122
|
-
melt_dens_kgm3_i=melt_dens_kgm3.iloc[i]
|
123
172
|
else:
|
124
|
-
melt_dens_kgm3_i=melt_dens_kgm3
|
125
173
|
|
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)
|
126
181
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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)
|
132
188
|
|
133
189
|
|
134
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)
|
135
208
|
|
136
209
|
|
137
|
-
# This is the function doing the work to actually make the simulations for each variable.
|
138
|
-
df_synthetic=propagate_CO2_in_bubble_ind(
|
139
|
-
N_dup=N_dup,
|
140
|
-
vol_perc_bub=vol_perc_bub_i,
|
141
|
-
melt_dens_kgm3=melt_dens_kgm3_i,
|
142
|
-
CO2_bub_dens_gcm3=CO2_bub_dens_gcm3_i,
|
143
|
-
error_CO2_bub_dens_gcm3=error_CO2_bub_dens_gcm3_i,
|
144
|
-
error_type_CO2_bub_dens_gcm3=error_type_CO2_bub_dens_gcm3,
|
145
|
-
error_dist_CO2_bub_dens_gcm3=error_dist_CO2_bub_dens_gcm3,
|
146
|
-
error_vol_perc_bub=error_vol_perc_bub_i,
|
147
|
-
error_type_vol_perc_bub=error_type_vol_perc_bub,
|
148
|
-
error_dist_vol_perc_bub=error_dist_vol_perc_bub,
|
149
|
-
error_melt_dens_kgm3=error_melt_dens_kgm3_i,
|
150
|
-
error_type_melt_dens_kgm3=error_type_melt_dens_kgm3,
|
151
|
-
error_dist_melt_dens_kgm3=error_dist_melt_dens_kgm3,
|
152
|
-
len_loop=1, neg_values=neg_values)
|
153
210
|
|
154
211
|
|
155
212
|
# Convert to densities for MC
|
@@ -186,12 +243,16 @@ error_dist_melt_dens_kgm3=error_dist_melt_dens_kgm3,
|
|
186
243
|
med_CO2_eq_melt[i]=np.nanmedian(df['CO2_eq_melt_ppm_MC'])
|
187
244
|
std_CO2_eq_melt[i]=np.nanstd(df['CO2_eq_melt_ppm_MC'])
|
188
245
|
var=df['CO2_eq_melt_ppm_MC']
|
246
|
+
Q16[i]=np.percentile(var, 16)
|
247
|
+
Q84[i]=np.percentile(var, 84)
|
189
248
|
std_IQR_CO2_eq_melt[i]=0.5*np.abs((np.percentile(var, 84) -np.percentile(var, 16)))
|
190
249
|
|
191
|
-
preferred_val_CO2_melt[i]=np.nanmean(df['CO2_eq_melt_ppm_noMC'])
|
192
250
|
|
193
251
|
|
194
|
-
|
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
|
+
|
195
256
|
|
196
257
|
|
197
258
|
|
@@ -202,7 +263,9 @@ error_dist_melt_dens_kgm3=error_dist_melt_dens_kgm3,
|
|
202
263
|
'CO2_eq_in_melt_noMC': preferred_val_CO2_melt,
|
203
264
|
'mean_MC_CO2_equiv_melt_ppm': mean_CO2_eq_melt,
|
204
265
|
'med_MC_CO2_equiv_melt_ppm': med_CO2_eq_melt,
|
205
|
-
'
|
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,
|
206
269
|
|
207
270
|
|
208
271
|
|
@@ -238,12 +301,43 @@ error_dist_melt_dens_kgm3=error_dist_melt_dens_kgm3,
|
|
238
301
|
|
239
302
|
|
240
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
|
+
|
241
332
|
|
242
333
|
|
243
334
|
|
244
335
|
def propagate_CO2_in_bubble_ind(sample_i=0, N_dup=1000, vol_perc_bub=None,
|
245
336
|
CO2_bub_dens_gcm3=None, melt_dens_kgm3=None,
|
246
|
-
|
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',
|
247
341
|
error_CO2_bub_dens_gcm3=0, error_type_CO2_bub_dens_gcm3='Abs', error_dist_CO2_bub_dens_gcm3='normal',
|
248
342
|
error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kgm3='normal', len_loop=1, neg_values=True):
|
249
343
|
|
@@ -300,7 +394,7 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
300
394
|
|
301
395
|
"""
|
302
396
|
|
303
|
-
|
397
|
+
# If only a single sample, set up an output dataframe with an index.
|
304
398
|
if len_loop==1:
|
305
399
|
df_c=pd.DataFrame(data={
|
306
400
|
'vol_perc_bub': vol_perc_bub,
|
@@ -316,64 +410,56 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
316
410
|
|
317
411
|
|
318
412
|
|
319
|
-
# 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)
|
418
|
+
|
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)
|
422
|
+
|
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)
|
425
|
+
|
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)
|
320
428
|
|
321
|
-
|
322
|
-
|
323
|
-
if error_type_vol_perc_bub =='Perc':
|
324
|
-
error_Vol=df_c['vol_perc_bub'].iloc[sample_i]*error_vol_perc_bub/100
|
325
|
-
if error_dist_vol_perc_bub=='normal':
|
326
|
-
Noise_to_add_Vol = np.random.normal(0, error_Vol, N_dup)
|
327
|
-
if error_dist_vol_perc_bub=='uniform':
|
328
|
-
Noise_to_add_Vol = np.random.uniform(- error_Vol, +
|
329
|
-
error_Vol, N_dup)
|
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)
|
330
431
|
|
331
|
-
|
332
|
-
|
333
|
-
Vol_with_noise[Vol_with_noise < 0.000000000000001] = 0.000000000000001
|
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)
|
334
434
|
|
335
|
-
|
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)
|
336
437
|
|
337
|
-
# Volume error distribution
|
338
438
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
error_CO2_bub_dens_gcm3=df_c['vol_perc_bub'].iloc[sample_i]*error_CO2_bub_dens_gcm3/100
|
343
|
-
if error_dist_CO2_bub_dens_gcm3=='normal':
|
344
|
-
Noise_to_add_CO2_bub_dens_gcm3 = np.random.normal(0, error_CO2_bub_dens_gcm3, N_dup)
|
345
|
-
if error_dist_CO2_bub_dens_gcm3=='uniform':
|
346
|
-
Noise_to_add_CO2_bub_dens_gcm3 = np.random.uniform(- error_CO2_bub_dens_gcm3, +
|
347
|
-
error_CO2_bub_dens_gcm3, 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
|
348
442
|
|
349
|
-
CO2_bub_dens_gcm3_with_noise=Noise_to_add_CO2_bub_dens_gcm3+df_c['CO2_bub_dens_gcm3'].iloc[sample_i]
|
350
|
-
if neg_values is False:
|
351
|
-
CO2_bub_dens_gcm3_with_noise[CO2_bub_dens_gcm3_with_noise < 0.000000000000001] = 0.000000000000001
|
352
443
|
|
353
|
-
#
|
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)
|
354
447
|
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
error_melt_dens_kgm3=df_c['vol_perc_bub'].iloc[sample_i]*error_melt_dens_kgm3/100
|
359
|
-
if error_dist_melt_dens_kgm3=='normal':
|
360
|
-
Noise_to_add_melt_dens_kgm3 = np.random.normal(0, error_melt_dens_kgm3, N_dup)
|
361
|
-
if error_dist_melt_dens_kgm3=='uniform':
|
362
|
-
Noise_to_add_melt_dens_kgm3 = np.random.uniform(- error_melt_dens_kgm3, +
|
363
|
-
error_melt_dens_kgm3, N_dup)
|
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)
|
364
451
|
|
365
|
-
|
366
|
-
if neg_values is False:
|
367
|
-
melt_dens_kgm3_with_noise[melt_dens_kgm3_with_noise < 0.000000000000001] = 0.000000000000001
|
452
|
+
# Now lets calculate the equilibrium CO2 content of the melt
|
368
453
|
CO2_eq_melt_ind=10**4 * (df_c['vol_perc_bub']*df_c['CO2_bub_dens_gcm3'])/(df_c['melt_dens_kgm3']/1000)
|
369
|
-
|
454
|
+
|
455
|
+
if error_vol_perc_bub is not None:
|
456
|
+
df_out=pd.DataFrame(data={
|
370
457
|
|
371
458
|
'vol_perc_bub_with_noise': Vol_with_noise,
|
372
459
|
'CO2_bub_dens_gcm3_with_noise': CO2_bub_dens_gcm3_with_noise,
|
373
460
|
'melt_dens_kgm3_with_noise': melt_dens_kgm3_with_noise,
|
374
461
|
'vol_perc_bub': df_c['vol_perc_bub'].iloc[sample_i],
|
375
462
|
'CO2_bub_dens_gcm3': CO2_bub_dens_gcm3,
|
376
|
-
'Absolute_error_Vol': error_Vol,
|
377
463
|
'error_type_vol_perc_bub': error_type_vol_perc_bub,
|
378
464
|
'error_dist_Vol': error_dist_vol_perc_bub,
|
379
465
|
'error_CO2_bub_dens_gcm3': error_CO2_bub_dens_gcm3,
|
@@ -381,6 +467,27 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
381
467
|
'error_dist_CO2_bub_dens_gcm3': error_dist_CO2_bub_dens_gcm3,
|
382
468
|
})
|
383
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
|
+
|
384
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)
|
385
492
|
|
386
493
|
df_out.insert(0, 'CO2_eq_melt_ppm_MC',CO2_eq_melt)
|
@@ -388,10 +495,5 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
388
495
|
df_out.insert(1, 'CO2_eq_melt_ppm_noMC',float(CO2_eq_melt_ind.values))
|
389
496
|
|
390
497
|
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
498
|
return df_out
|
397
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
|
|