DiadFit 1.0.8__tar.gz → 1.0.9__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 (56) hide show
  1. {DiadFit-1.0.8 → DiadFit-1.0.9}/PKG-INFO +1 -1
  2. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/_version.py +1 -1
  3. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/densimeter_fitting.py +1 -0
  4. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/densimeters.py +1 -1
  5. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/diads.py +0 -47
  6. DiadFit-1.0.9/src/DiadFit/molar_gas_proportions.py +231 -0
  7. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit.egg-info/PKG-INFO +1 -1
  8. DiadFit-1.0.8/src/DiadFit/molar_gas_proportions.py +0 -183
  9. {DiadFit-1.0.8 → DiadFit-1.0.9}/README.md +0 -0
  10. {DiadFit-1.0.8 → DiadFit-1.0.9}/setup.cfg +0 -0
  11. {DiadFit-1.0.8 → DiadFit-1.0.9}/setup.py +0 -0
  12. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/CO2_EOS.py +0 -0
  13. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/CO2_in_bubble_error.py +0 -0
  14. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/H2O_fitting.py +0 -0
  15. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_data.pkl +0 -0
  16. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_dataUCB_1117_1400.pkl +0 -0
  17. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_dataUCB_1117_1447.pkl +0 -0
  18. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_dataUCB_1220_1400.pkl +0 -0
  19. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_dataUCB_1220_1447.pkl +0 -0
  20. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_dataUCB_1220_1567.pkl +0 -0
  21. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_data_CCMR.pkl +0 -0
  22. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_data_CMASS.pkl +0 -0
  23. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_data_CMASS_24C.pkl +0 -0
  24. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_data.pkl +0 -0
  25. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_dataUCB_1117_1400.pkl +0 -0
  26. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_dataUCB_1117_1447.pkl +0 -0
  27. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_dataUCB_1220_1400.pkl +0 -0
  28. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_dataUCB_1220_1447.pkl +0 -0
  29. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_dataUCB_1220_1567.pkl +0 -0
  30. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_data_CCMR.pkl +0 -0
  31. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_data_CMASS.pkl +0 -0
  32. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_data_CMASS_24C.pkl +0 -0
  33. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_data.pkl +0 -0
  34. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_dataUCB_1117_1400.pkl +0 -0
  35. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_dataUCB_1117_1447.pkl +0 -0
  36. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_dataUCB_1220_1400.pkl +0 -0
  37. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_dataUCB_1220_1447.pkl +0 -0
  38. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_dataUCB_1220_1567.pkl +0 -0
  39. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_data_CCMR.pkl +0 -0
  40. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_data_CMASS.pkl +0 -0
  41. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/Psensor.py +0 -0
  42. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/__init__.py +0 -0
  43. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/argon_lines.py +0 -0
  44. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/cosmicray_filter.py +0 -0
  45. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/density_depth_crustal_profiles.py +0 -0
  46. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/error_propagation.py +0 -0
  47. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/importing_data_files.py +0 -0
  48. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/lookup_table.csv +0 -0
  49. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/lookup_table_noneg.csv +0 -0
  50. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/ne_lines.py +0 -0
  51. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/relaxfi_PW.py +0 -0
  52. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit/relaxifi.py +0 -0
  53. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit.egg-info/SOURCES.txt +0 -0
  54. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit.egg-info/dependency_links.txt +0 -0
  55. {DiadFit-1.0.8 → DiadFit-1.0.9}/src/DiadFit.egg-info/requires.txt +0 -0
  56. {DiadFit-1.0.8 → DiadFit-1.0.9}/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: 1.0.8
3
+ Version: 1.0.9
4
4
  Summary: DiadFit
5
5
  Home-page: https://github.com/PennyWieser/DiadFit
6
6
  Author: Penny Wieser
@@ -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__ = '1.0.8'
8
+ __version__ = '1.0.9'
@@ -15,6 +15,7 @@ from scipy import stats
15
15
 
16
16
  encode="ISO-8859-1"
17
17
 
18
+ ## Files are fit using the folder UCB_cali_fitting_1117_1447
18
19
 
19
20
  def calculate_generic_std_err_values(*, pickle_str, new_x, CI=0.67):
20
21
 
@@ -994,7 +994,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
994
994
  corrected_split: pd.Series
995
995
  Corrected splitting (cm-1)
996
996
 
997
- Split_err: float, int
997
+ split_err: float, int
998
998
  Error on corrected splitting
999
999
 
1000
1000
  temp: str
@@ -33,54 +33,7 @@ allowed_models = ["VoigtModel", "PseudoVoigtModel", "Pearson4Model", "SkewedVoig
33
33
  #warnings.simplefilter('error')
34
34
 
35
35
  encode="ISO-8859-1"
36
- ## Ratio of different peaks
37
36
 
38
-
39
- 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):
40
- """ Calculates SO2:CO2 ratio using the parameters from Marie-Camille Caumons lab"""
41
-
42
-
43
- A_CO2_star=( diad1_area + diad2_area)/(diad2_cross_sec+diad1_cross_sec)
44
- A_SO2_star=(SO2_area)/(SO2_cross_sec)
45
- Ratio=A_SO2_star/(A_SO2_star+A_CO2_star)
46
-
47
- return Ratio
48
-
49
- def calculate_mole_fraction_2comp(peak_area_a, peak_area_b, cross_section_a, cross_section_b, instrument_eff_a, instrument_eff_b):
50
- """ This function calculates the molar ration of 2 components a and b based on peak areas,
51
- cross section and instrument efficiency
52
-
53
- Parameters
54
- ------------
55
-
56
- peak_area_a: int, float, pd.Series, np.array
57
- Peak area of component a
58
-
59
- peak_area_b: int, float, pd.Series, np.array
60
- Peak area of component b
61
-
62
- cross_section_a, cross_section_a: int, float
63
- Raman cross section for component a and b
64
-
65
- instrument_eff_a, instrument_eff_b: int, float
66
- Instrument effeciency of a and b.
67
-
68
- Returns
69
- ------------
70
- pd.DataFrame
71
- Molar ratio of a/b
72
-
73
-
74
- """
75
-
76
- Sum_phase_a=peak_area_a/(cross_section_a*instrument_eff_a)
77
- Sum_phase_b=peak_area_b/(cross_section_b*instrument_eff_b)
78
-
79
- df=pd.DataFrame(data={'% A': 100*Sum_phase_a/(Sum_phase_b+Sum_phase_a),
80
- '% B': 100-100*Sum_phase_a/(Sum_phase_b+Sum_phase_a)}
81
- )
82
-
83
- return df
84
37
  def plot_diad(*,path=None, filename=None, filetype='Witec_ASCII', Spectra_x=None, Spectra_y=None):
85
38
  """This function makes a plot of the spectra for a specific file to allow visual inspectoin
86
39
 
@@ -0,0 +1,231 @@
1
+ import math
2
+ import pandas as pd
3
+ import numpy as np
4
+
5
+
6
+
7
+
8
+
9
+
10
+ # def calculate_sigma(wavelength, vi_dict, T_K):
11
+ # """
12
+ # This function calculates the σ cross section according to wavelength based on Burke (2001) EQ(1), you must provide:
13
+ # ### 1) the peak shift of the species, 2) temp (doesn't really matter) and 3) Σ (wavelength-independent relative Raman scattering cross-sections).
14
+ # """
15
+ # c = 2.998 * 10**10 # cm/s light speed
16
+ # h = 6.626 * 10**-27 # erg.s Planck constant
17
+ # k = 1.381 * 10**-16 # erg/K Boltzmann's constant
18
+ #
19
+ # v0 = 1 / (wavelength * 10**-7)
20
+ #
21
+ # sigma_results = {}
22
+ # for name, vi_info in vi_dict.items():
23
+ # vi = vi_info["Peak_shift_cm-1"]
24
+ # BigSigma = vi_info["Σ"]
25
+ #
26
+ # result = BigSigma / (((v0 - vi)**-4 / (v0 - 2331)**-4) * (1 - math.exp(-h * c * vi / (k * T_K))))
27
+ # sigma_results[name] = round(result, 2)
28
+ #
29
+ # return sigma_results
30
+ #
31
+ #
32
+ #
33
+ #
34
+ # def calculate_mole_percent(components):
35
+ # """ This function calculates the mole percents of the components entered, based on Burke (2001) EQ(2)
36
+ # """
37
+ # def partial_molec_contribution_single(A, sigma, squiggle):
38
+ # return A / (sigma * squiggle)
39
+ #
40
+ # def partial_molec_contribution_double(A1, sigma1, A2, sigma2, squiggle):
41
+ # return (A1 + A2) / ((sigma1 + sigma2) * squiggle)
42
+ #
43
+ # total_partials = 0
44
+ # partials = []
45
+ #
46
+ # for component in components:
47
+ # if component['name'] == 'CO2':
48
+ # partial = partial_molec_contribution_double(component['peak_area_1'], component['cross_section_1'],
49
+ # component['peak_area_2'], component['cross_section_2'],
50
+ # component['efficiency'])
51
+ # else:
52
+ # partial = partial_molec_contribution_single(component['peak_area'], component['cross_section'],
53
+ # component['efficiency'])
54
+ #
55
+ # partials.append(partial)
56
+ # total_partials += partial
57
+ #
58
+ # mole_percentages = [round((partial / total_partials) * 100, 1) for partial in partials]
59
+ #
60
+ # mole_percent_dict = {component['name']: mole_percent for component, mole_percent in zip(components, mole_percentages)}
61
+ # mole_percent_dict['Mole_Percent_Sum'] = sum(mole_percentages)
62
+ #
63
+ # return mole_percent_dict
64
+
65
+
66
+ #
67
+ #
68
+ # def calculate_CO2_SO2_ratio(*, peak_area_SO2, peak_area_diad1, peak_area_diad2,wavelength=532.067, T_K=37+273.15,efficiency_SO2=1, efficiency_CO2=0.5, sigma_SO2=4.03, sigma_CO2_v1=0.8, sigma_CO2_v2=1.23):
69
+ #
70
+ # # First we need to calculate the oarameters
71
+ #
72
+ # component_dict = {
73
+ # "SO2": {"Peak_shift_cm-1": 1151, "Σ": sigma_SO2},
74
+ # "CO2_v1": {"Peak_shift_cm-1": 1285, "Σ": sigma_CO2_v1},
75
+ # "CO2_2v2": {"Peak_shift_cm-1": 1388, "Σ": sigma_CO2_v2}}
76
+ # ### "Σ" is the wavelength independent relative cross-section
77
+ #
78
+ # sigma_results = calculate_sigma(wavelength=wavelength, vi_dict=component_dict, T_K=T_K)
79
+ #
80
+ # # Now lets allocate these calculations
81
+ # components = [
82
+ # {'name': 'SO2',
83
+ # 'peak_area': peak_area_SO2,
84
+ # 'cross_section': sigma_results['SO2'],
85
+ # 'efficiency': efficiency_SO2},
86
+ # {'name': 'CO2',
87
+ # 'peak_area_1':peak_area_diad2, 'cross_section_1': sigma_results['CO2_2v2'],
88
+ # 'peak_area_2': peak_area_diad1, 'cross_section_2': sigma_results['CO2_v1'], 'efficiency': efficiency_CO2}
89
+ # ]
90
+ # mol_perc=calculate_mole_percent(components)
91
+ #
92
+ #
93
+ # return pd.DataFrame(mol_perc)
94
+
95
+
96
+
97
+ ## Math for converting back and forth between Raman scattering cross sections
98
+
99
+ def calculate_wavelength_dependent_cross_section(wavelength_nm, T_C, Raman_shift_cm, wavelength_independent_cross_section ):
100
+ """ This function calculates the wavelength dependent cross section (lower case sigma) from the wavelength independent Raman scattering efficiency (Upper case sigma)
101
+
102
+ Parameters
103
+ ----------------
104
+ wavelength_nm:
105
+ laser wavelength used in nm to calculate the wavelength dependent cross section
106
+
107
+ wavelength_independent_cross_section:
108
+ Wavelength independent cross section
109
+
110
+ T_K:
111
+ absolute temperature in Kelvin
112
+
113
+ Raman_shift_cm:
114
+ Raman shift in cm-1 of peak of interest (e.g. 1151 for SO$_2$)
115
+
116
+ Returns
117
+ -----------------
118
+ Wavelength dependent cross section
119
+
120
+ """
121
+ Wavelength_cm1=1/wavelength_nm*10000000
122
+ constant =1-np.exp(((-6.626*10**-27)*(2.998*10**10)*Raman_shift_cm)/((1.381*10**-16)*(273.15+T_C)))
123
+ Wavelength_dependent = wavelength_independent_cross_section/(((Wavelength_cm1-Raman_shift_cm)**(-4)/(Wavelength_cm1-2331)**(-4))*constant)
124
+ return Wavelength_dependent
125
+
126
+ def calculate_wavelength_independent_cross_section(wavelength_nm, T_C, Raman_shift_cm, wavelength_dependent_cross_section ):
127
+ """ This function calculates the wavelength independent cross section (capital Sigma) from the wavelength dependent Raman scattering efficiency (lower case sigma)
128
+
129
+ Parameters
130
+ ----------------
131
+ wavelength_nm:
132
+ laser wavelength used in nm to calculate the wavelength dependent cross section
133
+
134
+ wavelength_dependent_cross_section:
135
+ Wavelength dependent cross section
136
+
137
+ T_K:
138
+ absolute temperature in Kelvin
139
+
140
+ Raman_shift_cm:
141
+ Raman shift in cm-1 of peak of interest (e.g. 1151 for SO$_2$)
142
+
143
+ Returns
144
+ -----------------
145
+ Wavelength independent cross section
146
+
147
+ """
148
+ Wavelength_cm1=1/wavelength_nm*10000000
149
+ constant =1-np.exp(((-6.626*10**-27)*(2.998*10**10)*Raman_shift_cm)/((1.381*10**-16)*(273.15+T_C)))
150
+ Wavelength_independent = wavelength_dependent_cross_section*((Wavelength_cm1-Raman_shift_cm)**(-4)/(Wavelength_cm1-2331)**(-4)*constant)
151
+ return Wavelength_independent
152
+
153
+ def convert_cross_section_wavelength1_wavelength2(wavelength_nm_1,wavelength_nm_2, Raman_shift_cm, wavelength_dependent_cross_section_wavelength1, T_C):
154
+ """ This function calculates the wavelength dependent cross section (lower case sigma) for laser wavelength 2 from the wavelength-dependent cross section for laser wavelength 1.
155
+
156
+
157
+ Parameters
158
+ ----------------
159
+ wavelength_nm_1:
160
+ laser wavelength used in nm to calculate the wavelength dependent cross section
161
+
162
+ wavelength_nm_2:
163
+ laser wavelength of the system of interest you are trying to calculate the wavelength dependent cross section for
164
+
165
+ wavelength_dependent_cross_section_wavelength1:
166
+ Wavelength dependent cross section
167
+
168
+ T_K:
169
+ absolute temperature in Kelvin
170
+
171
+ Raman_shift_cm:
172
+ Raman shift in cm-1 of peak of interest (e.g. 1151 for SO$_2$)
173
+
174
+ Returns
175
+ -----------------
176
+ Wavelength dependent cross section for wavelength2
177
+
178
+ """
179
+
180
+ # First calculate the independent cross section
181
+ ind_cross_sec=calculate_wavelength_independent_cross_section(wavelength_nm=wavelength_nm_1, T_C=T_C, Raman_shift_cm=Raman_shift_cm,
182
+ wavelength_dependent_cross_section =wavelength_dependent_cross_section_wavelength1)
183
+ print(ind_cross_sec)
184
+ dep_cross_sec=calculate_wavelength_dependent_cross_section(wavelength_nm=wavelength_nm_2, T_C=T_C, Raman_shift_cm=Raman_shift_cm, wavelength_independent_cross_section =ind_cross_sec)
185
+
186
+ return dep_cross_sec
187
+
188
+ def calculate_SO2_CO2_mol_prop_wave_indep(SO2_wavelength_ind, CO2_diad1_wavelength_ind, CO2_diad2_wavelength_ind, wavelength_nm, T_C,
189
+ A_SO2, A_CO2_Tot):
190
+ """ Takes wavelength independnet cross sections and CO2 and SO2 peak areas and converts them into SO2 mol proportions
191
+ Parameters
192
+ ------------------
193
+
194
+ SO2_wavelength_ind: Wavelength independent cross section for SO2
195
+
196
+ CO2_diad1_wavelength_ind: Wavelength independent cross section for diad 1 (at 1285)
197
+
198
+ CO2_diad2_wavelength_ind: Wavelength independent cross section for diad 2 (at 1388)
199
+
200
+ wavelength_nm: Laser wavelenth of system in nm
201
+
202
+ T_C: Temperature of analysis in C.
203
+
204
+ Returns
205
+ ---------------
206
+
207
+ SO2 mol proportion
208
+
209
+
210
+ """
211
+
212
+ SO2_cross_sec=calculate_wavelength_dependent_cross_section(wavelength_nm=wavelength_nm, T_C=T_C, Raman_shift_cm=1151, wavelength_independent_cross_section=SO2_wavelength_ind)
213
+ CO2_diad1_xsec=calculate_wavelength_dependent_cross_section(wavelength_nm=wavelength_nm, T_C=T_C, Raman_shift_cm=1285, wavelength_independent_cross_section=CO2_diad1_wavelength_ind)
214
+ CO2_diad2_xsec=calculate_wavelength_dependent_cross_section(wavelength_nm=wavelength_nm, T_C=T_C, Raman_shift_cm=1388, wavelength_independent_cross_section=CO2_diad2_wavelength_ind)
215
+
216
+
217
+ SO2_prop=(A_SO2/SO2_cross_sec)/(A_CO2_Tot /(CO2_diad1_xsec + CO2_diad2_xsec) + (A_SO2/SO2_cross_sec) )
218
+
219
+ return SO2_prop
220
+
221
+
222
+ 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):
223
+ """ Calculates SO2:CO2 ratio using the parameters from Marie-Camille Caumons lab"""
224
+
225
+
226
+ A_CO2_star=( diad1_area + diad2_area)/(diad2_cross_sec+diad1_cross_sec)
227
+ A_SO2_star=(SO2_area)/(SO2_cross_sec)
228
+ Ratio=A_SO2_star/(A_SO2_star+A_CO2_star)
229
+
230
+ return Ratio
231
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: DiadFit
3
- Version: 1.0.8
3
+ Version: 1.0.9
4
4
  Summary: DiadFit
5
5
  Home-page: https://github.com/PennyWieser/DiadFit
6
6
  Author: Penny Wieser
@@ -1,183 +0,0 @@
1
- import math
2
- import pandas as pd
3
- import numpy as np
4
-
5
- def calculate_sigma(wavelength, vi_dict, T_K):
6
- """
7
- This function calculates the σ cross section according to wavelength based on Burke (2001) EQ(1), you must provide:
8
- ### 1) the peak shift of the species, 2) temp (doesn't really matter) and 3) Σ (wavelength-independent relative Raman scattering cross-sections).
9
- """
10
- c = 2.998 * 10**10 # cm/s light speed
11
- h = 6.626 * 10**-27 # erg.s Planck constant
12
- k = 1.381 * 10**-16 # erg/K Boltzmann's constant
13
-
14
- v0 = 1 / (wavelength * 10**-7)
15
-
16
- sigma_results = {}
17
- for name, vi_info in vi_dict.items():
18
- vi = vi_info["Peak_shift_cm-1"]
19
- BigSigma = vi_info["Σ"]
20
-
21
- result = BigSigma / (((v0 - vi)**-4 / (v0 - 2331)**-4) * (1 - math.exp(-h * c * vi / (k * T_K))))
22
- sigma_results[name] = round(result, 2)
23
-
24
- return sigma_results
25
-
26
-
27
-
28
-
29
- def calculate_mole_percent(components):
30
- """ This function calculates the mole percents of the components entered, based on Burke (2001) EQ(2)
31
- """
32
- def partial_molec_contribution_single(A, sigma, squiggle):
33
- return A / (sigma * squiggle)
34
-
35
- def partial_molec_contribution_double(A1, sigma1, A2, sigma2, squiggle):
36
- return (A1 + A2) / ((sigma1 + sigma2) * squiggle)
37
-
38
- total_partials = 0
39
- partials = []
40
-
41
- for component in components:
42
- if component['name'] == 'CO2':
43
- partial = partial_molec_contribution_double(component['peak_area_1'], component['cross_section_1'],
44
- component['peak_area_2'], component['cross_section_2'],
45
- component['efficiency'])
46
- else:
47
- partial = partial_molec_contribution_single(component['peak_area'], component['cross_section'],
48
- component['efficiency'])
49
-
50
- partials.append(partial)
51
- total_partials += partial
52
-
53
- mole_percentages = [round((partial / total_partials) * 100, 1) for partial in partials]
54
-
55
- mole_percent_dict = {component['name']: mole_percent for component, mole_percent in zip(components, mole_percentages)}
56
- mole_percent_dict['Mole_Percent_Sum'] = sum(mole_percentages)
57
-
58
- return mole_percent_dict
59
-
60
-
61
-
62
-
63
- def calculate_CO2_SO2_ratio(*, peak_area_SO2, peak_area_diad1, peak_area_diad2,wavelength=532.067, T_K=37+273.15,efficiency_SO2=1, efficiency_CO2=0.5, sigma_SO2=4.03, sigma_CO2_v1=0.8, sigma_CO2_v2=1.23):
64
-
65
- # First we need to calculate the oarameters
66
-
67
- component_dict = {
68
- "SO2": {"Peak_shift_cm-1": 1151, "Σ": sigma_SO2},
69
- "CO2_v1": {"Peak_shift_cm-1": 1285, "Σ": sigma_CO2_v1},
70
- "CO2_2v2": {"Peak_shift_cm-1": 1388, "Σ": sigma_CO2_v2}}
71
- ### "Σ" is the wavelength independent relative cross-section
72
-
73
- sigma_results = calculate_sigma(wavelength=wavelength, vi_dict=component_dict, T_K=T_K)
74
-
75
- # Now lets allocate these calculations
76
- components = [
77
- {'name': 'SO2',
78
- 'peak_area': peak_area_SO2,
79
- 'cross_section': sigma_results['SO2'],
80
- 'efficiency': efficiency_SO2},
81
- {'name': 'CO2',
82
- 'peak_area_1':peak_area_diad2, 'cross_section_1': sigma_results['CO2_2v2'],
83
- 'peak_area_2': peak_area_diad1, 'cross_section_2': sigma_results['CO2_v1'], 'efficiency': efficiency_CO2}
84
- ]
85
- mol_perc=calculate_mole_percent(components)
86
-
87
-
88
- return pd.DataFrame(mol_perc)
89
-
90
-
91
-
92
- ## Math for converting back and forth between Raman scattering cross sections
93
-
94
- def calculate_wavelength_dependent_cross_section(wavelength_nm, T_C, Raman_shift_cm, wavelength_independent_cross_section ):
95
- """ This function calculates the wavelength dependent cross section (lower case sigma) from the wavelength independent Raman scattering efficiency (Upper case sigma)
96
-
97
- Parameters
98
- ----------------
99
- wavelength_nm:
100
- laser wavelength used in nm to calculate the wavelength dependent cross section
101
-
102
- wavelength_independent_cross_section:
103
- Wavelength independent cross section
104
-
105
- T_K:
106
- absolute temperature in Kelvin
107
-
108
- Raman_shift_cm:
109
- Raman shift in cm-1 of peak of interest (e.g. 1151 for SO$_2$)
110
-
111
- Returns
112
- -----------------
113
- Wavelength dependent cross section
114
-
115
- """
116
- Wavelength_cm1=1/wavelength_nm*10000000
117
- constant =1-np.exp(((-6.626*10**-27)*(2.998*10**10)*Raman_shift_cm)/((1.381*10**-16)*(273.15+T_C)))
118
- Wavelength_dependent = wavelength_independent_cross_section/(((Wavelength_cm1-Raman_shift_cm)**(-4)/(Wavelength_cm1-2331)**(-4))*constant)
119
- return Wavelength_dependent
120
-
121
- def calculate_wavelength_independent_cross_section(wavelength_nm, T_C, Raman_shift_cm, wavelength_dependent_cross_section ):
122
- """ This function calculates the wavelength independent cross section (capital Sigma) from the wavelength dependent Raman scattering efficiency (lower case sigma)
123
-
124
- Parameters
125
- ----------------
126
- wavelength_nm:
127
- laser wavelength used in nm to calculate the wavelength dependent cross section
128
-
129
- wavelength_dependent_cross_section:
130
- Wavelength dependent cross section
131
-
132
- T_K:
133
- absolute temperature in Kelvin
134
-
135
- Raman_shift_cm:
136
- Raman shift in cm-1 of peak of interest (e.g. 1151 for SO$_2$)
137
-
138
- Returns
139
- -----------------
140
- Wavelength independent cross section
141
-
142
- """
143
- Wavelength_cm1=1/wavelength_nm*10000000
144
- constant =1-np.exp(((-6.626*10**-27)*(2.998*10**10)*Raman_shift_cm)/((1.381*10**-16)*(273.15+T_C)))
145
- Wavelength_independent = wavelength_dependent_cross_section*((Wavelength_cm1-Raman_shift_cm)**(-4)/(Wavelength_cm1-2331)**(-4)*constant)
146
- return Wavelength_independent
147
-
148
- def convert_cross_section_wavelength1_wavelength2(wavelength_nm_1,wavelength_nm_2, Raman_shift_cm, wavelength_dependent_cross_section_wavelength1, T_C):
149
- """ This function calculates the wavelength dependent cross section (lower case sigma) for laser wavelength 2 from the wavelength-dependent cross section for laser wavelength 1.
150
-
151
-
152
- Parameters
153
- ----------------
154
- wavelength_nm_1:
155
- laser wavelength used in nm to calculate the wavelength dependent cross section
156
-
157
- wavelength_nm_2:
158
- laser wavelength of the system of interest you are trying to calculate the wavelength dependent cross section for
159
-
160
- wavelength_dependent_cross_section_wavelength1:
161
- Wavelength dependent cross section
162
-
163
- T_K:
164
- absolute temperature in Kelvin
165
-
166
- Raman_shift_cm:
167
- Raman shift in cm-1 of peak of interest (e.g. 1151 for SO$_2$)
168
-
169
- Returns
170
- -----------------
171
- Wavelength dependent cross section for wavelength2
172
-
173
- """
174
-
175
- # First calculate the independent cross section
176
- ind_cross_sec=calculate_wavelength_independent_cross_section(wavelength_nm=wavelength_nm_1, T_C=T_C, Raman_shift_cm=Raman_shift_cm,
177
- wavelength_dependent_cross_section =wavelength_dependent_cross_section_wavelength1)
178
- print(ind_cross_sec)
179
- dep_cross_sec=calculate_wavelength_dependent_cross_section(wavelength_nm=wavelength_nm_2, T_C=T_C, Raman_shift_cm=Raman_shift_cm, wavelength_independent_cross_section =ind_cross_sec)
180
-
181
- return dep_cross_sec
182
-
183
-
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes