DiadFit 0.0.80__tar.gz → 0.0.83__tar.gz

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 (45) hide show
  1. {DiadFit-0.0.80 → DiadFit-0.0.83}/PKG-INFO +1 -1
  2. {DiadFit-0.0.80 → DiadFit-0.0.83}/setup.py +2 -2
  3. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/CO2_EOS.py +17 -10
  4. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/CO2_H2O_EOS.py +110 -26
  5. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/H2O_fitting.py +5 -5
  6. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/_version.py +1 -1
  7. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/cosmicray_filter.py +2 -1
  8. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/densimeters.py +36 -7
  9. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/diads.py +267 -190
  10. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/error_propagation.py +243 -107
  11. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/importing_data_files.py +17 -11
  12. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/ne_lines.py +471 -440
  13. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit.egg-info/PKG-INFO +1 -1
  14. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit.egg-info/requires.txt +2 -2
  15. {DiadFit-0.0.80 → DiadFit-0.0.83}/README.md +0 -0
  16. {DiadFit-0.0.80 → DiadFit-0.0.83}/setup.cfg +0 -0
  17. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/CO2_in_bubble_error.py +0 -0
  18. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Highrho_polyfit_data.pkl +0 -0
  19. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Highrho_polyfit_dataUCB_1117_1400.pkl +0 -0
  20. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Highrho_polyfit_dataUCB_1220_1400.pkl +0 -0
  21. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Highrho_polyfit_dataUCB_1220_1447.pkl +0 -0
  22. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Highrho_polyfit_data_CCMR.pkl +0 -0
  23. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Highrho_polyfit_data_CMASS.pkl +0 -0
  24. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Lowrho_polyfit_data.pkl +0 -0
  25. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Lowrho_polyfit_dataUCB_1117_1400.pkl +0 -0
  26. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Lowrho_polyfit_dataUCB_1220_1400.pkl +0 -0
  27. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Lowrho_polyfit_dataUCB_1220_1447.pkl +0 -0
  28. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Lowrho_polyfit_data_CCMR.pkl +0 -0
  29. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Lowrho_polyfit_data_CMASS.pkl +0 -0
  30. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Mediumrho_polyfit_data.pkl +0 -0
  31. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Mediumrho_polyfit_dataUCB_1117_1400.pkl +0 -0
  32. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Mediumrho_polyfit_dataUCB_1220_1400.pkl +0 -0
  33. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Mediumrho_polyfit_dataUCB_1220_1447.pkl +0 -0
  34. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Mediumrho_polyfit_data_CCMR.pkl +0 -0
  35. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Mediumrho_polyfit_data_CMASS.pkl +0 -0
  36. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/Psensor.py +0 -0
  37. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/__init__.py +0 -0
  38. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/argon_lines.py +0 -0
  39. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/densimeter_fitting.py +0 -0
  40. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/density_depth_crustal_profiles.py +0 -0
  41. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/molar_gas_proportions.py +0 -0
  42. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit/relaxifi.py +0 -0
  43. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit.egg-info/SOURCES.txt +0 -0
  44. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit.egg-info/dependency_links.txt +0 -0
  45. {DiadFit-0.0.80 → DiadFit-0.0.83}/src/DiadFit.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: DiadFit
3
- Version: 0.0.80
3
+ Version: 0.0.83
4
4
  Summary: DiadFit
5
5
  Home-page: https://github.com/PennyWieser/DiadFit
6
6
  Author: Penny Wieser
@@ -31,11 +31,11 @@ setup(
31
31
  },
32
32
  install_requires=[
33
33
  'pandas',
34
- 'numpy',
34
+ 'numpy<2',
35
35
  'matplotlib',
36
36
  'scikit-learn',
37
37
  'scipy',
38
- 'lmfit',
38
+ 'lmfit>=1.1.0',
39
39
  'tqdm',
40
40
  'python-docx'
41
41
  ],
@@ -19,7 +19,7 @@ DiadFit_dir=Path(__file__).parent
19
19
 
20
20
  def calculate_CO2_density_homog_T(T_h_C, EOS='SW96', Sample_ID=None, homog_to=None, set_to_critical=False):
21
21
  """ Calculates CO2 density for a specified homogenization temperature in Celcius
22
- using the Span and Wanger (1996) equation of state.
22
+ using eq 3.14 and 3.15 from the Span and Wanger (1996) equation of state.
23
23
 
24
24
  Parameters
25
25
  --------------
@@ -52,18 +52,28 @@ def calculate_CO2_density_homog_T(T_h_C, EOS='SW96', Sample_ID=None, homog_to=No
52
52
  else:
53
53
  raise TypeError('unsupported input for homog_to, has to be L or V')
54
54
 
55
+
56
+ # IF its a float or integer, just tell people outright
55
57
  if isinstance(T_h_C, float) or isinstance(T_h_C, int):
56
58
  if T_h_C>=30.9782: # 29.878:
57
59
  #print('Sorry, algorithm cant converge for Ts above 29.878')
58
- raise TypeError('Sorry, algorithm cant converge for Ts above 30.9782')
60
+ raise TypeError('Sorry, algorithm cant converge for T_h_C above 30.9782')
61
+
62
+ # If its a panda series, set critical is false, raise a type error
59
63
  if isinstance(T_h_C, pd.Series) or isinstance(T_h_C, np.ndarray):
60
- if any(T_h_C)>=30.9782 and set_to_critical is False:
64
+
65
+ if any(T_h_C>=30.9782) and set_to_critical is False:
61
66
  raise TypeError('Sorry, algorithm cant converge for Ts above 30.9782. You can put set_to_critical=True and this T_ will be replacd with 30.9782')
62
- elif any(T_h_C)>=30.9782 and set_to_critical is True:
67
+ elif any(T_h_C>=30.9782) and set_to_critical is True:
68
+ print('found some with too high temps, are setting to 30.9782C - the max homog T ')
63
69
  if isinstance(T_h_C, pd.Series):
64
70
  T_h_C = np.where(T_h_C > 30.9782, 30.9782, T_h_C)
65
71
  elif isinstance(T_h_C, np.ndarray):
72
+
66
73
  T_h_C[T_h_C > 30.9782] = 30.9782
74
+ print('got into this loop')
75
+
76
+
67
77
 
68
78
 
69
79
  if EOS!='SW96':
@@ -72,7 +82,10 @@ def calculate_CO2_density_homog_T(T_h_C, EOS='SW96', Sample_ID=None, homog_to=No
72
82
  T_K_hom=T_h_C+273.15
73
83
  TempTerm=1-T_K_hom/304.1282
74
84
  # This is equation 3.14 from Span and Wanger (1996)
85
+
86
+
75
87
  Liq_density=(np.exp(1.9245108*TempTerm**0.34-0.62385555*TempTerm**0.5-0.32731127*TempTerm**1.6666667+0.39245142*TempTerm**1.8333333)*0.4676)
88
+
76
89
  # This is equation 3.15 from Span and Wanger (1996)
77
90
  gas_density=(np.exp(-1.7074879*TempTerm**0.34-0.8227467*TempTerm**0.5-4.6008549*TempTerm**1-10.111178*TempTerm**2.333333-29.742252*TempTerm**4.6666667)*0.4676)
78
91
 
@@ -473,12 +486,6 @@ def calculate_P_for_rho_T_SW96(CO2_dens_gcm3, T_K):
473
486
  except ImportError:
474
487
  raise RuntimeError('You havent installed CoolProp, which is required to convert FI densities to pressures. If you have python through conda, run conda install -c conda-forge coolprop in your command line')
475
488
 
476
- try:
477
- import CoolProp.CoolProp as cp
478
- except ImportError:
479
- raise RuntimeError('You havent installed CoolProp, which is required to convert FI densities to pressures. If you have python through conda, run conda install -c conda-forge coolprop in your command line')
480
-
481
-
482
489
 
483
490
  P_kbar=cp.PropsSI('P', 'D', Density_kgm3, 'T', T_K, 'CO2')/10**8
484
491
  if isinstance(P_kbar, float):
@@ -1022,7 +1022,7 @@ def calc_prop_knownP_EOS_DZ2006(*, P_kbar=1, T_K=1200, XH2O=1):
1022
1022
 
1023
1023
 
1024
1024
 
1025
- def calculate_entrapment_P_XH2O(*, XH2O, CO2_dens_gcm3, T_K):
1025
+ def calculate_entrapment_P_XH2O(*, XH2O, CO2_dens_gcm3, T_K, T_K_ambient=37+273.15, fast_calcs=False, Hloss=True):
1026
1026
  """" This function calculates pressure for a measured CO$_2$ density, temperature and estimate of initial XH2O.
1027
1027
  It first corrects the density to obtain a bulk density for a CO2-H2O mix, assuming that H2O was lost from the inclusion.
1028
1028
  correcting for XH2O. It assumes that H2O has been lost from the inclusion (see Hansteen and Klugel, 2008 for method). It also calculates using other
@@ -1037,47 +1037,131 @@ def calculate_entrapment_P_XH2O(*, XH2O, CO2_dens_gcm3, T_K):
1037
1037
  Measured CO2 density in g/cm3
1038
1038
 
1039
1039
  T_K: float, pd.Series
1040
- Temperature in Kelvin.
1040
+ Temperature in Kelvin fluid was trapped at
1041
+
1042
+ T_K_ambient: pd.Series
1043
+ Temperature in Kelvin Raman measurement was made at.
1044
+
1045
+ fast_calcs: bool (default False)
1046
+ If True, only performs one EOS calc for DZ06, not 4 (with water, without water, SP94 and SW96).
1047
+ also specify H2Oloss=True or False
1048
+
1049
+
1041
1050
 
1042
1051
  Returns
1043
1052
  -----------------------------
1053
+ if fast_calcs is False:
1044
1054
  pd.DataFrame:
1045
1055
  Columns showing:
1046
1056
  P_kbar_pureCO2_SW96: Pressure calculated for the measured CO$_2$ density using the pure CO2 EOS from Span and Wanger (1996)
1047
1057
  P_kbar_pureCO2_SP94: Pressure calculated for the measured CO$_2$ density using the pure CO2 EOS from Sterner and Pitzer (1994)
1048
1058
  P_kbar_pureCO2_DZ06: Pressure calculated from the measured CO$_2$ density using the pure CO2 EOs from Duan and Zhang (2006)
1049
- P_kbar_mixCO2_DZ06: Pressure calculated from the reconstructed mixed fluid density using the mixed EOS from Duan and Zhang (2006)
1050
- P Mix/P Pure DZ06: Correction factor - e.g. how much deeper the pressure is from the mixed EOS
1051
- rho_mix_calc: Bulk density calculated (C+H) at time of entrapment
1059
+ P_kbar_mixCO2_DZ06_Hloss: Pressure calculated from the reconstructed mixed fluid density using the mixed EOS from Duan and Zhang (2006) assuming H loss
1060
+ P_kbar_mixCO2_DZ06_noHloss: Pressure calculated from the reconstructed mixed fluid density using the mixed EOS from Duan and Zhang (2006) assuming H loss
1061
+ P Mix_Hloss/P Pure DZ06: Correction factor - e.g. how much deeper the pressure is from the mixed EOS with H loss
1062
+ P Mix_noHloss/P Pure DZ06: Correction factor - e.g. how much deeper the pressure is from the mixed EOS with H loss
1063
+ rho_mix_calc_noHloss: Bulk density calculated (C+H)
1064
+ rho_mix_calc_Hloss: Bulk density calculated (C+H) after h loss
1052
1065
  CO2_dens_gcm3: Input CO2 density
1053
1066
  T_K: input temperature
1054
1067
  XH2O: input molar fraction of H2O
1055
1068
 
1069
+ if fast_calcs is True:
1070
+ P_kbar_mixCO2_DZ06: Pressure calculated from the reconstructed mixed fluid density using the mixed EOS from Duan and Zhang (2006)
1071
+
1072
+
1073
+
1056
1074
  """
1057
1075
  XH2O, rho_meas, T_K=ensure_series(a=XH2O, b=CO2_dens_gcm3, c=T_K)
1058
1076
  alpha=XH2O/(1-XH2O)
1059
- # This gets the bulk density of the CO2-H2O fluid
1060
- rho_orig=rho_meas*(1+alpha*(18/44))
1061
- # Lets calculate the pressure using SW96
1062
- P_SW=calculate_P_for_rho_T(T_K=T_K, CO2_dens_gcm3=rho_meas, EOS='SW96')
1063
- P_SP=calculate_P_for_rho_T(T_K=T_K, CO2_dens_gcm3=rho_meas, EOS='SP94')
1064
- # Same for DZ2006
1065
- P_DZ=calculate_Pressure_DZ2006(density=rho_meas, T_K=T_K, XH2O=XH2O*0)
1066
- # Now doing it with XH2O
1067
- P_DZ_mix=calculate_Pressure_DZ2006(density=rho_orig, T_K=T_K, XH2O=XH2O)
1068
-
1069
- df=pd.DataFrame(data={
1070
- 'P_kbar_pureCO2_SW96': P_SW['P_kbar'],
1071
- 'P_kbar_pureCO2_SP94': P_SW['P_kbar'],
1072
- 'P_kbar_pureCO2_DZ06': P_DZ/1000,
1073
- 'P_kbar_mixCO2_DZ06': P_DZ_mix/1000,
1074
- 'P Mix/P Pure DZ06': P_DZ_mix/P_DZ,
1075
- 'rho_mix_calc': rho_orig,
1076
- 'CO2_dens_gcm3': rho_meas,
1077
- 'T_K': T_K,
1078
- 'XH2O': XH2O})
1077
+ # IF water is lost
1078
+ rho_orig_H_loss=rho_meas*(1+alpha*(18/44))
1079
+ # IF water isnt lost
1079
1080
 
1080
- return df
1081
+ # Calculate mass ratio from molar ratio
1082
+ mass_ratio=(XH2O*18)/((1-XH2O)*44)
1083
+ # Calculate pressure in CO2 fluid
1084
+ P=calculate_P_for_rho_T_SW96(CO2_dens_gcm3, T_K_ambient)
1085
+ # Now calculate density of H2O fluid
1086
+
1087
+ # Calculate density of H2O
1088
+ rho_H2O=calculate_rho_for_P_T_H2O(P['P_kbar'], T_K_ambient)
1089
+
1090
+
1091
+
1092
+ # Assume a system of unit 1. Calculate volume of CO2
1093
+ VolCO2=(1-mass_ratio)/CO2_dens_gcm3
1094
+ VolH2O=mass_ratio/rho_H2O
1095
+ rho_orig_no_H_loss=1/(VolH2O+VolCO2)
1096
+
1097
+ if fast_calcs is True:
1098
+ if Hloss is True:
1099
+ P=calculate_Pressure_DZ2006(density=rho_orig_H_loss, T_K=T_K, XH2O=XH2O)
1100
+ if Hloss is False:
1101
+ P=calculate_Pressure_DZ2006(density=rho_orig_H_loss, T_K=T_K, XH2O=XH2O)
1102
+ return P/1000
1103
+
1104
+ else:
1105
+
1106
+ # Lets calculate the pressure using SW96
1107
+ P_SW=calculate_P_for_rho_T(T_K=T_K, CO2_dens_gcm3=rho_meas, EOS='SW96')
1108
+ P_SP=calculate_P_for_rho_T(T_K=T_K, CO2_dens_gcm3=rho_meas, EOS='SP94')
1109
+ # Same for DZ2006
1110
+ P_DZ=calculate_Pressure_DZ2006(density=rho_meas, T_K=T_K, XH2O=XH2O*0)
1111
+ # Now doing it with XH2O
1112
+ P_DZ_mix_H_loss=calculate_Pressure_DZ2006(density=rho_orig_H_loss, T_K=T_K, XH2O=XH2O)
1113
+ P_DZ_mix_noH_loss=calculate_Pressure_DZ2006(density=rho_orig_no_H_loss, T_K=T_K, XH2O=XH2O)
1114
+
1115
+ df=pd.DataFrame(data={
1116
+ 'P_kbar_pureCO2_SW96': P_SW['P_kbar'],
1117
+ 'P_kbar_pureCO2_SP94': P_SP['P_kbar'],
1118
+ 'P_kbar_pureCO2_DZ06': P_DZ/1000,
1119
+ 'P_kbar_mixCO2_DZ06_Hloss': P_DZ_mix_H_loss/1000,
1120
+ 'P_kbar_mixCO2_DZ06_no_Hloss': P_DZ_mix_noH_loss/1000,
1121
+ 'P Mix_Hloss/P Pure DZ06': P_DZ_mix_H_loss/P_DZ,
1122
+ 'P Mix_no_Hloss/P Pure DZ06': P_DZ_mix_noH_loss/P_DZ,
1123
+ 'rho_mix_calc_Hloss': rho_orig_H_loss,
1124
+ 'rho_mix_calc_noHloss': rho_orig_no_H_loss,
1125
+ 'CO2_dens_gcm3': rho_meas,
1126
+ 'T_K': T_K,
1127
+ 'XH2O': XH2O})
1128
+
1129
+ return df
1130
+
1131
+
1132
+ def calculate_rho_for_P_T_H2O(P_kbar, T_K):
1133
+ """ This function calculates H2O density in g/cm3 for a known Pressure (in kbar), a known T (in K) using the Wanger and Pru (2002) EOS from CoolProp
1134
+ doi:10.1063/1.1461829.
1135
+
1136
+ Parameters
1137
+ ---------------------
1138
+ P_kbar: int, float, pd.Series, np.array
1139
+ Pressure in kbar
1140
+
1141
+ T_K: int, float, pd.Series, np.array
1142
+ Temperature in Kelvin
1143
+
1144
+ Returns
1145
+ --------------------
1146
+ pd.Series
1147
+ H2O density in g/cm3
1148
+
1149
+ """
1150
+ if isinstance(P_kbar, pd.Series):
1151
+ P_kbar=np.array(P_kbar)
1152
+ if isinstance(T_K, pd.Series):
1153
+ T_K=np.array(T_K)
1154
+
1155
+ P_Pa=P_kbar*10**8
1156
+
1157
+ try:
1158
+ import CoolProp.CoolProp as cp
1159
+ except ImportError:
1160
+ raise RuntimeError('You havent installed CoolProp, which is required to convert FI densities to pressures. If you have python through conda, run conda install -c conda-forge coolprop in your command line')
1161
+
1162
+ H2O_dens_gcm3=cp.PropsSI('D', 'P', P_Pa, 'T', T_K, 'H2O')/1000
1163
+
1164
+ return pd.Series(H2O_dens_gcm3)
1081
1165
 
1082
1166
 
1083
1167
 
@@ -305,8 +305,8 @@ def make_evaluate_mixed_spectra(*, path, filename, smoothed_host_y, smoothed_MI_
305
305
  X_min=0, X_max=1, plot_figure=True, dpi=200):
306
306
 
307
307
  """
308
- This function unmixes glass and host spectra, and fits the best fit proportion
309
- where the host peak and trough disapears. Specifically, it calculates the mixed spectra by
308
+ This function unmixes glass and host spectra, and fits the best fit proportion
309
+ where the host peak and trough disapears. Specifically, it calculates the mixed spectra by
310
310
  taking the measured MI spectra and subtracting X*Ol spectra, where X is the mixing proportions
311
311
 
312
312
  Parameters
@@ -355,7 +355,7 @@ def make_evaluate_mixed_spectra(*, path, filename, smoothed_host_y, smoothed_MI_
355
355
  Dist: float
356
356
  Vertical distance between the host peak and trough (in intensity units)
357
357
  MI_Mix: np.array
358
- Umixed spectra for each of the N_steps
358
+ Ubmixed spectra for each of the N_steps
359
359
  X: np.array
360
360
  X coordinates of unmixed spectra (along with MI_Mix and X allows plots of unmixing)
361
361
 
@@ -428,7 +428,7 @@ def make_evaluate_mixed_spectra(*, path, filename, smoothed_host_y, smoothed_MI_
428
428
  ax3.set_xlim([775, 900])
429
429
 
430
430
 
431
- ax4.plot(MI_spectra[:, 0],MI_Mix_Best[:, 1], '-k', label='Umixed glass')
431
+ ax4.plot(MI_spectra[:, 0],MI_Mix_Best[:, 1], '-k', label='Unmixed glass')
432
432
  ax4.plot(MI_spectra[:, 0],MI_spectra[:, 1], '-', color='salmon',label='Measured MI')
433
433
  ax4.plot(Host_spectra[:, 0],Host_spectra[:, 1], '-', color='g', label='Measured Host')
434
434
  ax4.legend()
@@ -456,7 +456,7 @@ override=False, flip=False, plot_figure=True, dpi=200):
456
456
  """
457
457
  This function checks if the unmixed specta is negative, based on two tie points.
458
458
  The first tie point is the mean y coordinate of the peak position of host +5 wavenumbers,
459
- and the second tie point (tie_x_cord) is an optional input. If the specta is inverted,
459
+ and the second tie point (tie_x_cord) is an optional input. If the specta is inverted,
460
460
  this function inverts it.
461
461
 
462
462
 
@@ -5,4 +5,4 @@
5
5
  # 1) we don't load dependencies by storing it in __init__.py
6
6
  # 2) we can import it in setup.py for the same reason
7
7
  # 3) we can import it into your module
8
- __version__ = '0.0.80'
8
+ __version__ = '0.0.83'
@@ -102,6 +102,7 @@ def filter_singleray(*,path=None,Diad_files=None,i=None,diad_peaks=None, exclude
102
102
 
103
103
  file=Diad_files.iloc[i]
104
104
  #open the spectrum in form of array
105
+
105
106
  Diad_array=pf.get_data(path=path, filename=file, filetype=filetype)
106
107
 
107
108
  # Get the intensity of the next and previous pixels
@@ -402,7 +403,7 @@ def filter_singleray(*,path=None,Diad_files=None,i=None,diad_peaks=None, exclude
402
403
 
403
404
  record=pd.DataFrame([])
404
405
  record.loc[file,'filename']=file
405
- record.loc[file,'rays_present']=not all_rayswave.empty
406
+ record.loc[file,'rays_present']=float(not all_rayswave.empty)
406
407
 
407
408
  if second_pass==True:
408
409
  clean_spec_df=pxdf_filt_pass2[['Wavenumber','Intensity']]
@@ -619,8 +619,12 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
619
619
 
620
620
  df.loc[zero, 'Preferred D']=0
621
621
  df.loc[zero, 'Notes']=0
622
-
623
-
622
+
623
+ # Get rid of pandas 2 issue with warning of setting item of incompatible dtype
624
+ df['Preferred D'] = df['Preferred D'].astype('float64', errors='ignore')
625
+ df['Preferred D_σ'] = df['Preferred D_σ'].astype('float64', errors='ignore')
626
+ df['Preferred D_σ_split'] = df['Preferred D_σ_split'].astype('float64', errors='ignore')
627
+ df['Preferred D_σ_dens'] = df['Preferred D_σ_dens'].astype('float64', errors='ignore')
624
628
 
625
629
 
626
630
 
@@ -692,23 +696,39 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
692
696
 
693
697
 
694
698
 
699
+ # if Ne_pickle_str is not None:
700
+ #
701
+ # df_merge1=pd.concat([df_combo_c, Ne_corr], axis=1).reset_index(drop=True)
702
+ # else:
703
+ # df_merge1=df
704
+ # print('df')
705
+ # print(df['Preferred D'])
706
+ # print('df_merge1')
707
+ # print(df_merge1['Preferred D'])
695
708
  if Ne_pickle_str is not None:
696
709
  df_merge1=pd.concat([df_combo_c, Ne_corr], axis=1).reset_index(drop=True)
710
+ df_merge=pd.concat([df, df_merge1], axis=1).reset_index(drop=True)
711
+ elif Ne_pickle_str is None and df_combo is not None:
712
+ df_merge=pd.concat([df, df_combo_c], axis=1).reset_index(drop=True)
697
713
  else:
698
- df_merge1=df
714
+ df_merge=df
715
+
716
+
699
717
 
700
- df_merge=pd.concat([df, df_merge1], axis=1).reset_index(drop=True)
718
+ #df_merge=pd.concat([df, df_merge1], axis=1).reset_index(drop=True)
701
719
 
702
720
 
703
721
 
704
722
 
705
- df_merge=pd.concat([df, df_merge1], axis=1).reset_index(drop=True)
723
+
724
+
706
725
 
707
726
  df_merge = df_merge.rename(columns={'Preferred D': 'Density g/cm3'})
708
727
  df_merge = df_merge.rename(columns={'Preferred D_σ': 'σ Density g/cm3'})
709
728
  df_merge = df_merge.rename(columns={'Preferred D_σ_split': 'σ Density g/cm3 (from Ne+peakfit)'})
710
729
  df_merge = df_merge.rename(columns={'Preferred D_σ_dens': 'σ Density g/cm3 (from densimeter)'})
711
730
  df_merge = df_merge.rename(columns={'filename_x': 'filename'})
731
+
712
732
 
713
733
 
714
734
  #
@@ -727,6 +747,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
727
747
  df_merge = df_merge[cols_to_move + [
728
748
  col for col in df_merge.columns if col not in cols_to_move]]
729
749
 
750
+
730
751
 
731
752
  return df_merge
732
753
 
@@ -968,7 +989,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
968
989
  Split=df_combo_c['Splitting']*pref_Ne
969
990
 
970
991
  else:
971
- Split_err=(split_err*Split).astype(float)
992
+ Split_err=split_err
972
993
 
973
994
 
974
995
 
@@ -1129,6 +1150,14 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
1129
1150
 
1130
1151
  df.loc[zero, 'Preferred D']=0
1131
1152
  df.loc[zero, 'Notes']=0
1153
+
1154
+ # Assign to the right type to avoid annoying pandas 2 warning
1155
+ # Ensure the columns are of type float64
1156
+ df['Preferred D'] = df['Preferred D'].astype('float64', errors='ignore')
1157
+ df['Preferred D_σ'] = df['Preferred D_σ'].astype('float64', errors='ignore')
1158
+ df['Preferred D_σ_split'] = df['Preferred D_σ_split'].astype('float64', errors='ignore')
1159
+ df['Preferred D_σ_dens'] = df['Preferred D_σ_dens'].astype('float64', errors='ignore')
1160
+
1132
1161
 
1133
1162
 
1134
1163
 
@@ -1146,7 +1175,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
1146
1175
  df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D_σ_split'] = medD_error['MedD_Density_σ_split']
1147
1176
  df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Preferred D_σ_dens'] = medD_error['MedD_Density_σ_dens']
1148
1177
  df.loc[SupCrit&(min_MD_SC_Split&max_MD_SC_Split), 'Notes']='SupCrit, Med density'
1149
-
1178
+
1150
1179
  # If SupCrit, low density
1151
1180
  df.loc[ SupCrit&(min_lowD_SC_Split&max_lowD_SC_Split), 'Preferred D'] = LowD_SC
1152
1181
  df.loc[ SupCrit&(min_lowD_SC_Split&max_lowD_SC_Split), 'Preferred D_σ'] = lowD_error['LowD_Density_σ']