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/densimeters.py
CHANGED
@@ -498,8 +498,10 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
498
498
|
Split_err=(split_err*Split).astype(float)
|
499
499
|
|
500
500
|
|
501
|
-
|
502
|
-
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
|
503
505
|
if isinstance(Split, float) or isinstance(Split, int):
|
504
506
|
Split=pd.Series(Split)
|
505
507
|
# #if temp is "RoomT":
|
@@ -509,7 +511,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
509
511
|
HighD_RT=-41.64784 + 0.4058777*Split- 0.1460339*(Split-104.653)**2
|
510
512
|
|
511
513
|
# IF temp is 37
|
512
|
-
if lab=='CMASS':
|
514
|
+
if lab=='CMASS' and temp=='SupCrit':
|
513
515
|
# This gets the densimeter at low density
|
514
516
|
pickle_str_lowr='Lowrho_polyfit_data_CMASS.pkl'
|
515
517
|
with open(DiadFit_dir/pickle_str_lowr, 'rb') as f:
|
@@ -523,6 +525,25 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
523
525
|
pickle_str_highr='Highrho_polyfit_data_CMASS.pkl'
|
524
526
|
with open(DiadFit_dir/pickle_str_highr, 'rb') as f:
|
525
527
|
highrho_pickle_data = pickle.load(f)
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
|
532
|
+
if lab=='CMASS' and temp=='RoomT':
|
533
|
+
# This gets the densimeter at low density
|
534
|
+
pickle_str_lowr='Lowrho_polyfit_data_CMASS_24C.pkl'
|
535
|
+
with open(DiadFit_dir/pickle_str_lowr, 'rb') as f:
|
536
|
+
lowrho_pickle_data = pickle.load(f)
|
537
|
+
|
538
|
+
|
539
|
+
# This gets the densimeter at high density.
|
540
|
+
pickle_str_highr='Highrho_polyfit_data_CMASS_24C.pkl'
|
541
|
+
with open(DiadFit_dir/pickle_str_highr, 'rb') as f:
|
542
|
+
highrho_pickle_data = pickle.load(f)
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
|
526
547
|
elif lab=='CCMR':
|
527
548
|
pickle_str_lowr='Lowrho_polyfit_data_CCMR.pkl'
|
528
549
|
with open(DiadFit_dir/pickle_str_lowr, 'rb') as f:
|
@@ -543,7 +564,13 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
543
564
|
|
544
565
|
# this allocates the model
|
545
566
|
lowrho_model = lowrho_pickle_data['model']
|
546
|
-
|
567
|
+
|
568
|
+
if temp=='SupCrit':
|
569
|
+
medrho_model = medrho_pickle_data['model']
|
570
|
+
MedD_SC = pd.Series(medrho_model(Split), index=Split.index)
|
571
|
+
medD_error=calculate_Densimeter_std_err_values(corrected_split=Split, corrected_split_err=Split_err,
|
572
|
+
pickle_str=pickle_str_medr, CI_dens=CI_neon, CI_split=CI_split, str_d='MedD')
|
573
|
+
|
547
574
|
highrho_model = highrho_pickle_data['model']
|
548
575
|
|
549
576
|
# Each of these lines get the density, and then the error on that density.
|
@@ -551,10 +578,8 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
551
578
|
LowD_SC = pd.Series(lowrho_model(Split), index=Split.index)
|
552
579
|
lowD_error=calculate_Densimeter_std_err_values(corrected_split=Split, corrected_split_err=Split_err,
|
553
580
|
pickle_str=pickle_str_lowr, CI_dens=CI_neon, CI_split=CI_split, str_d='LowD')
|
581
|
+
|
554
582
|
|
555
|
-
MedD_SC = pd.Series(medrho_model(Split), index=Split.index)
|
556
|
-
medD_error=calculate_Densimeter_std_err_values(corrected_split=Split, corrected_split_err=Split_err,
|
557
|
-
pickle_str=pickle_str_medr, CI_dens=CI_neon, CI_split=CI_split, str_d='MedD')
|
558
583
|
|
559
584
|
HighD_SC = pd.Series(highrho_model(Split), index=Split.index)
|
560
585
|
highD_error=calculate_Densimeter_std_err_values(corrected_split=Split, corrected_split_err=Split_err,
|
@@ -563,7 +588,14 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
563
588
|
|
564
589
|
|
565
590
|
|
566
|
-
|
591
|
+
if temp=='RoomT':
|
592
|
+
MedD_SC=np.nan
|
593
|
+
MedD_err=np.nan
|
594
|
+
|
595
|
+
else:
|
596
|
+
MedD_err=medD_error['MedD_Density_σ']
|
597
|
+
|
598
|
+
|
567
599
|
df=pd.DataFrame(data={'Preferred D': 0,
|
568
600
|
'Corrected_Splitting': Split,
|
569
601
|
'Preferred D_σ': 0,
|
@@ -578,7 +610,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
578
610
|
'LowD_SC': LowD_SC,
|
579
611
|
'LowD_SC_σ': lowD_error['LowD_Density_σ'],
|
580
612
|
'MedD_SC': MedD_SC,
|
581
|
-
'MedD_SC_σ':
|
613
|
+
'MedD_SC_σ': MedD_err,
|
582
614
|
'HighD_SC': HighD_SC,
|
583
615
|
'HighD_SC_σ': highD_error['HighD_Density_σ'],
|
584
616
|
'Temperature': temp,
|
@@ -594,6 +626,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
594
626
|
# If splitting is 0
|
595
627
|
zero=df['Corrected_Splitting']==0
|
596
628
|
|
629
|
+
|
597
630
|
# Range for SC low density
|
598
631
|
min_lowD_SC_Split=df['Corrected_Splitting']>=102.7623598753032
|
599
632
|
max_lowD_SC_Split=df['Corrected_Splitting']<=103.1741034592534
|
@@ -634,12 +667,13 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
634
667
|
df.loc[ SupCrit&(min_HD_SC_Split&max_HD_SC_Split), 'Preferred D_σ_split'] = highD_error['HighD_Density_σ_split']
|
635
668
|
df.loc[ SupCrit&(min_HD_SC_Split&max_HD_SC_Split), 'Preferred D_σ_dens'] = highD_error['HighD_Density_σ_dens']
|
636
669
|
df.loc[ SupCrit&(min_HD_SC_Split&max_HD_SC_Split), 'Notes']='SupCrit, high density'
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
670
|
+
|
671
|
+
if temp!='RoomT':
|
672
|
+
df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D'] = MedD_SC
|
673
|
+
df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D_σ'] = medD_error['MedD_Density_σ']
|
674
|
+
df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D_σ_split'] = medD_error['MedD_Density_σ_split']
|
675
|
+
df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D_σ_dens'] = medD_error['MedD_Density_σ_dens']
|
676
|
+
df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Notes']='SupCrit, Med density'
|
643
677
|
|
644
678
|
# If SupCrit, low density
|
645
679
|
df.loc[ SupCrit&(min_lowD_SC_Split&max_lowD_SC_Split), 'Preferred D'] = LowD_SC
|
@@ -652,6 +686,26 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
652
686
|
df.loc[SupCrit&(Too_Low_SC), 'Preferred D']=LowD_SC
|
653
687
|
df.loc[SupCrit&(Too_Low_SC), 'Notes']='Below lower calibration limit'
|
654
688
|
df.loc[SupCrit&(Too_Low_SC), 'in range']='N'
|
689
|
+
|
690
|
+
|
691
|
+
|
692
|
+
# now lets do Room T ---------------------------------
|
693
|
+
df.loc[ roomT&(min_HD_SC_Split&max_HD_SC_Split), 'Preferred D'] = HighD_SC
|
694
|
+
df.loc[ roomT&(min_HD_SC_Split&max_HD_SC_Split), 'Preferred D_σ'] = highD_error['HighD_Density_σ']
|
695
|
+
df.loc[ roomT&(min_HD_SC_Split&max_HD_SC_Split), 'Preferred D_σ_split'] = highD_error['HighD_Density_σ_split']
|
696
|
+
df.loc[ roomT&(min_HD_SC_Split&max_HD_SC_Split), 'Preferred D_σ_dens'] = highD_error['HighD_Density_σ_dens']
|
697
|
+
df.loc[ roomT&(min_HD_SC_Split&max_HD_SC_Split), 'Notes']='roomT, high density'
|
698
|
+
|
699
|
+
# If roomT, low density
|
700
|
+
df.loc[ roomT&(min_lowD_SC_Split&max_lowD_SC_Split), 'Preferred D'] = LowD_SC
|
701
|
+
df.loc[ roomT&(min_lowD_SC_Split&max_lowD_SC_Split), 'Preferred D_σ'] = lowD_error['LowD_Density_σ']
|
702
|
+
df.loc[ roomT&(min_lowD_SC_Split&max_lowD_SC_Split), 'Preferred D_σ_split'] = lowD_error['LowD_Density_σ_split']
|
703
|
+
df.loc[ roomT&(min_lowD_SC_Split&max_lowD_SC_Split), 'Preferred D_σ_dens'] = lowD_error['LowD_Density_σ_dens']
|
704
|
+
df.loc[roomT&(min_lowD_SC_Split&max_lowD_SC_Split), 'Notes']='roomT, low density'
|
705
|
+
|
706
|
+
|
707
|
+
|
708
|
+
|
655
709
|
|
656
710
|
|
657
711
|
# If RoomT, and too low
|
@@ -731,21 +785,30 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
731
785
|
|
732
786
|
|
733
787
|
|
734
|
-
#
|
735
|
-
#
|
736
788
|
|
737
|
-
|
789
|
+
|
790
|
+
|
791
|
+
if Ne_pickle_str is not None: # If its not none, have all the columns for Ne
|
738
792
|
cols_to_move = ['filename', 'Density g/cm3', 'σ Density g/cm3','σ Density g/cm3 (from Ne+peakfit)', 'σ Density g/cm3 (from densimeter)',
|
739
793
|
'Corrected_Splitting', 'Corrected_Splitting_σ',
|
740
794
|
'Corrected_Splitting_σ_Ne', 'Corrected_Splitting_σ_peak_fit', 'power (mW)', 'Spectral Center']
|
741
795
|
df_merge = df_merge[cols_to_move + [
|
742
796
|
col for col in df_merge.columns if col not in cols_to_move]]
|
743
|
-
|
797
|
+
|
798
|
+
# If pref Ne is not none and you dont have a dataframe
|
799
|
+
elif pref_Ne is not None and df_combo is not None: #If Pref Ne,
|
744
800
|
cols_to_move = ['filename', 'Density g/cm3', 'σ Density g/cm3','σ Density g/cm3 (from Ne+peakfit)', 'σ Density g/cm3 (from densimeter)',
|
745
801
|
'Corrected_Splitting', 'Corrected_Splitting_σ',
|
746
802
|
'Corrected_Splitting_σ_Ne', 'Corrected_Splitting_σ_peak_fit']
|
747
803
|
df_merge = df_merge[cols_to_move + [
|
748
804
|
col for col in df_merge.columns if col not in cols_to_move]]
|
805
|
+
|
806
|
+
elif df_combo is None:
|
807
|
+
|
808
|
+
cols_to_move = ['Density g/cm3', 'σ Density g/cm3','σ Density g/cm3 (from Ne+peakfit)', 'σ Density g/cm3 (from densimeter)',
|
809
|
+
'Corrected_Splitting']
|
810
|
+
df_merge = df_merge[cols_to_move + [
|
811
|
+
col for col in df_merge.columns if col not in cols_to_move]]
|
749
812
|
|
750
813
|
|
751
814
|
|
@@ -906,7 +969,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
906
969
|
|
907
970
|
Parameters
|
908
971
|
-------------
|
909
|
-
Ne_line_combo: str, '1117_1447', '1220_1447', '1220_1400'
|
972
|
+
Ne_line_combo: str, '1117_1447', '1117_1400', '1220_1447', '1220_1400', '1220_1567'
|
910
973
|
Combination of Ne lines used for drift correction
|
911
974
|
|
912
975
|
Either:
|
@@ -1042,6 +1105,22 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
1042
1105
|
with open(DiadFit_dir/pickle_str_highr, 'rb') as f:
|
1043
1106
|
highrho_pickle_data = pickle.load(f)
|
1044
1107
|
|
1108
|
+
|
1109
|
+
if Ne_line_combo=='1220_1567':
|
1110
|
+
|
1111
|
+
pickle_str_lowr='Lowrho_polyfit_dataUCB_1220_1567.pkl'
|
1112
|
+
with open(DiadFit_dir/pickle_str_lowr, 'rb') as f:
|
1113
|
+
lowrho_pickle_data = pickle.load(f)
|
1114
|
+
|
1115
|
+
# This gets the densimeter at medium density
|
1116
|
+
pickle_str_medr='Mediumrho_polyfit_dataUCB_1220_1567.pkl'
|
1117
|
+
with open(DiadFit_dir/pickle_str_medr, 'rb') as f:
|
1118
|
+
medrho_pickle_data = pickle.load(f)
|
1119
|
+
# This gets the densimeter at high density.
|
1120
|
+
pickle_str_highr='Highrho_polyfit_dataUCB_1220_1567.pkl'
|
1121
|
+
with open(DiadFit_dir/pickle_str_highr, 'rb') as f:
|
1122
|
+
highrho_pickle_data = pickle.load(f)
|
1123
|
+
|
1045
1124
|
if Ne_line_combo=='1117_1400':
|
1046
1125
|
pickle_str_lowr='Lowrho_polyfit_dataUCB_1117_1400.pkl'
|
1047
1126
|
with open(DiadFit_dir/pickle_str_lowr, 'rb') as f:
|
@@ -1125,29 +1204,30 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
1125
1204
|
# If splitting is 0
|
1126
1205
|
zero=df['Corrected_Splitting']==0
|
1127
1206
|
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1207
|
+
|
1208
|
+
offset=0
|
1209
|
+
if Ne_line_combo=='1220_1400':
|
1210
|
+
offset=105.257-105.3438707618937
|
1211
|
+
|
1212
|
+
|
1213
|
+
|
1214
|
+
|
1215
|
+
|
1216
|
+
|
1217
|
+
min_lowD_SC_Split=df['Corrected_Splitting']>=102.7623598753032+offset
|
1218
|
+
max_lowD_SC_Split=df['Corrected_Splitting']<=103.1741034592534+offset
|
1131
1219
|
# Range for SC med density
|
1132
|
-
min_MD_SC_Split=df['Corrected_Splitting']>103.0608505403591
|
1133
|
-
max_MD_SC_Split=df['Corrected_Splitting']<=104.3836704771313
|
1220
|
+
min_MD_SC_Split=df['Corrected_Splitting']>103.0608505403591+offset
|
1221
|
+
max_MD_SC_Split=df['Corrected_Splitting']<=104.3836704771313+offset
|
1134
1222
|
# Range for SC high density
|
1135
|
-
min_HD_SC_Split=df['Corrected_Splitting']>=104.2538992302499
|
1136
|
-
max_HD_SC_Split=df['Corrected_Splitting']<=105.3438707618937
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
#
|
1141
|
-
min_HD_RoomT_Split=df['Corrected_Splitting']>=104.407308904012
|
1142
|
-
max_HD_RoomT_Split=df['Corrected_Splitting']<=105.1
|
1143
|
-
# Impossible densities, room T
|
1144
|
-
Imposs_lower_end=(df['Corrected_Splitting']>103.350311768435) & (df['Corrected_Splitting']<103.88)
|
1223
|
+
min_HD_SC_Split=df['Corrected_Splitting']>=104.2538992302499+offset
|
1224
|
+
max_HD_SC_Split=df['Corrected_Splitting']<=105.3438707618937+offset
|
1225
|
+
Too_Low_SC=df['Corrected_Splitting']<102.72+offset
|
1226
|
+
Too_Low_RT=df['Corrected_Splitting']<102.734115670188+offset
|
1227
|
+
|
1228
|
+
Imposs_lower_end=(df['Corrected_Splitting']>103.350311768435+offset) # & (df['Splitting']<103.88+offset)
|
1145
1229
|
# Impossible densities, room T
|
1146
|
-
Imposs_upper_end=(df['Corrected_Splitting']<
|
1147
|
-
# Too low density
|
1148
|
-
Too_Low_SC=df['Corrected_Splitting']<102.7623598753032
|
1149
|
-
Too_Low_RT=df['Corrected_Splitting']<102.734115670188
|
1150
|
-
|
1230
|
+
Imposs_upper_end=(df['Corrected_Splitting']<105.3438707618937+offset)# & (df['Splitting']>103.88+offset)
|
1151
1231
|
df.loc[zero, 'Preferred D']=0
|
1152
1232
|
df.loc[zero, 'Notes']=0
|
1153
1233
|
|
@@ -1276,5 +1356,67 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
1276
1356
|
|
1277
1357
|
|
1278
1358
|
return df_merge
|
1359
|
+
|
1360
|
+
## Method from FLuids laboratory from FRANCIS Program
|
1361
|
+
|
1362
|
+
|
1363
|
+
|
1364
|
+
def Francis_pureCO2(FDS, FDS_std, uncer_FDS, uncer_FDS_std=0):
|
1365
|
+
""" Returns density using a densimeter made from a single CO2 standard
|
1366
|
+
"""
|
1367
|
+
offset= 0.035089020233933815 # Calculated FDS at 0.01 g/cm3
|
1368
|
+
FDS_normalized_1=(FDS - FDS_std) + (uncer_FDS**2 + uncer_FDS_std**2)**0.5 + offset
|
1369
|
+
FDS_normalized=(FDS - FDS_std) + offset
|
1370
|
+
FDS_normalized_2=(FDS - FDS_std) - (uncer_FDS**2 + uncer_FDS_std**2)**0.5 + offset
|
1371
|
+
|
1372
|
+
p0= 0
|
1373
|
+
p1= 148.73
|
1374
|
+
p2= 20.946
|
1375
|
+
p3= -180.85
|
1376
|
+
p4= 96.503
|
1377
|
+
p5= -9.8157
|
1378
|
+
|
1379
|
+
d0= 0
|
1380
|
+
d1= +0.31273
|
1381
|
+
d2= +0.11155
|
1382
|
+
d3= -0.01843
|
1383
|
+
d4= -0.0044
|
1384
|
+
d5= 0
|
1385
|
+
|
1386
|
+
|
1387
|
+
pressure1 = p5*FDS_normalized_1**5 + p4*FDS_normalized_1**4 + p3*FDS_normalized_1**3 + p2*FDS_normalized_1**2 +p1*FDS_normalized_1**1 + p0
|
1388
|
+
pressure2 = p5*FDS_normalized_2**5 + p4*FDS_normalized_2**4 + p3*FDS_normalized_2**3 + p2*FDS_normalized_2**2 +p1*FDS_normalized_2**1 + p0
|
1389
|
+
pressure_final = (pressure1 + pressure2)/2
|
1390
|
+
uncer_pressure_final = 8.7 + (np.maximum(pressure1, pressure2) - np.minimum(pressure1, pressure2))/(2*np.sqrt(3)) #uncertainty=8
|
1391
|
+
|
1392
|
+
|
1393
|
+
density1 = d5*FDS_normalized_1**5 + d4*FDS_normalized_1**4 + d3*FDS_normalized_1**3 + d2*FDS_normalized_1**2 + d1*FDS_normalized_1**1 + d0
|
1394
|
+
density2 = d5*FDS_normalized_2**5 + d4*FDS_normalized_2**4 + d3*FDS_normalized_2**3 + d2*FDS_normalized_2**2 + d1*FDS_normalized_2**1 + d0
|
1395
|
+
|
1396
|
+
densityPW = d5*FDS_normalized**5 + d4*FDS_normalized**4 + d3*FDS_normalized**3 + d2*FDS_normalized**2 + d1*FDS_normalized**1 + d0
|
1397
|
+
|
1398
|
+
density_final = (density1 + density2)/2
|
1399
|
+
uncer_density_final = 0.006 + (np.maximum(density1,density2)-np.minimum(density1,density2))/(2*np.sqrt(3)) #uncertainty = 0.003
|
1400
|
+
|
1401
|
+
|
1402
|
+
if len(FDS)==1:
|
1403
|
+
df=pd.DataFrame(data={'Density': density_final,
|
1404
|
+
'Density_PW': densityPW,
|
1405
|
+
'Density_err': uncer_density_final,
|
1406
|
+
'Input_Split':FDS,
|
1407
|
+
'Split_err':uncer_FDS,
|
1408
|
+
'Split_Std':FDS_std,
|
1409
|
+
}, index=[0])
|
1410
|
+
else:
|
1411
|
+
df=pd.DataFrame(data={'Density': density_final,
|
1412
|
+
'Density_PW': densityPW,
|
1413
|
+
'Density_err': uncer_density_final,
|
1414
|
+
'Input_Split':FDS,
|
1415
|
+
'Split_err':uncer_FDS,
|
1416
|
+
'Split_Std':FDS_std,
|
1417
|
+
|
1418
|
+
})
|
1419
|
+
|
1420
|
+
return df
|
1279
1421
|
|
1280
1422
|
|
@@ -76,6 +76,33 @@ def ryan_lerner(P_kbar):
|
|
76
76
|
|
77
77
|
return D
|
78
78
|
|
79
|
+
|
80
|
+
def denlinger_lerner(P_kbar):
|
81
|
+
""" Calculates depth for a given pressure using the Parameterization of Denlinger and Flinders (2022) with the addition of 200 kg/m3 at shallow depths, from Lerner et al. (2024).
|
82
|
+
After 15 km returns NaN following Lerner
|
83
|
+
|
84
|
+
Parameters
|
85
|
+
-------------
|
86
|
+
P_kbar: int, float, pd.series
|
87
|
+
Pressure in kbar
|
88
|
+
|
89
|
+
Returns
|
90
|
+
-------------
|
91
|
+
Depth in km (same datatype as input)
|
92
|
+
|
93
|
+
|
94
|
+
"""
|
95
|
+
|
96
|
+
D=0.0684*P_kbar**3 - 0.5008*P_kbar**2 + 4.47*P_kbar
|
97
|
+
if D>15:
|
98
|
+
D=np.nan
|
99
|
+
|
100
|
+
return D
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
79
106
|
def mavko_debari(P_kbar):
|
80
107
|
""" Calculates depth for a given pressure using the parameterization of Mavko and Thompson (1983) and DeBari and Greene (2011)
|
81
108
|
as given in Putirka (2017) Down the Crater Elements supplement, used for Cascades
|
@@ -143,7 +170,7 @@ def prezzi(P_kbar):
|
|
143
170
|
return D
|
144
171
|
|
145
172
|
|
146
|
-
Profile_funcs={ryan_lerner, mavko_debari, hill_zucca, prezzi, rasmussen}
|
173
|
+
Profile_funcs={ryan_lerner, denlinger_lerner, mavko_debari, hill_zucca, prezzi, rasmussen}
|
147
174
|
Profile_funcs_by_name= {p.__name__: p for p in Profile_funcs}
|
148
175
|
|
149
176
|
|
@@ -223,7 +250,7 @@ def loop_pressure_depth_2step(P_kbar=None, d1=14, rho1=2800, rho2=3100, g=9.81):
|
|
223
250
|
depth_km_loop=convert_pressure_depth_2step(P_kbar,
|
224
251
|
d1=d1, rho1=rho1, rho2=rho2, g=g)
|
225
252
|
else:
|
226
|
-
depth_km_loop=np.
|
253
|
+
depth_km_loop=np.zeros(len(P_kbar))
|
227
254
|
for i in range(0, len(P_kbar)):
|
228
255
|
depth_km_loop[i]=convert_pressure_depth_2step(P_kbar[i],
|
229
256
|
d1=d1, rho1=rho1, rho2=rho2, g=g)
|
@@ -328,7 +355,7 @@ def loop_pressure_depth_3step(P_kbar=None, d1=5, d2=14,
|
|
328
355
|
d1=d1, rho1=rho1, rho2=rho2, g=g)
|
329
356
|
else:
|
330
357
|
|
331
|
-
depth_km_loop=np.
|
358
|
+
depth_km_loop=np.zeros(len(P_kbar))
|
332
359
|
for i in range(0, len(P_kbar)):
|
333
360
|
depth_km_loop[i]=convert_pressure_depth_3step(P_kbar[i],
|
334
361
|
d1=d1, d2=d2,rho1=rho1, rho2=rho2, rho3=rho3, g=g)
|
@@ -364,6 +391,11 @@ d1=None, d2=None,rho1=None, rho2=None, rho3=None, model=None):
|
|
364
391
|
Parameterization of Ryan 1987, actual equation from Lerner et al. 2021
|
365
392
|
After 16.88 km (455 MPa), assume density is 2.746, as density turns around again. This profile is tweaked for Hawaii
|
366
393
|
|
394
|
+
denlinger_lerner:
|
395
|
+
Parameterization of Denlinger and Flinders (2022) with the addition of 200 kg/m3 at shallow depths, from Lerner et al. (2024).
|
396
|
+
After 15 km returns NaN following Lerner
|
397
|
+
|
398
|
+
|
367
399
|
mavko_debari:
|
368
400
|
Parameterization of Mavko and Thompson (1983) and DeBari and Greene (2011)
|
369
401
|
as given in Putirka (2017) Down the Crater Elements supplement.
|
@@ -463,12 +495,12 @@ d1=None, d2=None,rho1=None, rho2=None, rho3=None, model=None):
|
|
463
495
|
D=func(P_kbar)
|
464
496
|
|
465
497
|
if isinstance(P_kbar, pd.Series):
|
466
|
-
D=np.
|
498
|
+
D=np.zeros(len(P_kbar), float)
|
467
499
|
for i in range(0, len(P_kbar)):
|
468
500
|
D[i]=func(P_kbar.iloc[i])
|
469
501
|
|
470
502
|
if isinstance(P_kbar, np.ndarray):
|
471
|
-
D=np.
|
503
|
+
D=np.zeros(len(P_kbar), float)
|
472
504
|
for i in range(0, len(P_kbar)):
|
473
505
|
D[i]=func(P_kbar[i])
|
474
506
|
|
DiadFit/diads.py
CHANGED
@@ -4,7 +4,7 @@ import matplotlib.pyplot as plt
|
|
4
4
|
from matplotlib import patches
|
5
5
|
import lmfit
|
6
6
|
from lmfit.models import GaussianModel, VoigtModel, LinearModel, ConstantModel, PseudoVoigtModel, Pearson4Model
|
7
|
-
from scipy.signal import find_peaks
|
7
|
+
from scipy.signal import find_peaks
|
8
8
|
import os
|
9
9
|
import re
|
10
10
|
from os import listdir
|
@@ -31,6 +31,17 @@ allowed_models = ["VoigtModel", "PseudoVoigtModel", "Pearson4Model", "SkewedVoig
|
|
31
31
|
encode="ISO-8859-1"
|
32
32
|
## Ratio of different peaks
|
33
33
|
|
34
|
+
|
35
|
+
def calculate_SO2_CO2_ratio(SO2_area, diad1_area, diad2_area, SO2_cross_sec=5.3, diad1_cross_sec=0.89, diad2_cross_sec=1.4):
|
36
|
+
""" Calculates SO2:CO2 ratio using the parameters from Marie-Camille Caumons lab"""
|
37
|
+
|
38
|
+
|
39
|
+
A_CO2_star=( diad1_area + diad2_area)/(diad2_cross_sec+diad1_cross_sec)
|
40
|
+
A_SO2_star=(SO2_area)/(SO2_cross_sec)
|
41
|
+
Ratio=A_SO2_star/(A_SO2_star+A_CO2_star)
|
42
|
+
|
43
|
+
return Ratio
|
44
|
+
|
34
45
|
def calculate_mole_fraction_2comp(peak_area_a, peak_area_b, cross_section_a, cross_section_b, instrument_eff_a, instrument_eff_b):
|
35
46
|
""" This function calculates the molar ration of 2 components a and b based on peak areas,
|
36
47
|
cross section and instrument efficiency
|
@@ -61,7 +72,9 @@ def calculate_mole_fraction_2comp(peak_area_a, peak_area_b, cross_section_a, cro
|
|
61
72
|
Sum_phase_a=peak_area_a/(cross_section_a*instrument_eff_a)
|
62
73
|
Sum_phase_b=peak_area_b/(cross_section_b*instrument_eff_b)
|
63
74
|
|
64
|
-
df=pd.DataFrame(data={'A
|
75
|
+
df=pd.DataFrame(data={'% A': 100*Sum_phase_a/(Sum_phase_b+Sum_phase_a),
|
76
|
+
'% B': 100-100*Sum_phase_a/(Sum_phase_b+Sum_phase_a)}
|
77
|
+
)
|
65
78
|
|
66
79
|
return df
|
67
80
|
def plot_diad(*,path=None, filename=None, filetype='Witec_ASCII', Spectra_x=None, Spectra_y=None):
|
@@ -613,8 +626,8 @@ def loop_approx_diad_fits(*, spectra_path, config, Diad_Files, filetype, plot_fi
|
|
613
626
|
# Now do for all files
|
614
627
|
fit_params = pd.DataFrame([])
|
615
628
|
x_cord=Diad[:, 0]
|
616
|
-
data_y_all=np.
|
617
|
-
data_x_all=np.
|
629
|
+
data_y_all=np.zeros([ len(x_cord), len(Diad_Files)], float)
|
630
|
+
data_x_all=np.zeros([ len(x_cord), len(Diad_Files)], float)
|
618
631
|
i=0
|
619
632
|
for file in tqdm(Diad_Files):
|
620
633
|
|
@@ -842,8 +855,8 @@ def identify_diad_group(*, fit_params, data_y, x_cord, filter_bool,y_fig_scale=
|
|
842
855
|
if np.shape(data_y)[1]==0:
|
843
856
|
Group1_df=pd.DataFrame().reindex_like(fit_params)
|
844
857
|
Groupnot1_df=pd.DataFrame().reindex_like(fit_params)
|
845
|
-
Group1_np_y=np.
|
846
|
-
Groupnot1_np_y=np.
|
858
|
+
Group1_np_y=np.zeros(0, dtype='float')
|
859
|
+
Groupnot1_np_y=np.zeros(0, dtype='float')
|
847
860
|
return Group1_df, Groupnot1_df, Group1_np_y, Groupnot1_np_y
|
848
861
|
|
849
862
|
else:
|
@@ -1647,7 +1660,6 @@ def fit_gaussian_voigt_generic_diad(config1, *, diad1=False, diad2=False, path=N
|
|
1647
1660
|
|
1648
1661
|
|
1649
1662
|
|
1650
|
-
|
1651
1663
|
# Calculate the amplitude from the sigma and the prominence
|
1652
1664
|
calc_diad_amplitude=((config1.diad_sigma)*(config1.diad_prom))/0.3939
|
1653
1665
|
calc_HB_amplitude=((config1.diad_sigma)*(config1.HB_prom))/0.3939
|
@@ -3186,6 +3198,7 @@ def fit_diad_1_w_bck(*, config1: diad1_fit_config=diad1_fit_config(), config2: d
|
|
3186
3198
|
else:
|
3187
3199
|
axc_xmin=config1.lower_bck_diad1[0]
|
3188
3200
|
axc_xmax=config1.upper_bck_diad1[1]
|
3201
|
+
|
3189
3202
|
axc_ymin=np.min(Baseline_diad1[:, 1])-config1.y_range_baseline
|
3190
3203
|
axc_ymax=np.max(Baseline_diad1[:, 1])+config1.y_range_baseline
|
3191
3204
|
|
@@ -3419,6 +3432,44 @@ def calculate_HB_Diad_area_ratio(df):
|
|
3419
3432
|
|
3420
3433
|
@dataclass
|
3421
3434
|
class generic_peak_config:
|
3435
|
+
"""
|
3436
|
+
Configuration class for fitting secondary peaks (e.g. SO2, Carbonate)
|
3437
|
+
|
3438
|
+
Attributes:
|
3439
|
+
name (str): Default 'Generic'
|
3440
|
+
Name of component you are fitting that gets stamped onto the peak parameters, e.g. if 'SO2', get Peak_Area_SO2'
|
3441
|
+
|
3442
|
+
lower_bck, upper_bck: Tuple[float, float]
|
3443
|
+
Background positions in wavenumbers
|
3444
|
+
|
3445
|
+
model_name: Default 'PseudoVoigt'
|
3446
|
+
Type of peak fit. Choose from 'GaussianModel', 'VoigtModel', 'PseudoVoigtModel', 'Spline'.
|
3447
|
+
|
3448
|
+
x_range_bck: float (default 10)
|
3449
|
+
When showing bck collected plot, shows peak center +- this amount
|
3450
|
+
|
3451
|
+
N_poly_carb_bck: float (default 1)
|
3452
|
+
Degree of polynomial to fit to background.
|
3453
|
+
|
3454
|
+
amplitude: float (default 100)
|
3455
|
+
Approximate amplitude of peak fit (first guess for Gaussian , voigt and Psuedovoigt needed)
|
3456
|
+
|
3457
|
+
cent: float (default 1090)
|
3458
|
+
Approximate peak position of species you are looking for. E.g. 1090 for CO2, 1150 for SO2
|
3459
|
+
|
3460
|
+
outlier_sigma: float (default 12)
|
3461
|
+
Code calculates standard deviation of background, and excludes points more than outlier_sigma*this standard deviatoin from nearby background points
|
3462
|
+
|
3463
|
+
distance, prominence, width, threshold, height: float
|
3464
|
+
Scipy find peak parameters to get initial fit of peak
|
3465
|
+
|
3466
|
+
|
3467
|
+
|
3468
|
+
|
3469
|
+
fit_peaks (int): Default 2
|
3470
|
+
Number of peaks to fit. 2 = Diad + HB, 1 = Diad.
|
3471
|
+
|
3472
|
+
"""
|
3422
3473
|
|
3423
3474
|
# Name that gets stamped onto fits
|
3424
3475
|
name: str= 'generic'
|
@@ -3566,24 +3617,24 @@ path=None, filename=None, filetype=None,
|
|
3566
3617
|
# To make a nice plot, give 50 wavenumber units on either side as a buffer
|
3567
3618
|
Spectra_plot=Spectra[ (Spectra[:,0]>lower_0baseline-50) & (Spectra[:,0]<upper_1baseline+50) ]
|
3568
3619
|
|
3569
|
-
# Find peaks using Scipy find peaks
|
3620
|
+
# # Find peaks using Scipy find peaks
|
3570
3621
|
y=Spectra_fit[:, 1]
|
3571
3622
|
x=Spectra_fit[:, 0]
|
3572
3623
|
spec_res=np.abs(x[0]-x[1])
|
3573
|
-
|
3574
|
-
|
3575
|
-
peaks = find_peaks(y,height = config.height, threshold = config.threshold,
|
3576
|
-
distance = config.distance, prominence=config.prominence, width=config.width)
|
3577
|
-
|
3578
|
-
height = peaks[1]['peak_heights'] #list of the heights of the peaks
|
3579
|
-
peak_pos = x[peaks[0]] #list of the peaks positions
|
3580
|
-
df_sort=pd.DataFrame(data={'pos': peak_pos,
|
3581
|
-
|
3582
|
-
|
3583
|
-
df_peak_sort=df_sort.sort_values('height', axis=0, ascending=False)
|
3584
|
-
|
3585
|
-
# Trim number of peaks based on user-defined N peaks
|
3586
|
-
df_peak_sort_short=df_peak_sort[0:config.N_peaks]
|
3624
|
+
#
|
3625
|
+
#
|
3626
|
+
# peaks = find_peaks(y,height = config.height, threshold = config.threshold,
|
3627
|
+
# distance = config.distance, prominence=config.prominence, width=config.width)
|
3628
|
+
#
|
3629
|
+
# height = peaks[1]['peak_heights'] #list of the heights of the peaks
|
3630
|
+
# peak_pos = x[peaks[0]] #list of the peaks positions
|
3631
|
+
# df_sort=pd.DataFrame(data={'pos': peak_pos,
|
3632
|
+
# 'height': height})
|
3633
|
+
#
|
3634
|
+
# df_peak_sort=df_sort.sort_values('height', axis=0, ascending=False)
|
3635
|
+
#
|
3636
|
+
# # Trim number of peaks based on user-defined N peaks
|
3637
|
+
# df_peak_sort_short=df_peak_sort[0:config.N_peaks]
|
3587
3638
|
|
3588
3639
|
|
3589
3640
|
# Get actual baseline
|
@@ -3828,33 +3879,19 @@ path=None, filename=None, filetype=None,
|
|
3828
3879
|
|
3829
3880
|
if config.model_name != 'Spline' and config.model_name != 'Poly':
|
3830
3881
|
ax2.plot(xx_carb, y_carb, '-k', label='Peak fit')
|
3831
|
-
|
3832
|
-
|
3882
|
+
|
3883
|
+
|
3833
3884
|
else:
|
3834
3885
|
ax2.plot(x_new, Baseline_ysub_sil, '-k')
|
3835
3886
|
ax2.fill_between(x_new, Baseline_ysub_sil, color='yellow', label='fit area', alpha=0.5)
|
3836
3887
|
|
3837
3888
|
|
3838
|
-
|
3839
|
-
|
3840
|
-
|
3841
|
-
|
3842
|
-
|
3843
|
-
|
3889
|
+
cent=df['Peak_Cent_{}'.format(name)].iloc[0]
|
3890
|
+
ax2.set_xlim([cent-config.x_range_bck, cent+config.x_range_bck])
|
3844
3891
|
|
3892
|
+
ax2.set_title('Bkg-subtracted, ' + name + ' peak fit')
|
3845
3893
|
|
3846
3894
|
|
3847
|
-
# ax2.set_ylim([min(y_carb)-0.5*(max(y_carb)-min(y_carb)),
|
3848
|
-
# max(y_carb)+0.1*max(y_carb),
|
3849
|
-
# ])
|
3850
|
-
|
3851
|
-
|
3852
|
-
|
3853
|
-
if find_peaks is True:
|
3854
|
-
|
3855
|
-
ax1.plot(df_peak_sort_short['pos'], df_peak_sort_short['height'], '*k', mfc='yellow', label='SciPy Peaks')
|
3856
|
-
ax1.plot(Spectra_short[:, 0], Py_base, '-k')
|
3857
|
-
|
3858
3895
|
ax1.set_ylabel('Intensity')
|
3859
3896
|
ax1.set_xlabel('Wavenumber (cm$^{-1}$)')
|
3860
3897
|
ax2.set_ylabel('Bck-corrected Intensity')
|
@@ -4010,15 +4047,15 @@ def plot_secondary_peaks(*, Diad_Files, path, filetype,
|
|
4010
4047
|
|
4011
4048
|
i=0
|
4012
4049
|
Y=0
|
4013
|
-
peak_pos_saved=np.
|
4014
|
-
peak_prom_saved=np.
|
4015
|
-
peak_height_saved=np.
|
4016
|
-
peak_bck=np.
|
4017
|
-
y_star=np.
|
4018
|
-
yplot=np.
|
4050
|
+
peak_pos_saved=np.zeros(len(Diad_Files), dtype=float)
|
4051
|
+
peak_prom_saved=np.zeros(len(Diad_Files), dtype=float)
|
4052
|
+
peak_height_saved=np.zeros(len(Diad_Files), dtype=float)
|
4053
|
+
peak_bck=np.zeros(len(Diad_Files), dtype=float)
|
4054
|
+
y_star=np.zeros(len(Diad_Files), dtype=float)
|
4055
|
+
yplot=np.zeros(len(Diad_Files), dtype=float)
|
4019
4056
|
Diad_df=get_data(path=path, filename=Diad_Files[0], filetype=filetype)
|
4020
4057
|
x_data=Diad_df[:, 0]
|
4021
|
-
y_data=np.
|
4058
|
+
y_data=np.zeros([ len(x_data), len(Diad_Files)], float)
|
4022
4059
|
|
4023
4060
|
|
4024
4061
|
for file in Diad_Files:
|