DiadFit 0.0.85__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.
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 +182 -40
  24. DiadFit/density_depth_crustal_profiles.py +37 -5
  25. DiadFit/diads.py +26 -13
  26. DiadFit/error_propagation.py +137 -226
  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.88.dist-info}/METADATA +1 -1
  30. DiadFit-0.0.88.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.88.dist-info}/WHEEL +0 -0
  33. {DiadFit-0.0.85.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
- 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,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
- medrho_model = medrho_pickle_data['model']
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_σ': medD_error['MedD_Density_σ'],
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
- # 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'
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
- if Ne_pickle_str is not None:
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
- elif pref_Ne is not None:
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
- # 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
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
- # 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)
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']<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
-
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.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,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, gaussian
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:B molar ratio': Sum_phase_a/Sum_phase_b})
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.empty([ len(x_cord), len(Diad_Files)], float)
617
- data_x_all=np.empty([ len(x_cord), len(Diad_Files)], float)
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.empty(0, dtype='float')
846
- Groupnot1_np_y=np.empty(0, dtype='float')
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:
@@ -4034,15 +4047,15 @@ def plot_secondary_peaks(*, Diad_Files, path, filetype,
4034
4047
 
4035
4048
  i=0
4036
4049
  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)
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)
4043
4056
  Diad_df=get_data(path=path, filename=Diad_Files[0], filetype=filetype)
4044
4057
  x_data=Diad_df[:, 0]
4045
- y_data=np.empty([ len(x_data), len(Diad_Files)], float)
4058
+ y_data=np.zeros([ len(x_data), len(Diad_Files)], float)
4046
4059
 
4047
4060
 
4048
4061
  for file in Diad_Files: