DiadFit 0.0.90__py3-none-any.whl → 1.0.0__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 +1320 -5
- DiadFit/CO2_in_bubble_error.py +91 -19
- DiadFit/__init__.py +1 -1
- DiadFit/_version.py +1 -1
- DiadFit/densimeters.py +7 -4
- DiadFit/error_propagation.py +358 -143
- {DiadFit-0.0.90.dist-info → DiadFit-1.0.0.dist-info}/METADATA +1 -1
- {DiadFit-0.0.90.dist-info → DiadFit-1.0.0.dist-info}/RECORD +10 -11
- DiadFit/CO2_H2O_EOS.py +0 -1255
- {DiadFit-0.0.90.dist-info → DiadFit-1.0.0.dist-info}/WHEEL +0 -0
- {DiadFit-0.0.90.dist-info → DiadFit-1.0.0.dist-info}/top_level.txt +0 -0
DiadFit/CO2_in_bubble_error.py
CHANGED
@@ -90,10 +90,16 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
90
90
|
"""
|
91
91
|
# Constant for sphere calcs
|
92
92
|
|
93
|
+
|
93
94
|
# Lets check what they entered for volume - if they didnt enter a volume % Bubble, lets calculate it
|
94
95
|
if vol_perc_bub is None:
|
95
|
-
|
96
|
-
|
96
|
+
if VB_z is None:
|
97
|
+
VB_z=(VB_x+VB_y)/2
|
98
|
+
if MI_z is None:
|
99
|
+
MI_z=(MI_x+MI_y)/2
|
100
|
+
|
101
|
+
Vol_VB_sphere=const*VB_x*VB_y*VB_z*(0.5)**3
|
102
|
+
Vol_MI_sphere=const*MI_x*MI_y*MI_z*(0.5)**3
|
97
103
|
vol_perc_bub=100* Vol_VB_sphere/Vol_MI_sphere
|
98
104
|
|
99
105
|
# Now lets check how they entered error in volume
|
@@ -128,6 +134,7 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
128
134
|
|
129
135
|
|
130
136
|
|
137
|
+
|
131
138
|
#This loops through each sample
|
132
139
|
for i in range(0, len_loop):
|
133
140
|
if i % 20 == 0:
|
@@ -152,6 +159,7 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
152
159
|
|
153
160
|
# This is the function doing the work to actually make the simulations for each variable.
|
154
161
|
if error_vol_perc_bub is not None:
|
162
|
+
print('didnt get inside else loop')
|
155
163
|
|
156
164
|
df_synthetic=propagate_CO2_in_bubble_ind(
|
157
165
|
N_dup=N_dup,
|
@@ -169,15 +177,27 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
169
177
|
error_dist_melt_dens_kgm3=error_dist_melt_dens_kgm3,
|
170
178
|
len_loop=1, neg_values=neg_values)
|
171
179
|
|
180
|
+
|
181
|
+
|
172
182
|
else:
|
173
183
|
|
184
|
+
|
174
185
|
# This is the more complex one where we have to account for x-y-z errors on all of them.
|
175
186
|
MI_x_i = get_value(MI_x, i)
|
176
187
|
MI_y_i = get_value(MI_y, i)
|
177
|
-
|
188
|
+
|
189
|
+
|
190
|
+
|
178
191
|
VB_x_i = get_value(VB_x, i)
|
179
192
|
VB_y_i = get_value(VB_y, i)
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
180
197
|
VB_z_i = get_value(VB_z, i)
|
198
|
+
MI_z_i = get_value(MI_z, i)
|
199
|
+
|
200
|
+
|
181
201
|
|
182
202
|
error_MI_x_i = get_value(error_MI_x, i)
|
183
203
|
error_MI_y_i = get_value(error_MI_y, i)
|
@@ -299,11 +319,33 @@ error_type_dimension=error_type_dimension, error_dist_dimension=error_dist_dimen
|
|
299
319
|
|
300
320
|
return df_step, All_outputs, fig if 'fig' in locals() else None
|
301
321
|
|
302
|
-
|
322
|
+
# Lets set the random seed
|
323
|
+
np.random.seed(42)
|
303
324
|
|
304
325
|
def add_noise_to_variable(original_value, error, error_type, error_dist, N_dup, neg_values, neg_threshold):
|
305
326
|
""" This function adds noise to each variable for the monte-carloing
|
306
327
|
|
328
|
+
Parameters
|
329
|
+
-----------------
|
330
|
+
original_value: int, float
|
331
|
+
Preferred value (e.g. center of distribution)
|
332
|
+
|
333
|
+
error: int, float
|
334
|
+
Error value
|
335
|
+
|
336
|
+
error_type: str
|
337
|
+
'Abs' if absolute error, 'Perc' if percent
|
338
|
+
|
339
|
+
error_dist: str
|
340
|
+
'normal' if normally distributed, 'uniform' if uniformly distributed.
|
341
|
+
|
342
|
+
N_dup: int
|
343
|
+
number of duplicates
|
344
|
+
|
345
|
+
neg_values: bool
|
346
|
+
whether negative values are replaced with zeros
|
347
|
+
|
348
|
+
|
307
349
|
"""
|
308
350
|
|
309
351
|
# Depending on the error type, allocates an error
|
@@ -351,14 +393,47 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
351
393
|
|
352
394
|
Parameters
|
353
395
|
----------------
|
396
|
+
For volumes, either enter vol% bubble and associated errors...
|
397
|
+
|
398
|
+
vol_perc_bub: int, float, pd.series
|
399
|
+
Volume proportion of sulfide in melt inclusion
|
400
|
+
|
401
|
+
|
402
|
+
error_vol_perc_bub, CO2_bub_dens_gcm3, error_melt_dens_kgm3: int, float, pd.Series
|
403
|
+
Error for each variable, can be absolute or %
|
404
|
+
|
405
|
+
error_type_vol_perc_bub, error_type_bub_dens_gcm3, error_type_melt_dens_kgm3: 'Abs' or 'Perc'
|
406
|
+
whether given error is perc or absolute
|
407
|
+
|
408
|
+
error_dist_vol_perc_bub, error_dist_bub_dens_gcm3, error_dist_melt_dens_kgm3: 'normal' or 'uniform'
|
409
|
+
Distribution of simulated error
|
410
|
+
|
411
|
+
|
412
|
+
OR
|
413
|
+
Enter melt inclusion and vapour bubble dimensions (diameter, not radii), and their errors
|
414
|
+
MI_x, MI_y, MI_z, VB_x, VB_y, VB_z: int, float, series:
|
415
|
+
Diameter of melt inclusions.
|
416
|
+
|
417
|
+
error_MI_x, error_MI_y, error_MI_z, error_VB_x, error_VB_y, error_VB_z:
|
418
|
+
Error on diameter of melt inclusions
|
419
|
+
|
420
|
+
error_type_dimension='Abs' or 'Perc':
|
421
|
+
Specify whether errors on these dimensions are absolute or percentage
|
422
|
+
|
423
|
+
error_dist_dimension='normal' or 'uniform':
|
424
|
+
Specify error distribution
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
354
430
|
SampleID: str, pd.series
|
355
431
|
Sample_ID (e.g. sample names) which is returned on dataframe
|
356
432
|
|
357
433
|
N_dup: int
|
358
434
|
Number of duplicates when generating errors for Monte Carlo simulations
|
359
435
|
|
360
|
-
|
361
|
-
Volume proportion of sulfide in melt inclusion
|
436
|
+
|
362
437
|
|
363
438
|
melt_dens_kgm3:int, float, pd.series
|
364
439
|
Density of the silicate melt in kg/m3, e.g. from DensityX
|
@@ -367,14 +442,6 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
367
442
|
Density of the vapour bubble in g/cm3
|
368
443
|
|
369
444
|
|
370
|
-
error_vol_perc_bub, CO2_bub_dens_gcm3, error_melt_dens_kgm3: int, float, pd.Series
|
371
|
-
Error for each variable, can be absolute or %
|
372
|
-
|
373
|
-
error_type_vol_perc_bub, error_type_bub_dens_gcm3, error_type_melt_dens_kgm3: 'Abs' or 'Perc'
|
374
|
-
whether given error is perc or absolute
|
375
|
-
|
376
|
-
error_dist_vol_perc_bub, error_dist_bub_dens_gcm3, error_dist_melt_dens_kgm3: 'normal' or 'uniform'
|
377
|
-
Distribution of simulated error
|
378
445
|
|
379
446
|
plot_figure: bool
|
380
447
|
Default true - plots a figure of the row indicated by fig_i (default 1st row, fig_i=0)
|
@@ -412,32 +479,37 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
412
479
|
|
413
480
|
# Volume error distribution - if they give a volume percentage rather than dimensions
|
414
481
|
if error_vol_perc_bub is not None:
|
482
|
+
print('using error on the bubble volume percent, not the entered dimensions, as error_vol_perc_bub was not None')
|
415
483
|
# Easy peasy
|
416
484
|
Vol_with_noise=add_noise_to_variable(vol_perc_bub, error_vol_perc_bub,
|
417
485
|
error_type_vol_perc_bub, error_dist_vol_perc_bub, N_dup, neg_values, neg_threshold=0.0000000001)
|
418
486
|
|
487
|
+
|
419
488
|
else:
|
489
|
+
|
420
490
|
x_MI_with_noise=add_noise_to_variable(MI_x, error_MI_x,
|
421
491
|
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
422
492
|
|
423
493
|
y_MI_with_noise=add_noise_to_variable(MI_y, error_MI_y,
|
424
494
|
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
425
495
|
|
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)
|
428
|
-
|
429
496
|
x_VB_with_noise=add_noise_to_variable(VB_x, error_VB_x,
|
430
497
|
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
431
498
|
|
432
499
|
y_VB_with_noise=add_noise_to_variable(VB_y, error_VB_y,
|
433
500
|
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
434
501
|
|
502
|
+
|
503
|
+
z_MI_with_noise=add_noise_to_variable(MI_z, error_MI_z,
|
504
|
+
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
505
|
+
|
506
|
+
|
435
507
|
z_VB_with_noise=add_noise_to_variable(VB_z, error_VB_z,
|
436
508
|
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
437
509
|
|
438
510
|
|
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
|
511
|
+
Vol_VB_sphere_with_noise=const*x_VB_with_noise*y_VB_with_noise*z_VB_with_noise*(0.5)**3
|
512
|
+
Vol_MI_sphere_with_noise=const*x_MI_with_noise*y_MI_with_noise*z_MI_with_noise*(0.5)**3
|
441
513
|
Vol_with_noise=100* Vol_VB_sphere_with_noise/Vol_MI_sphere_with_noise
|
442
514
|
|
443
515
|
|
DiadFit/__init__.py
CHANGED
DiadFit/_version.py
CHANGED
DiadFit/densimeters.py
CHANGED
@@ -545,7 +545,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
545
545
|
|
546
546
|
|
547
547
|
|
548
|
-
elif lab=='CCMR':
|
548
|
+
elif lab=='CCMR' and temp=='SupCrit':
|
549
549
|
pickle_str_lowr='Lowrho_polyfit_data_CCMR.pkl'
|
550
550
|
with open(DiadFit_dir/pickle_str_lowr, 'rb') as f:
|
551
551
|
lowrho_pickle_data = pickle.load(f)
|
@@ -557,11 +557,12 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
557
557
|
# This gets the densimeter at high density.
|
558
558
|
pickle_str_highr='Highrho_polyfit_data_CCMR.pkl'
|
559
559
|
with open(DiadFit_dir/pickle_str_highr, 'rb') as f:
|
560
|
-
highrho_pickle_data = pickle.load(f)
|
560
|
+
highrho_pickle_data = pickle.load(f)
|
561
|
+
|
561
562
|
|
562
563
|
|
563
564
|
else:
|
564
|
-
raise TypeError('Lab name not recognised. enter CCMR
|
565
|
+
raise TypeError('Lab name not recognised. enter CCMR SupCrit, CMASS SupCrit, CMASS roomT (CCMR room T can be added on request to Penny)')
|
565
566
|
|
566
567
|
# this allocates the model
|
567
568
|
lowrho_model = lowrho_pickle_data['model']
|
@@ -627,7 +628,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
627
628
|
# If splitting is 0
|
628
629
|
zero=df['Corrected_Splitting']==0
|
629
630
|
|
630
|
-
|
631
|
+
# Cut off values -------------------------------------------
|
631
632
|
# Range for SC low density
|
632
633
|
min_lowD_SC_Split=df['Corrected_Splitting']>=102.7623598753032
|
633
634
|
max_lowD_SC_Split=df['Corrected_Splitting']<=103.1741034592534
|
@@ -643,6 +644,8 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
643
644
|
# Range for Room T high density
|
644
645
|
min_HD_RoomT_Split=df['Corrected_Splitting']>=104.407308904012
|
645
646
|
max_HD_RoomT_Split=df['Corrected_Splitting']<=105.1
|
647
|
+
|
648
|
+
|
646
649
|
# Impossible densities, room T
|
647
650
|
Imposs_lower_end=(df['Corrected_Splitting']>103.350311768435) & (df['Corrected_Splitting']<103.88)
|
648
651
|
# Impossible densities, room T
|