DiadFit 0.0.85__py3-none-any.whl → 0.0.90__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.
Files changed (33) hide show
  1. DiadFit/CO2_EOS.py +2 -2
  2. DiadFit/CO2_H2O_EOS.py +8 -8
  3. DiadFit/CO2_in_bubble_error.py +190 -112
  4. DiadFit/Highrho_polyfit_dataUCB_1117_1400.pkl +0 -0
  5. DiadFit/Highrho_polyfit_dataUCB_1117_1447.pkl +0 -0
  6. DiadFit/Highrho_polyfit_dataUCB_1220_1400.pkl +0 -0
  7. DiadFit/Highrho_polyfit_dataUCB_1220_1447.pkl +0 -0
  8. DiadFit/Highrho_polyfit_dataUCB_1220_1567.pkl +0 -0
  9. DiadFit/Highrho_polyfit_data_CMASS_24C.pkl +0 -0
  10. DiadFit/Lowrho_polyfit_dataUCB_1117_1400.pkl +0 -0
  11. DiadFit/Lowrho_polyfit_dataUCB_1117_1447.pkl +0 -0
  12. DiadFit/Lowrho_polyfit_dataUCB_1220_1400.pkl +0 -0
  13. DiadFit/Lowrho_polyfit_dataUCB_1220_1447.pkl +0 -0
  14. DiadFit/Lowrho_polyfit_dataUCB_1220_1567.pkl +0 -0
  15. DiadFit/Lowrho_polyfit_data_CMASS_24C.pkl +0 -0
  16. DiadFit/Mediumrho_polyfit_dataUCB_1117_1400.pkl +0 -0
  17. DiadFit/Mediumrho_polyfit_dataUCB_1117_1447.pkl +0 -0
  18. DiadFit/Mediumrho_polyfit_dataUCB_1220_1400.pkl +0 -0
  19. DiadFit/Mediumrho_polyfit_dataUCB_1220_1447.pkl +0 -0
  20. DiadFit/Mediumrho_polyfit_dataUCB_1220_1567.pkl +0 -0
  21. DiadFit/_version.py +1 -1
  22. DiadFit/densimeter_fitting.py +7 -1
  23. DiadFit/densimeters.py +183 -40
  24. DiadFit/density_depth_crustal_profiles.py +37 -5
  25. DiadFit/diads.py +28 -13
  26. DiadFit/error_propagation.py +185 -234
  27. DiadFit/importing_data_files.py +81 -15
  28. DiadFit/ne_lines.py +51 -23
  29. {DiadFit-0.0.85.dist-info → DiadFit-0.0.90.dist-info}/METADATA +1 -1
  30. DiadFit-0.0.90.dist-info/RECORD +50 -0
  31. DiadFit-0.0.85.dist-info/RECORD +0 -42
  32. {DiadFit-0.0.85.dist-info → DiadFit-0.0.90.dist-info}/WHEEL +0 -0
  33. {DiadFit-0.0.85.dist-info → DiadFit-0.0.90.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
- if temp=='RoomT':
502
- raise TypeError('Sorry, this function doesnt yet support the calibration at 24C, please enter temp=SupCrit')
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,8 @@ 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':
515
+ print('yes')
513
516
  # This gets the densimeter at low density
514
517
  pickle_str_lowr='Lowrho_polyfit_data_CMASS.pkl'
515
518
  with open(DiadFit_dir/pickle_str_lowr, 'rb') as f:
@@ -523,6 +526,25 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
523
526
  pickle_str_highr='Highrho_polyfit_data_CMASS.pkl'
524
527
  with open(DiadFit_dir/pickle_str_highr, 'rb') as f:
525
528
  highrho_pickle_data = pickle.load(f)
529
+
530
+
531
+
532
+
533
+ elif lab=='CMASS' and temp=='RoomT':
534
+ # This gets the densimeter at low density
535
+ pickle_str_lowr='Lowrho_polyfit_data_CMASS_24C.pkl'
536
+ with open(DiadFit_dir/pickle_str_lowr, 'rb') as f:
537
+ lowrho_pickle_data = pickle.load(f)
538
+
539
+
540
+ # This gets the densimeter at high density.
541
+ pickle_str_highr='Highrho_polyfit_data_CMASS_24C.pkl'
542
+ with open(DiadFit_dir/pickle_str_highr, 'rb') as f:
543
+ highrho_pickle_data = pickle.load(f)
544
+
545
+
546
+
547
+
526
548
  elif lab=='CCMR':
527
549
  pickle_str_lowr='Lowrho_polyfit_data_CCMR.pkl'
528
550
  with open(DiadFit_dir/pickle_str_lowr, 'rb') as f:
@@ -543,7 +565,13 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
543
565
 
544
566
  # this allocates the model
545
567
  lowrho_model = lowrho_pickle_data['model']
546
- medrho_model = medrho_pickle_data['model']
568
+
569
+ if temp=='SupCrit':
570
+ medrho_model = medrho_pickle_data['model']
571
+ MedD_SC = pd.Series(medrho_model(Split), index=Split.index)
572
+ medD_error=calculate_Densimeter_std_err_values(corrected_split=Split, corrected_split_err=Split_err,
573
+ pickle_str=pickle_str_medr, CI_dens=CI_neon, CI_split=CI_split, str_d='MedD')
574
+
547
575
  highrho_model = highrho_pickle_data['model']
548
576
 
549
577
  # Each of these lines get the density, and then the error on that density.
@@ -551,10 +579,8 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
551
579
  LowD_SC = pd.Series(lowrho_model(Split), index=Split.index)
552
580
  lowD_error=calculate_Densimeter_std_err_values(corrected_split=Split, corrected_split_err=Split_err,
553
581
  pickle_str=pickle_str_lowr, CI_dens=CI_neon, CI_split=CI_split, str_d='LowD')
582
+
554
583
 
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
584
 
559
585
  HighD_SC = pd.Series(highrho_model(Split), index=Split.index)
560
586
  highD_error=calculate_Densimeter_std_err_values(corrected_split=Split, corrected_split_err=Split_err,
@@ -563,7 +589,14 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
563
589
 
564
590
 
565
591
 
566
-
592
+ if temp=='RoomT':
593
+ MedD_SC=np.nan
594
+ MedD_err=np.nan
595
+
596
+ else:
597
+ MedD_err=medD_error['MedD_Density_σ']
598
+
599
+
567
600
  df=pd.DataFrame(data={'Preferred D': 0,
568
601
  'Corrected_Splitting': Split,
569
602
  'Preferred D_σ': 0,
@@ -578,7 +611,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
578
611
  'LowD_SC': LowD_SC,
579
612
  'LowD_SC_σ': lowD_error['LowD_Density_σ'],
580
613
  'MedD_SC': MedD_SC,
581
- 'MedD_SC_σ': medD_error['MedD_Density_σ'],
614
+ 'MedD_SC_σ': MedD_err,
582
615
  'HighD_SC': HighD_SC,
583
616
  'HighD_SC_σ': highD_error['HighD_Density_σ'],
584
617
  'Temperature': temp,
@@ -594,6 +627,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
594
627
  # If splitting is 0
595
628
  zero=df['Corrected_Splitting']==0
596
629
 
630
+
597
631
  # Range for SC low density
598
632
  min_lowD_SC_Split=df['Corrected_Splitting']>=102.7623598753032
599
633
  max_lowD_SC_Split=df['Corrected_Splitting']<=103.1741034592534
@@ -634,12 +668,13 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
634
668
  df.loc[ SupCrit&(min_HD_SC_Split&max_HD_SC_Split), 'Preferred D_σ_split'] = highD_error['HighD_Density_σ_split']
635
669
  df.loc[ SupCrit&(min_HD_SC_Split&max_HD_SC_Split), 'Preferred D_σ_dens'] = highD_error['HighD_Density_σ_dens']
636
670
  df.loc[ SupCrit&(min_HD_SC_Split&max_HD_SC_Split), 'Notes']='SupCrit, high density'
637
- # If SupCrit, Med density
638
- df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D'] = MedD_SC
639
- df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D_σ'] = medD_error['MedD_Density_σ']
640
- df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D_σ_split'] = medD_error['MedD_Density_σ_split']
641
- df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D_σ_dens'] = medD_error['MedD_Density_σ_dens']
642
- df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Notes']='SupCrit, Med density'
671
+
672
+ if temp!='RoomT':
673
+ df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D'] = MedD_SC
674
+ df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D_σ'] = medD_error['MedD_Density_σ']
675
+ df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D_σ_split'] = medD_error['MedD_Density_σ_split']
676
+ df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D_σ_dens'] = medD_error['MedD_Density_σ_dens']
677
+ df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Notes']='SupCrit, Med density'
643
678
 
644
679
  # If SupCrit, low density
645
680
  df.loc[ SupCrit&(min_lowD_SC_Split&max_lowD_SC_Split), 'Preferred D'] = LowD_SC
@@ -652,6 +687,26 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
652
687
  df.loc[SupCrit&(Too_Low_SC), 'Preferred D']=LowD_SC
653
688
  df.loc[SupCrit&(Too_Low_SC), 'Notes']='Below lower calibration limit'
654
689
  df.loc[SupCrit&(Too_Low_SC), 'in range']='N'
690
+
691
+
692
+
693
+ # now lets do Room T ---------------------------------
694
+ df.loc[ roomT&(min_HD_SC_Split&max_HD_SC_Split), 'Preferred D'] = HighD_SC
695
+ df.loc[ roomT&(min_HD_SC_Split&max_HD_SC_Split), 'Preferred D_σ'] = highD_error['HighD_Density_σ']
696
+ df.loc[ roomT&(min_HD_SC_Split&max_HD_SC_Split), 'Preferred D_σ_split'] = highD_error['HighD_Density_σ_split']
697
+ df.loc[ roomT&(min_HD_SC_Split&max_HD_SC_Split), 'Preferred D_σ_dens'] = highD_error['HighD_Density_σ_dens']
698
+ df.loc[ roomT&(min_HD_SC_Split&max_HD_SC_Split), 'Notes']='roomT, high density'
699
+
700
+ # If roomT, low density
701
+ df.loc[ roomT&(min_lowD_SC_Split&max_lowD_SC_Split), 'Preferred D'] = LowD_SC
702
+ df.loc[ roomT&(min_lowD_SC_Split&max_lowD_SC_Split), 'Preferred D_σ'] = lowD_error['LowD_Density_σ']
703
+ df.loc[ roomT&(min_lowD_SC_Split&max_lowD_SC_Split), 'Preferred D_σ_split'] = lowD_error['LowD_Density_σ_split']
704
+ df.loc[ roomT&(min_lowD_SC_Split&max_lowD_SC_Split), 'Preferred D_σ_dens'] = lowD_error['LowD_Density_σ_dens']
705
+ df.loc[roomT&(min_lowD_SC_Split&max_lowD_SC_Split), 'Notes']='roomT, low density'
706
+
707
+
708
+
709
+
655
710
 
656
711
 
657
712
  # If RoomT, and too low
@@ -731,21 +786,30 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
731
786
 
732
787
 
733
788
 
734
- #
735
- #
736
789
 
737
- if Ne_pickle_str is not None:
790
+
791
+
792
+ if Ne_pickle_str is not None: # If its not none, have all the columns for Ne
738
793
  cols_to_move = ['filename', 'Density g/cm3', 'σ Density g/cm3','σ Density g/cm3 (from Ne+peakfit)', 'σ Density g/cm3 (from densimeter)',
739
794
  'Corrected_Splitting', 'Corrected_Splitting_σ',
740
795
  'Corrected_Splitting_σ_Ne', 'Corrected_Splitting_σ_peak_fit', 'power (mW)', 'Spectral Center']
741
796
  df_merge = df_merge[cols_to_move + [
742
797
  col for col in df_merge.columns if col not in cols_to_move]]
743
- elif pref_Ne is not None:
798
+
799
+ # If pref Ne is not none and you dont have a dataframe
800
+ elif pref_Ne is not None and df_combo is not None: #If Pref Ne,
744
801
  cols_to_move = ['filename', 'Density g/cm3', 'σ Density g/cm3','σ Density g/cm3 (from Ne+peakfit)', 'σ Density g/cm3 (from densimeter)',
745
802
  'Corrected_Splitting', 'Corrected_Splitting_σ',
746
803
  'Corrected_Splitting_σ_Ne', 'Corrected_Splitting_σ_peak_fit']
747
804
  df_merge = df_merge[cols_to_move + [
748
805
  col for col in df_merge.columns if col not in cols_to_move]]
806
+
807
+ elif df_combo is None:
808
+
809
+ cols_to_move = ['Density g/cm3', 'σ Density g/cm3','σ Density g/cm3 (from Ne+peakfit)', 'σ Density g/cm3 (from densimeter)',
810
+ 'Corrected_Splitting']
811
+ df_merge = df_merge[cols_to_move + [
812
+ col for col in df_merge.columns if col not in cols_to_move]]
749
813
 
750
814
 
751
815
 
@@ -906,7 +970,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
906
970
 
907
971
  Parameters
908
972
  -------------
909
- Ne_line_combo: str, '1117_1447', '1220_1447', '1220_1400'
973
+ Ne_line_combo: str, '1117_1447', '1117_1400', '1220_1447', '1220_1400', '1220_1567'
910
974
  Combination of Ne lines used for drift correction
911
975
 
912
976
  Either:
@@ -1042,6 +1106,22 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
1042
1106
  with open(DiadFit_dir/pickle_str_highr, 'rb') as f:
1043
1107
  highrho_pickle_data = pickle.load(f)
1044
1108
 
1109
+
1110
+ if Ne_line_combo=='1220_1567':
1111
+
1112
+ pickle_str_lowr='Lowrho_polyfit_dataUCB_1220_1567.pkl'
1113
+ with open(DiadFit_dir/pickle_str_lowr, 'rb') as f:
1114
+ lowrho_pickle_data = pickle.load(f)
1115
+
1116
+ # This gets the densimeter at medium density
1117
+ pickle_str_medr='Mediumrho_polyfit_dataUCB_1220_1567.pkl'
1118
+ with open(DiadFit_dir/pickle_str_medr, 'rb') as f:
1119
+ medrho_pickle_data = pickle.load(f)
1120
+ # This gets the densimeter at high density.
1121
+ pickle_str_highr='Highrho_polyfit_dataUCB_1220_1567.pkl'
1122
+ with open(DiadFit_dir/pickle_str_highr, 'rb') as f:
1123
+ highrho_pickle_data = pickle.load(f)
1124
+
1045
1125
  if Ne_line_combo=='1117_1400':
1046
1126
  pickle_str_lowr='Lowrho_polyfit_dataUCB_1117_1400.pkl'
1047
1127
  with open(DiadFit_dir/pickle_str_lowr, 'rb') as f:
@@ -1125,29 +1205,30 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
1125
1205
  # If splitting is 0
1126
1206
  zero=df['Corrected_Splitting']==0
1127
1207
 
1128
- # Range for SC low density
1129
- min_lowD_SC_Split=df['Corrected_Splitting']>=102.7623598753032
1130
- max_lowD_SC_Split=df['Corrected_Splitting']<=103.1741034592534
1208
+
1209
+ offset=0
1210
+ if Ne_line_combo=='1220_1400':
1211
+ offset=105.257-105.3438707618937
1212
+
1213
+
1214
+
1215
+
1216
+
1217
+
1218
+ min_lowD_SC_Split=df['Corrected_Splitting']>=102.7623598753032+offset
1219
+ max_lowD_SC_Split=df['Corrected_Splitting']<=103.1741034592534+offset
1131
1220
  # 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
1221
+ min_MD_SC_Split=df['Corrected_Splitting']>103.0608505403591+offset
1222
+ max_MD_SC_Split=df['Corrected_Splitting']<=104.3836704771313+offset
1134
1223
  # 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
- # Range for Room T low density
1138
- min_lowD_RoomT_Split=df['Corrected_Splitting']>=102.734115670188
1139
- max_lowD_RoomT_Split=df['Corrected_Splitting']<=103.350311768435
1140
- # Range for Room T high density
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)
1224
+ min_HD_SC_Split=df['Corrected_Splitting']>=104.2538992302499+offset
1225
+ max_HD_SC_Split=df['Corrected_Splitting']<=105.3438707618937+offset
1226
+ Too_Low_SC=df['Corrected_Splitting']<102.72+offset
1227
+ Too_Low_RT=df['Corrected_Splitting']<102.734115670188+offset
1228
+
1229
+ Imposs_lower_end=(df['Corrected_Splitting']>103.350311768435+offset) # & (df['Splitting']<103.88+offset)
1145
1230
  # Impossible densities, room T
1146
- Imposs_upper_end=(df['Corrected_Splitting']<104.407308904012) & (df['Corrected_Splitting']>103.88)
1147
- # Too low density
1148
- Too_Low_SC=df['Corrected_Splitting']<102.7623598753032
1149
- Too_Low_RT=df['Corrected_Splitting']<102.734115670188
1150
-
1231
+ Imposs_upper_end=(df['Corrected_Splitting']<105.3438707618937+offset)# & (df['Splitting']>103.88+offset)
1151
1232
  df.loc[zero, 'Preferred D']=0
1152
1233
  df.loc[zero, 'Notes']=0
1153
1234
 
@@ -1276,5 +1357,67 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
1276
1357
 
1277
1358
 
1278
1359
  return df_merge
1360
+
1361
+ ## Method from FLuids laboratory from FRANCIS Program
1362
+
1363
+
1364
+
1365
+ def Francis_pureCO2(FDS, FDS_std, uncer_FDS, uncer_FDS_std=0):
1366
+ """ Returns density using a densimeter made from a single CO2 standard
1367
+ """
1368
+ offset= 0.035089020233933815 # Calculated FDS at 0.01 g/cm3
1369
+ FDS_normalized_1=(FDS - FDS_std) + (uncer_FDS**2 + uncer_FDS_std**2)**0.5 + offset
1370
+ FDS_normalized=(FDS - FDS_std) + offset
1371
+ FDS_normalized_2=(FDS - FDS_std) - (uncer_FDS**2 + uncer_FDS_std**2)**0.5 + offset
1372
+
1373
+ p0= 0
1374
+ p1= 148.73
1375
+ p2= 20.946
1376
+ p3= -180.85
1377
+ p4= 96.503
1378
+ p5= -9.8157
1379
+
1380
+ d0= 0
1381
+ d1= +0.31273
1382
+ d2= +0.11155
1383
+ d3= -0.01843
1384
+ d4= -0.0044
1385
+ d5= 0
1386
+
1387
+
1388
+ 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
1389
+ 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
1390
+ pressure_final = (pressure1 + pressure2)/2
1391
+ uncer_pressure_final = 8.7 + (np.maximum(pressure1, pressure2) - np.minimum(pressure1, pressure2))/(2*np.sqrt(3)) #uncertainty=8
1392
+
1393
+
1394
+ 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
1395
+ 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
1396
+
1397
+ densityPW = d5*FDS_normalized**5 + d4*FDS_normalized**4 + d3*FDS_normalized**3 + d2*FDS_normalized**2 + d1*FDS_normalized**1 + d0
1398
+
1399
+ density_final = (density1 + density2)/2
1400
+ uncer_density_final = 0.006 + (np.maximum(density1,density2)-np.minimum(density1,density2))/(2*np.sqrt(3)) #uncertainty = 0.003
1401
+
1402
+
1403
+ if len(FDS)==1:
1404
+ df=pd.DataFrame(data={'Density': density_final,
1405
+ 'Density_PW': densityPW,
1406
+ 'Density_err': uncer_density_final,
1407
+ 'Input_Split':FDS,
1408
+ 'Split_err':uncer_FDS,
1409
+ 'Split_Std':FDS_std,
1410
+ }, index=[0])
1411
+ else:
1412
+ df=pd.DataFrame(data={'Density': density_final,
1413
+ 'Density_PW': densityPW,
1414
+ 'Density_err': uncer_density_final,
1415
+ 'Input_Split':FDS,
1416
+ 'Split_err':uncer_FDS,
1417
+ 'Split_Std':FDS_std,
1418
+
1419
+ })
1420
+
1421
+ return df
1279
1422
 
1280
1423
 
@@ -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.empty(len(P_kbar))
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.empty(len(P_kbar))
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.empty(len(P_kbar), float)
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.empty(len(P_kbar), float)
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,9 @@ 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, gaussian
7
+ from scipy.signal import find_peaks
8
+ from scipy.signal.windows import gaussian
9
+
8
10
  import os
9
11
  import re
10
12
  from os import listdir
@@ -31,6 +33,17 @@ allowed_models = ["VoigtModel", "PseudoVoigtModel", "Pearson4Model", "SkewedVoig
31
33
  encode="ISO-8859-1"
32
34
  ## Ratio of different peaks
33
35
 
36
+
37
+ 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):
38
+ """ Calculates SO2:CO2 ratio using the parameters from Marie-Camille Caumons lab"""
39
+
40
+
41
+ A_CO2_star=( diad1_area + diad2_area)/(diad2_cross_sec+diad1_cross_sec)
42
+ A_SO2_star=(SO2_area)/(SO2_cross_sec)
43
+ Ratio=A_SO2_star/(A_SO2_star+A_CO2_star)
44
+
45
+ return Ratio
46
+
34
47
  def calculate_mole_fraction_2comp(peak_area_a, peak_area_b, cross_section_a, cross_section_b, instrument_eff_a, instrument_eff_b):
35
48
  """ This function calculates the molar ration of 2 components a and b based on peak areas,
36
49
  cross section and instrument efficiency
@@ -61,7 +74,9 @@ def calculate_mole_fraction_2comp(peak_area_a, peak_area_b, cross_section_a, cro
61
74
  Sum_phase_a=peak_area_a/(cross_section_a*instrument_eff_a)
62
75
  Sum_phase_b=peak_area_b/(cross_section_b*instrument_eff_b)
63
76
 
64
- df=pd.DataFrame(data={'A:B molar ratio': Sum_phase_a/Sum_phase_b})
77
+ df=pd.DataFrame(data={'% A': 100*Sum_phase_a/(Sum_phase_b+Sum_phase_a),
78
+ '% B': 100-100*Sum_phase_a/(Sum_phase_b+Sum_phase_a)}
79
+ )
65
80
 
66
81
  return df
67
82
  def plot_diad(*,path=None, filename=None, filetype='Witec_ASCII', Spectra_x=None, Spectra_y=None):
@@ -613,8 +628,8 @@ def loop_approx_diad_fits(*, spectra_path, config, Diad_Files, filetype, plot_fi
613
628
  # Now do for all files
614
629
  fit_params = pd.DataFrame([])
615
630
  x_cord=Diad[:, 0]
616
- data_y_all=np.empty([ len(x_cord), len(Diad_Files)], float)
617
- data_x_all=np.empty([ len(x_cord), len(Diad_Files)], float)
631
+ data_y_all=np.zeros([ len(x_cord), len(Diad_Files)], float)
632
+ data_x_all=np.zeros([ len(x_cord), len(Diad_Files)], float)
618
633
  i=0
619
634
  for file in tqdm(Diad_Files):
620
635
 
@@ -842,8 +857,8 @@ def identify_diad_group(*, fit_params, data_y, x_cord, filter_bool,y_fig_scale=
842
857
  if np.shape(data_y)[1]==0:
843
858
  Group1_df=pd.DataFrame().reindex_like(fit_params)
844
859
  Groupnot1_df=pd.DataFrame().reindex_like(fit_params)
845
- Group1_np_y=np.empty(0, dtype='float')
846
- Groupnot1_np_y=np.empty(0, dtype='float')
860
+ Group1_np_y=np.zeros(0, dtype='float')
861
+ Groupnot1_np_y=np.zeros(0, dtype='float')
847
862
  return Group1_df, Groupnot1_df, Group1_np_y, Groupnot1_np_y
848
863
 
849
864
  else:
@@ -4034,15 +4049,15 @@ def plot_secondary_peaks(*, Diad_Files, path, filetype,
4034
4049
 
4035
4050
  i=0
4036
4051
  Y=0
4037
- peak_pos_saved=np.empty(len(Diad_Files), dtype=float)
4038
- peak_prom_saved=np.empty(len(Diad_Files), dtype=float)
4039
- peak_height_saved=np.empty(len(Diad_Files), dtype=float)
4040
- peak_bck=np.empty(len(Diad_Files), dtype=float)
4041
- y_star=np.empty(len(Diad_Files), dtype=float)
4042
- yplot=np.empty(len(Diad_Files), dtype=float)
4052
+ peak_pos_saved=np.zeros(len(Diad_Files), dtype=float)
4053
+ peak_prom_saved=np.zeros(len(Diad_Files), dtype=float)
4054
+ peak_height_saved=np.zeros(len(Diad_Files), dtype=float)
4055
+ peak_bck=np.zeros(len(Diad_Files), dtype=float)
4056
+ y_star=np.zeros(len(Diad_Files), dtype=float)
4057
+ yplot=np.zeros(len(Diad_Files), dtype=float)
4043
4058
  Diad_df=get_data(path=path, filename=Diad_Files[0], filetype=filetype)
4044
4059
  x_data=Diad_df[:, 0]
4045
- y_data=np.empty([ len(x_data), len(Diad_Files)], float)
4060
+ y_data=np.zeros([ len(x_data), len(Diad_Files)], float)
4046
4061
 
4047
4062
 
4048
4063
  for file in Diad_Files: