DiadFit 0.0.54__py3-none-any.whl → 0.0.57__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 +185 -18
- DiadFit/__init__.py +1 -2
- DiadFit/_version.py +1 -1
- DiadFit/diads.py +19 -8
- DiadFit/error_propagation.py +283 -165
- DiadFit/importing_data_files.py +160 -29
- DiadFit/ne_lines.py +117 -38
- {DiadFit-0.0.54.dist-info → DiadFit-0.0.57.dist-info}/METADATA +1 -1
- DiadFit-0.0.57.dist-info/RECORD +16 -0
- DiadFit/example_peak_params.py +0 -0
- DiadFit/microthermometry.py +0 -10
- DiadFit/ne_lines_BACKUP_966.py +0 -1431
- DiadFit/ne_lines_BASE_966.py +0 -1427
- DiadFit/ne_lines_LOCAL_966.py +0 -1427
- DiadFit/ne_lines_REMOTE_966.py +0 -1427
- DiadFit/skewness.py +0 -0
- DiadFit-0.0.54.dist-info/RECORD +0 -23
- {DiadFit-0.0.54.dist-info → DiadFit-0.0.57.dist-info}/WHEEL +0 -0
- {DiadFit-0.0.54.dist-info → DiadFit-0.0.57.dist-info}/top_level.txt +0 -0
DiadFit/error_propagation.py
CHANGED
@@ -11,6 +11,36 @@ from DiadFit.CO2_EOS import *
|
|
11
11
|
# propagate_microthermometry_uncertainty_1sam goes to 'make_error_dist_microthermometry_1sam'
|
12
12
|
def make_error_dist_microthermometry_1sam(*, T_h_C, sample_i=0, error_T_h_C=0.3, N_dup=1000,
|
13
13
|
error_dist_T_h_C='uniform', error_type_T_h_C='Abs', len_loop=1):
|
14
|
+
|
15
|
+
"""
|
16
|
+
|
17
|
+
This function generates a dataset of temperature measurements for a given sample.
|
18
|
+
It adds random noise to the temperature measurement based on the specified distribution and error type.
|
19
|
+
|
20
|
+
Parameters
|
21
|
+
----------
|
22
|
+
T_h_C : numeric or list of numeric values
|
23
|
+
The measured temperature(s) of the sample(s) in degrees Celsius.
|
24
|
+
sample_i : int, optional
|
25
|
+
The index of the sample for which the error distribution will be generated. Default value is 0.
|
26
|
+
error_T_h_C : numeric, optional
|
27
|
+
The amount of error to add to the temperature measurement. Default value is 0.3.
|
28
|
+
N_dup : int, optional
|
29
|
+
The number of duplicated samples to generate with random noise. Default value is 1000.
|
30
|
+
error_dist_T_h_C : str, optional
|
31
|
+
The distribution of the random noise to be added to the temperature measurement. Can be either 'normal' or 'uniform'. Default value is 'uniform'.
|
32
|
+
error_type_T_h_C : str, optional
|
33
|
+
The type of error to add to the temperature measurement. Can be either 'Abs' or 'Perc'. Default value is 'Abs'.
|
34
|
+
len_loop : int, optional
|
35
|
+
The number of samples for which the error distribution will be generated. Default value is 1.
|
36
|
+
|
37
|
+
Returns
|
38
|
+
-------
|
39
|
+
numpy.ndarray
|
40
|
+
An array of temperature measurements with random noise added to them based on the specified error
|
41
|
+
distribution and error type. The size of the array is (N_dup, len(T_h_C)).
|
42
|
+
|
43
|
+
"""
|
14
44
|
|
15
45
|
if len_loop==1:
|
16
46
|
df_c=pd.DataFrame(data={'T_h_C': T_h_C}, index=[0])
|
@@ -34,16 +64,57 @@ def make_error_dist_microthermometry_1sam(*, T_h_C, sample_i=0, error_T_h_C=0.3,
|
|
34
64
|
return T_h_C_with_noise
|
35
65
|
|
36
66
|
|
37
|
-
def propagate_microthermometry_uncertainty(T_h_C, Sample_ID=None,
|
38
|
-
error_dist_T_h_C='uniform', error_type_T_h_C='Abs',
|
67
|
+
def propagate_microthermometry_uncertainty(T_h_C, Sample_ID=None, error_T_h_C=0.3, N_dup=1000,
|
68
|
+
error_dist_T_h_C='uniform', error_type_T_h_C='Abs', EOS='SW96', homog_to=None):
|
39
69
|
|
40
|
-
|
70
|
+
"""
|
71
|
+
This function propagates the uncertainty in measured temperature values to calculate the density of gas and liquid CO2 using an equation of state (EOS).
|
72
|
+
It loops over more than 1 sample, using the function make_error_dist_microthermometry_1sam for each sample to generate the variable input parameters
|
73
|
+
It generates a dataset of temperature measurements with random noise added to them based on the specified distribution and error type,
|
74
|
+
calculates the CO2 density for each temperature value, and returns the mean and standard deviation of the density values.
|
75
|
+
|
76
|
+
Parameters
|
77
|
+
----------
|
78
|
+
T_h_C : numeric or list of numeric values
|
79
|
+
The measured temperature(s) of the sample(s) in degrees Celsius.
|
80
|
+
|
81
|
+
Sample_ID : str or pandas.Series
|
82
|
+
The ID or a pandas Series of IDs of the sample(s). If not provided, the function uses an index number as the ID. Default is None.
|
83
|
+
|
84
|
+
error_T_h_C : float or pandas.Series
|
85
|
+
The amount of error to add to the temperature measurement. If a pandas.Series is provided, the function takes the right one for each loop. Default value is 0.3.
|
86
|
+
|
87
|
+
N_dup : int, optional
|
88
|
+
The number of duplicated samples to generate with random noise. Default value is 1000.
|
89
|
+
|
90
|
+
error_dist_T_h_C : str, optional
|
91
|
+
The distribution of the random noise to be added to the temperature measurement. Can be either 'normal' or 'uniform'. Default value is 'uniform'.
|
92
|
+
|
93
|
+
error_type_T_h_C : str, optional
|
94
|
+
The type of error to add to the temperature measurement. Can be either 'Abs' or 'Perc'. Default value is 'Abs'.
|
95
|
+
|
96
|
+
EOS : str, optional
|
97
|
+
The equation of state to use for the calculation. Can be either 'SW96' or 'SP94'. Default value is 'SW96'.
|
98
|
+
|
99
|
+
|
100
|
+
homog_to : str, optional
|
101
|
+
The phase to which the CO2 density is homogenized. Can be either 'Gas' or 'Liq'. Default is None.
|
102
|
+
|
103
|
+
Returns
|
104
|
+
-------
|
105
|
+
pandas.DataFrame, pandas.DataFrame
|
106
|
+
A tuple of two pandas DataFrames. The first DataFrame contains the mean and standard deviation of the gas and liquid CO2 density values. The second DataFrame contains the CO2 density values for each temperature value in the input.
|
107
|
+
|
108
|
+
|
109
|
+
"""
|
41
110
|
|
42
111
|
if type(T_h_C) is pd.Series:
|
43
112
|
len_loop=len(T_h_C)
|
44
113
|
else:
|
45
114
|
len_loop=1
|
46
115
|
|
116
|
+
|
117
|
+
|
47
118
|
|
48
119
|
All_outputs=pd.DataFrame([])
|
49
120
|
Std_density_gas=np.empty(len_loop)
|
@@ -109,85 +180,87 @@ def propagate_microthermometry_uncertainty(T_h_C, Sample_ID=None, sample_i=0, er
|
|
109
180
|
|
110
181
|
|
111
182
|
|
112
|
-
def calculate_temperature_density_MC(sample_i=
|
113
|
-
|
114
|
-
error_T_K=0, error_type_T_K='Abs', error_dist_T_K='normal',
|
115
|
-
|
116
|
-
|
117
|
-
plot_figure=True, len_loop=1, model=None):
|
183
|
+
def calculate_temperature_density_MC(sample_i=0, N_dup=1000,
|
184
|
+
CO2_dens_gcm3=None, error_CO2_dens=0, error_type_CO2_dens='Abs', error_dist_CO2_dens='normal',
|
185
|
+
T_K=None, error_T_K=0, error_type_T_K='Abs', error_dist_T_K='normal',
|
186
|
+
crust_dens_kgm3=None, error_crust_dens=0, error_type_crust_dens='Abs', error_dist_crust_dens='normal',
|
187
|
+
model=None):
|
118
188
|
|
119
|
-
"""
|
189
|
+
"""
|
190
|
+
This function generates the range of T_K, CO2 densities and crustal densities for 1 sample for performing Monte Carlo simulations
|
191
|
+
using the function propagate_FI_uncertainty (e.g. this function makes the range of input parameters for each sample, but doesnt do the EOS calculations).
|
120
192
|
|
121
193
|
Parameters
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
The number of simulations to run. Default is 1000.
|
126
|
-
|
127
|
-
T_K (float, optional):
|
128
|
-
The temperature of the sample in degrees Kelvin.
|
129
|
-
|
130
|
-
len_loop: float
|
131
|
-
Number of samples you are doing, if only 1 for loop, uses an index.
|
132
|
-
|
133
|
-
error_T_K (float, optional):
|
134
|
-
The error in the temperature measurement. Default is 0.
|
135
|
-
|
136
|
-
error_type_T_K (str, optional):
|
137
|
-
The type of error in the temperature measurement, either 'Abs' for absolute error or 'Perc' for percent error. Default is 'Abs'.
|
138
|
-
|
139
|
-
error_dist_T_K (str, optional):
|
140
|
-
The distribution of error in the CO2 density measurement, either 'normal' or 'uniform'
|
141
|
-
|
142
|
-
CO2_dens_gcm3 (float, optional):
|
143
|
-
The CO2 density of the CO2 fluid in g/cm^3.
|
144
|
-
|
145
|
-
error_CO2_dens (float, optional):
|
146
|
-
The error in the CO2 density measurement. Default is 0.
|
147
|
-
|
148
|
-
error_type_CO2_dens (str, optional):
|
149
|
-
The type of error in the CO2 density measurement, either 'Abs' for absolute error or 'Perc' for percent error. Default is 'Abs'.
|
150
|
-
|
151
|
-
error_dist_CO2_dens (str, optional):
|
152
|
-
The distribution of error in the CO2 density measurement, either 'normal' or 'uniform'
|
153
|
-
|
194
|
+
-----------------
|
195
|
+
sample_i: int
|
196
|
+
The index of the sample
|
154
197
|
|
155
|
-
|
156
|
-
|
157
|
-
if str, either a density model ('ryan_lerner, two step etc')
|
158
|
-
if two-step or three-step:
|
159
|
-
rho1 - density in kg/m3 down to d1
|
160
|
-
rho2 - density in kg/m3 between d1 and d2
|
161
|
-
rho3 - density in kg/m3 between d2 and d3
|
162
|
-
d1 - depth in km to first density transition
|
163
|
-
d2 - depth in km to second density transition
|
198
|
+
N_dup: int
|
199
|
+
Number of synthetic inputs to do for each sample.
|
164
200
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
201
|
+
CO2_dens_gcm3: pd.Series, integer or float
|
202
|
+
CO2 densities in g/cm3 to perform calculations with. Can be a column from your dataframe (df['density_g_cm3']), or a single value (e.g.., 0.2)
|
203
|
+
error_CO2_dens: float
|
204
|
+
Error in CO2 fluid density
|
205
|
+
error_type_CO2_dens: str
|
206
|
+
Type of CO2 fluid density error. Can be 'Abs' or 'Perc'
|
207
|
+
error_dist_CO2_dens: str
|
208
|
+
Distribution of CO2 fluid density error. Can be 'normal' or 'uniform'.
|
173
209
|
|
174
|
-
|
175
|
-
|
210
|
+
T_K: pd.Series, integer, float
|
211
|
+
Temperature in Kelvin at which you think your fluid inclusion was trapped.
|
212
|
+
Can be a column from your dataframe (df['T_K']), or a single value (e.g.., 1500)
|
213
|
+
error_T_K: float
|
214
|
+
Error in temperature.
|
215
|
+
error_type_T_K: str
|
216
|
+
Type of temperature error. Can be 'Abs' or 'Perc'.
|
217
|
+
error_dist_T_K: str
|
218
|
+
Distribution of temperature error. Can be 'normal' or 'uniform'.
|
219
|
+
|
220
|
+
For converting pressure to depth in the crust, choose either
|
221
|
+
|
222
|
+
A fixed crustal density
|
223
|
+
|
224
|
+
crust_dens_kgm3: float
|
225
|
+
Density of the crust in kg/m^3.
|
226
|
+
error_crust_dens: float, optional
|
227
|
+
Error in crust density.
|
228
|
+
error_type_crust_dens: str
|
229
|
+
Type of crust density error. Can be 'Abs' or 'Perc'.
|
230
|
+
error_dist_crust_dens: str
|
231
|
+
Distribution of crust density error. Can be 'normal' or 'uniform'.
|
232
|
+
|
233
|
+
|
234
|
+
OR a crustal density model
|
235
|
+
|
236
|
+
model: str
|
237
|
+
see documentation for the function 'convert_pressure_to_depth' to see more detail about model options.
|
238
|
+
If you select a model, it will just use this to calculate a depth, but it wont add any uncertainty to this model (as this is
|
239
|
+
more likely systematic than random uncertainty that can be simulated with MC methods)
|
240
|
+
For this function, you dont need any more info like d1, rho1, that comes in the propagate_FI_uncertainty function.
|
176
241
|
|
177
242
|
Returns
|
178
|
-
|
179
|
-
|
180
|
-
|
243
|
+
------------
|
244
|
+
df_out: pandas.DataFrame
|
245
|
+
DataFrame containing information on temperature, CO2 density, crust density, and error.
|
181
246
|
|
182
247
|
"""
|
183
248
|
|
184
|
-
|
185
|
-
|
249
|
+
# print('entered T_K')
|
250
|
+
# print(T_K)
|
251
|
+
# print('entered CO2')
|
252
|
+
# print(CO2_dens_gcm3)
|
253
|
+
# If any of them are panda series or numpy nd array, you dont need an index
|
254
|
+
if isinstance(T_K, pd.Series) or isinstance(CO2_dens_gcm3, pd.Series) or isinstance(T_K, np.ndarray) or isinstance(CO2_dens_gcm3, np.ndarray):
|
186
255
|
df_c=pd.DataFrame(data={'T_K': T_K,
|
187
|
-
'CO2_dens_gcm3': CO2_dens_gcm3}
|
256
|
+
'CO2_dens_gcm3': CO2_dens_gcm3})
|
257
|
+
|
258
|
+
# you do need an index here
|
188
259
|
else:
|
260
|
+
#print('here')
|
189
261
|
df_c=pd.DataFrame(data={'T_K': T_K,
|
190
|
-
'CO2_dens_gcm3': CO2_dens_gcm3})
|
262
|
+
'CO2_dens_gcm3': CO2_dens_gcm3}, index=[0])
|
263
|
+
|
191
264
|
|
192
265
|
|
193
266
|
# Temperature error distribution
|
@@ -201,6 +274,7 @@ plot_figure=True, len_loop=1, model=None):
|
|
201
274
|
Noise_to_add_T_K = np.random.uniform(- error_T_K, +
|
202
275
|
error_T_K, N_dup)
|
203
276
|
|
277
|
+
|
204
278
|
T_K_with_noise=Noise_to_add_T_K+df_c['T_K'].iloc[sample_i]
|
205
279
|
T_K_with_noise[T_K_with_noise < 0.0001] = 0.0001
|
206
280
|
|
@@ -281,120 +355,115 @@ error_crust_dens=0, error_type_crust_dens='Abs', error_dist_crust_dens='uniform'
|
|
281
355
|
error_T_K=0, error_type_T_K='Abs', error_dist_T_K='normal',
|
282
356
|
error_CO2_dens=0, error_type_CO2_dens='Abs', error_dist_CO2_dens='normal',
|
283
357
|
plot_figure=False, fig_i=0):
|
358
|
+
""" This is a redundant function, kept around for a while for backwards compatability"""
|
284
359
|
|
285
360
|
print('Please use the new function propagate_FI_uncertainty instead as this allows you use different EOS')
|
286
361
|
|
287
362
|
|
288
363
|
|
289
|
-
def propagate_FI_uncertainty(sample_ID, CO2_dens_gcm3, T_K,
|
290
|
-
|
364
|
+
def propagate_FI_uncertainty(sample_ID, CO2_dens_gcm3, T_K, N_dup=1000, EOS='SW96',
|
365
|
+
plot_figure=False, fig_i=0,
|
366
|
+
error_CO2_dens=0, error_type_CO2_dens='Abs', error_dist_CO2_dens='normal',
|
367
|
+
crust_dens_kgm3=None, model=None, d1=None, d2=None, rho1=None, rho2=None, rho3=None,
|
291
368
|
error_crust_dens=0, error_type_crust_dens='Abs', error_dist_crust_dens='uniform',
|
292
369
|
error_T_K=0, error_type_T_K='Abs', error_dist_T_K='normal',
|
293
|
-
|
294
|
-
plot_figure=False, fig_i=0, EOS='SW96', model=None):
|
370
|
+
):
|
295
371
|
|
296
372
|
"""
|
297
|
-
|
298
|
-
|
373
|
+
This function performs Monte Carlo simulations of uncertainty in CO2 density, input temperature, and crustal density.
|
374
|
+
It uses the function 'calculate_temperature_density_MC' to make the simulated variables, and then uses this to calculate a resulting
|
375
|
+
pressure using the equation of state of choice
|
299
376
|
|
300
|
-
|
301
|
-
|
377
|
+
Parameters
|
378
|
+
-----------------
|
302
379
|
sample_ID: pd.Series
|
303
380
|
Panda series of sample names. E.g., select a column from your dataframe (df['sample_name'])
|
304
381
|
|
382
|
+
N_dup: int
|
383
|
+
Number of Monte Carlo simulations to perform for each sample
|
384
|
+
|
385
|
+
EOS: str
|
386
|
+
'SW96' or 'SP94' for the pure CO2 EOS
|
387
|
+
|
388
|
+
plot_figure: bool
|
389
|
+
if True, plots a figure for one sample showing the range of input parameters. If this is True,
|
390
|
+
also select:
|
391
|
+
fig_i: int
|
392
|
+
Which determins which sample is plotted (e.g. 0 is the 1st sample name, etc. )
|
393
|
+
|
394
|
+
|
305
395
|
CO2_dens_gcm3: pd.Series, integer or float
|
306
396
|
CO2 densities in g/cm3 to perform calculations with. Can be a column from your dataframe (df['density_g_cm3']), or a single value (e.g.., 0.2)
|
397
|
+
error_CO2_dens: float
|
398
|
+
Error in CO2 fluid density
|
399
|
+
error_type_CO2_dens: str
|
400
|
+
Type of CO2 fluid density error. Can be 'Abs' or 'Perc'
|
401
|
+
error_dist_CO2_dens: str
|
402
|
+
Distribution of CO2 fluid density error. Can be 'normal' or 'uniform'.
|
307
403
|
|
308
404
|
T_K: pd.Series, integer, float
|
309
|
-
Temperature in Kelvin
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
ryan_lerner:
|
358
|
-
Parameterization of Ryan 1987, actual equation from Lerner et al. 2021
|
359
|
-
After 16.88 km (455 MPa), assume density is 2.746, as density turns around again. This profile is tweaked for Hawaii
|
360
|
-
|
361
|
-
mavko_debari:
|
362
|
-
Parameterization of Mavko and Thompson (1983) and DeBari and Greene (2011)
|
363
|
-
as given in Putirka (2017) Down the Crater Elements supplement.
|
364
|
-
|
365
|
-
|
366
|
-
hill_zucca:
|
367
|
-
Parameterization of Hill and Zucca (1987),
|
368
|
-
as given in Putirka (2017) Down the Crater Elements supplement
|
405
|
+
Temperature in Kelvin at which you think your fluid inclusion was trapped.
|
406
|
+
Can be a column from your dataframe (df['T_K']), or a single value (e.g.., 1500)
|
407
|
+
error_T_K: float
|
408
|
+
Error in temperature.
|
409
|
+
error_type_T_K: str
|
410
|
+
Type of temperature error. Can be 'Abs' or 'Perc'.
|
411
|
+
error_dist_T_K: str
|
412
|
+
Distribution of temperature error. Can be 'normal' or 'uniform'.
|
413
|
+
|
414
|
+
For converting pressure to depth in the crust, choose either
|
415
|
+
|
416
|
+
A fixed crustal density
|
417
|
+
|
418
|
+
crust_dens_kgm3: float
|
419
|
+
Density of the crust in kg/m^3.
|
420
|
+
error_crust_dens: float, optional
|
421
|
+
Error in crust density.
|
422
|
+
error_type_crust_dens: str
|
423
|
+
Type of crust density error. Can be 'Abs' or 'Perc'.
|
424
|
+
error_dist_crust_dens: str
|
425
|
+
Distribution of crust density error. Can be 'normal' or 'uniform'.
|
426
|
+
|
427
|
+
|
428
|
+
OR a crustal density model
|
429
|
+
|
430
|
+
model: str
|
431
|
+
see documentation for the function 'convert_pressure_to_depth' to see more detail about model options.
|
432
|
+
If you select a model, it will just use this to calculate a depth, but it wont add any uncertainty to this model (as this is
|
433
|
+
more likely systematic than random uncertainty that can be simulated with MC methods)
|
434
|
+
|
435
|
+
if model is two-step:
|
436
|
+
If two step, must also define:
|
437
|
+
d1: Depth to first transition in km
|
438
|
+
rho1: Density between surface and 1st transition
|
439
|
+
d2: Depth to second transition in km (from surface)
|
440
|
+
rho2: Density between 1st and 2nd transition
|
441
|
+
|
442
|
+
if model is three-step:
|
443
|
+
If three step, must also define:
|
444
|
+
d1: Depth to first transition in km
|
445
|
+
rho1: Density between surface and 1st transition
|
446
|
+
d2: Depth to second transition in km (from surface)
|
447
|
+
rho2: Density between 1st and 2nd transition
|
448
|
+
d3: Depth to third transition in km (from surface)
|
449
|
+
rho3: Density between 2nd and 3rd transition depth.
|
450
|
+
|
451
|
+
|
369
452
|
|
370
|
-
prezzi:
|
371
|
-
Parameterization of Prezzi et al. (2009),
|
372
|
-
as given in Putirka (2017) Down the Crater Elements supplement. Tweaked for Andes.
|
373
|
-
|
374
|
-
rasmussen:
|
375
|
-
Linear fit to the supporting information of Rasmussen et al. 2022,
|
376
|
-
overall best fit density vs. depth
|
377
|
-
|
378
|
-
two-step:
|
379
|
-
If two step, must also define d1 (depth to 1st step), rho1 (density to 1st step), rho2 (density to 2nd step)
|
380
|
-
|
381
|
-
three-step:
|
382
|
-
If three step, must also define d1 (depth to 1st step), d2 (depth to second step), rho1 (density to 1st step), rho2 (density to 2nd step),
|
383
|
-
rho3 (density after 3rd step) in km and kg/m3 respectively.
|
384
|
-
|
385
|
-
|
386
|
-
If a model is selected, error_type_crust_dens, error_crust_dens, and error_dist_crust_dens not used.
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
plot_figure (bool):
|
391
|
-
if True, plots a figure of the distribution of different variables.
|
392
453
|
|
393
454
|
Returns
|
394
455
|
----------------
|
395
|
-
pd.DataFrame
|
396
|
-
Dataframe with N_dup rows, and calculated T, densities, as well as input parameters
|
397
456
|
|
457
|
+
df_step, All_outputs,fig if plot_figure is true
|
458
|
+
|
459
|
+
df_step: pd.DataFrame
|
460
|
+
has 1 row for each entered sample, with mean, median, and standard deviation for each parameter
|
461
|
+
|
462
|
+
All_outputs: pd.DataFrame
|
463
|
+
has N_dup rows for each input, e.g. full simulation data for each sample. What is being shown in the figure
|
464
|
+
|
465
|
+
fig: figure
|
466
|
+
Figure of simulated input and output parameters for 1 sample selected by the user.
|
398
467
|
|
399
468
|
|
400
469
|
"""
|
@@ -437,7 +506,7 @@ error_CO2_dens=0, error_type_CO2_dens='Abs', error_dist_CO2_dens='normal',
|
|
437
506
|
|
438
507
|
|
439
508
|
|
440
|
-
#This loops through each fluid inclusion
|
509
|
+
#This loops through each fluid inclusion entered density
|
441
510
|
for i in range(0, len_loop):
|
442
511
|
if i % 20 == 0:
|
443
512
|
print('working on sample number '+str(i))
|
@@ -480,8 +549,7 @@ error_CO2_dens=0, error_type_CO2_dens='Abs', error_dist_CO2_dens='normal',
|
|
480
549
|
T_K=T_K, error_T_K=error_T_K, error_type_T_K=error_type_T_K, error_dist_T_K=error_dist_T_K,
|
481
550
|
error_CO2_dens=error_CO2_dens, error_type_CO2_dens=error_type_CO2_dens, error_dist_CO2_dens=error_dist_CO2_dens,
|
482
551
|
crust_dens_kgm3=crust_dens_kgm3, error_crust_dens=error_crust_dens, error_type_crust_dens= error_type_crust_dens, error_dist_crust_dens=error_dist_crust_dens,
|
483
|
-
|
484
|
-
plot_figure=plot_figure, len_loop=len_loop, model=model)
|
552
|
+
model=model)
|
485
553
|
|
486
554
|
# Convert to densities for MC
|
487
555
|
|
@@ -646,11 +714,61 @@ error_CO2_dens=0, error_type_CO2_dens='Abs', error_dist_CO2_dens='normal',
|
|
646
714
|
|
647
715
|
|
648
716
|
## Actual functions doing the conversions
|
649
|
-
def convert_co2_dens_press_depth(T_K=None,
|
717
|
+
def convert_co2_dens_press_depth(EOS='SW96', T_K=None,
|
650
718
|
CO2_dens_gcm3=None,
|
651
719
|
crust_dens_kgm3=None, output='kbar',
|
652
720
|
g=9.81, model=None,
|
653
|
-
d1=None, d2=None, rho1=None, rho2=None, rho3=None,
|
721
|
+
d1=None, d2=None, rho1=None, rho2=None, rho3=None, ):
|
722
|
+
|
723
|
+
""" This function calculates pressure and depth based on input CO2 densities, temperatures, and crustal density information from the user
|
724
|
+
|
725
|
+
Parameters
|
726
|
+
------------------
|
727
|
+
EOS: str
|
728
|
+
'SP94' or 'SW96' - CO2 equation of state choosen
|
729
|
+
|
730
|
+
T_K: float, pd.Series
|
731
|
+
Temperature in Kelvin at which fluid inclusion was trapped.
|
732
|
+
|
733
|
+
CO2_dens_gcm3: float, pd.Series
|
734
|
+
CO2 density of FI in g/cm3
|
735
|
+
|
736
|
+
For Pressure to depth conversion choose:
|
737
|
+
|
738
|
+
crust_dens_kgm3: float
|
739
|
+
Crustal density in kg/m3
|
740
|
+
|
741
|
+
OR
|
742
|
+
|
743
|
+
model: str
|
744
|
+
see documentation for the function 'convert_pressure_to_depth' to see more detail about model options.
|
745
|
+
If you select a model, it will just use this to calculate a depth, but it wont add any uncertainty to this model (as this is
|
746
|
+
more likely systematic than random uncertainty that can be simulated with MC methods)
|
747
|
+
|
748
|
+
if model is two-step:
|
749
|
+
If two step, must also define:
|
750
|
+
d1: Depth to first transition in km
|
751
|
+
rho1: Density between surface and 1st transition
|
752
|
+
d2: Depth to second transition in km (from surface)
|
753
|
+
rho2: Density between 1st and 2nd transition
|
754
|
+
|
755
|
+
if model is three-step:
|
756
|
+
If three step, must also define:
|
757
|
+
d1: Depth to first transition in km
|
758
|
+
rho1: Density between surface and 1st transition
|
759
|
+
d2: Depth to second transition in km (from surface)
|
760
|
+
rho2: Density between 1st and 2nd transition
|
761
|
+
d3: Depth to third transition in km (from surface)
|
762
|
+
rho3: Density between 2nd and 3rd transition depth.
|
763
|
+
|
764
|
+
Returns
|
765
|
+
---------------------
|
766
|
+
pd.DataFrame
|
767
|
+
dataframe of pressure, depth, and input parameterss
|
768
|
+
|
769
|
+
"""
|
770
|
+
|
771
|
+
|
654
772
|
|
655
773
|
# First step is to get pressure
|
656
774
|
Pressure=calculate_P_for_rho_T(T_K=T_K,
|