DiadFit 1.0.5__py3-none-any.whl → 1.0.9__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.
@@ -1352,6 +1352,158 @@ def get_settings():
1352
1352
  # Return the settings
1353
1353
  return settings.get('meta_path'), settings.get('spectra_path'), settings.get('spectra_filetype'), \
1354
1354
  settings.get('prefix'), settings.get('prefix_str'), settings.get('spectra_file_ext'), settings.get('meta_file_ext'),settings.get('TruPower')
1355
+
1356
+ ## Give nice column names
1357
+
1358
+ ## Lets do the look up code.
1359
+ #
1360
+
1361
+ def add_column_name_descriptions(df):
1362
+
1363
+ """ Adds a new to inputted dataframe, with a description of what the diadfit columns mean underneath
1364
+
1365
+ Parameters
1366
+ -------------------
1367
+ df: pandas dataframe, including some columns from DiadFit (can have other columns too)
1368
+
1369
+ Returns
1370
+ ----------------------
1371
+ df: A dataframe with a new row, with descriptions for columns matching our reference key.
1372
+
1373
+
1374
+
1375
+ """
1376
+ lookup_key = {
1377
+ 'filename': 'name of file',
1378
+ 'Density g/cm3': 'Density of CO2 in g/cm3',
1379
+ 'σ Density g/cm3': '1 sigma error on density (combined from peak fitting, Ne correction model, and densimeter equation)',
1380
+ 'σ Density g/cm3 (from Ne+peakfit)': '1 sigma error on density (from just peak fitting + Ne correction model)',
1381
+ 'σ Density g/cm3 (from densimeter)': '1 sigma error on density (from just the densimeter equation)',
1382
+ 'Corrected_Splitting': 'Splitting in cm-1 after correcting for instrument drift',
1383
+ 'Corrected_Splitting_σ': '1 sigma error on splitting (combined from peak fitting, Ne correction model)',
1384
+ 'Corrected_Splitting_σ_Ne': '1 sigma error on splitting just from Ne correction model',
1385
+ 'Corrected_Splitting_σ_peak_fit': '1 sigma error on splitting just from peak fitting',
1386
+ 'power (mW)': 'Laser power used in mW measured by WITEC TruPower',
1387
+ 'Spectral Center': 'Spectral Center used for analysis',
1388
+ 'in range': 'Y or N - Is the corrected splitting within the calibration range of the densimeter?',
1389
+ 'Notes': 'Which segment of the densimeter was used (e.g. which of several polynomials)',
1390
+ 'LowD_RT': 'Density calculated using the low density part of the Room Temp densimeter',
1391
+ 'HighD_RT': 'Density calculated using the high density part of the Room Temp densimeter',
1392
+ 'LowD_SC': 'Density calculated using the low density segment of the 37C densimeter',
1393
+ 'LowD_SC_σ': 'Error on density calculated using the low density segment of the 37C densimeter',
1394
+ 'MedD_RC': 'Density calculated using the medium density segment of the 37C densimeter',
1395
+ 'MedD_SC_σ': 'Error on density calculated using the medium density segment of the 37C densimeter',
1396
+ 'HighD_SC': 'Density calculated using the high density segment of the 37C densimeter',
1397
+ 'HighD_SC_σ': 'Error on density calculated using the high density segment of the 37C densimeter',
1398
+ 'Temperature': 'User entered Temp description: SupCrit or RoomT ',
1399
+ 'Splitting': 'Distance between fitted peak centers of Diad 1 and Diad 2 (cm-1)',
1400
+ 'Split_σ': 'Error on splitting',
1401
+ 'Diad1_Combofit_Cent': 'Fitted peak center (cm-1) of Diad1 (combined fit of diad, HB, gaussian background etc. )',
1402
+ 'Diad1_cent_err': 'Error on peak center of Diad1 (cm-1, calculated using lmfit)',
1403
+ 'Diad1_Combofit_Height': 'Height (intensity) of Diad1 combined fit',
1404
+ 'Diad1_Voigt_Cent': 'Fitted peak center (cm-1) of Diad1 for just the main peak',
1405
+ 'Diad1_Voigt_Area': 'Fitted area of Diad1 for just the main peak',
1406
+ 'Diad1_Voigt_Sigma': 'Fitted sigma of Diad1 for just the main peak',
1407
+ 'Diad1_Residual': 'Residual of fit to Diad1 (see DiadFit paper for explanation)',
1408
+ 'Diad1_Prop_Lor': 'Proportion of Lorentzian in Psuedovoigt peak for Diad1',
1409
+ 'Diad1_fwhm': 'Full Width Half Maximum of the fit to Diad1',
1410
+ 'Diad1_refit': 'Notes any warnings that flagged during iterative fitting',
1411
+ 'Diad2_Combofit_Cent': 'Fitted peak center (cm-1) of Diad2 (combined fit of diad, HB, gaussian background etc. )',
1412
+ 'Diad2_cent_err': 'Error on peak center of Diad2 (cm-1, calculated using lmfit)',
1413
+ 'Diad2_Combofit_Height': 'Height (intensity) of Diad2 combined fit',
1414
+ 'Diad2_Voigt_Cent': 'Fitted peak center (cm-1) of Diad2 for just the main peak',
1415
+ 'Diad2_Voigt_Area': 'Fitted area of Diad2 for just the main peak',
1416
+ 'Diad2_Voigt_Sigma': 'Fitted sigma of Diad2 for just the main peak',
1417
+ 'Diad2_Residual': 'Residual of fit to Diad2 (see DiadFit paper for explanation)',
1418
+ 'Diad2_Prop_Lor': 'Proportion of Lorentzian in Psuedovoigt peak for Diad2',
1419
+ 'Diad2_fwhm': 'Full Width Half Maximum of the fit to Diad2',
1420
+ 'Diad2_refit': 'Notes any warnings that flagged during iterative fitting',
1421
+ 'HB1_Cent': 'Fitted peak center of HB1 (cm-1)',
1422
+ 'HB1_Area': 'Fitted area of HB1',
1423
+ 'HB1_Sigma': 'Fitted sigma of HB1',
1424
+ 'HB2_Cent': 'Fitted peak center of HB2 (cm-1)',
1425
+ 'HB2_Area': 'Fitted area of HB2',
1426
+ 'HB2_Sigma': 'Fitted sigma of HB2',
1427
+ 'C13_Cent': 'Fitted peak center of the C13 peak (cm-1)',
1428
+ 'C13_Area': 'Fitted area of the C13 peak',
1429
+ 'C13_Sigma': 'Fitted sigma of the C13 peak',
1430
+ 'Diad2_Gauss_Cent': 'Fitted peak center (cm-1) of the Gaussian background on Diad2 (if used)',
1431
+ 'Diad2_Gauss_Area': 'Fitted area of the Gaussian background on Diad2',
1432
+ 'Diad2_Gauss_Sigma': 'Fitted sigma of the Gaussian backgroun on Diad2',
1433
+ 'Diad1_Gauss_Cent': 'Fitted peak center (cm-1) of the Gaussian background on Diad1 (if used)',
1434
+ 'Diad1_Gauss_Area': 'Fitted area of the Gaussian background on Diad1',
1435
+ 'Diad1_Gauss_Sigma': 'Fitted sigma of the Gaussian backgroun on Diad1',
1436
+ 'Diad1_Asym50': 'Asymmetry of Diad1 using a 50% intensity cut off (see DeVitre et al. 2023, Volcanica)',
1437
+ 'Diad1_Asym70': 'Asymmetry of Diad1 using a 70% intensity cut off (see DeVitre et al. 2023, Volcanica)',
1438
+ 'Diad1_Yuan2017_sym_factor': 'Symmetry factor of Diad1 following Yuan 2017',
1439
+ 'Diad1_Remigi2021_BSF': 'BSF factor of Diad1 following Remigi (2021)',
1440
+ 'Diad2_Asym50': 'Asymmetry of Diad2 using a 50% intensity cut off (see DeVitre et al. 2023, Volcanica)',
1441
+ 'Diad2_Asym70': 'Asymmetry of Diad2 using a 70% intensity cut off (see DeVitre et al. 2023, Volcanica)',
1442
+ 'Diad2_Yuan2017_sym_factor': 'Symmetry factor of Diad2 following Yuan 2017',
1443
+ 'Diad2_Remigi2021_BSF': 'BSF factor of Diad2 following Remigi (2021)',
1444
+ 'Diad1_PDF_Model': 'Name of the probability density function used to fit Diad1',
1445
+ 'Diad2_PDF_Model': 'Name of the probability density function used to fit Diad2',
1446
+ 'Standard': 'Is the analysis a standard (Yes/No)',
1447
+ 'date': 'Full date of analysis',
1448
+ 'Month': 'Month of analysis',
1449
+ 'Day': 'Day of the week of analysis',
1450
+ 'Int_time (s)': 'Integration time of each individual spectra in s',
1451
+ 'accumulations':'How many individual spectra are collected and averaged for a single reported spectra',
1452
+ 'Mag (X)': 'Objective used during analysis',
1453
+ 'duration': 'Duration of analysis as a string from WITEC',
1454
+ '24hr_time': 'Time converted to a 24 hr clock',
1455
+ 'sec since midnight': 'time of acquisition as seconds after midnight on the day of analysis',
1456
+ 'Peak_Cent_SO2': 'Fitted peak center (cm-1) of the SO2 peak',
1457
+ 'Peak_Area_SO2': 'Fitted peak area (cm-1) of the SO2 peak',
1458
+ 'Peak_Height_SO2': 'Fitted peak height (cm-1) of the SO2 peak',
1459
+ 'Model_name_x': 'Model used to fit the SO2 peak',
1460
+ 'Peak_Cent_Carb': 'Fitted peak center (cm-1) of the Carb peak',
1461
+ 'Peak_Area_Carb': 'Fitted peak area (cm-1) of the Carb peak',
1462
+ 'Peak_Height_Carb': 'Fitted peak height (cm-1) of the Carb peak',
1463
+ 'Model_name_y': 'Model used to fit the SO2 peak',
1464
+ 'Carb_Diad_Ratio': 'Area of carbonate peak divided by sum of area of Diad1 and Diad2 ',
1465
+ 'SO2_Diad_Ratio': 'Area of the SO2 peak divided by sum of area of Diad1 and Diad2',
1466
+ 'SO2_mol_ratio': 'Molar proportion of SO2 in the gas species',
1467
+ 'time': 'seconds after midnight used for Ne correction ',
1468
+ 'preferred_values': 'Preferred value for Ne correction',
1469
+ 'lower_values': 'Preferred value - 1 sigma for Ne correction',
1470
+ 'upper_values': 'Preferred value + 1 sigma for Ne correction',
1471
+
1472
+ 'SingleCalc_D_km': 'Depth calculated using the preferred (average) value for the input parameters of the MC simulation',
1473
+ 'SingleCalc_P_kbar': 'Pressure calculated using the preferred (average) value for the input parameters of the MC simulation',
1474
+ 'Mean_MC_P_kbar': 'Mean pressure calculated by averaging all the MC simulations for a single FI',
1475
+ 'Med_MC_P_kbar':'Median pressure calculated by averaging all the MC simulations for a single FI',
1476
+ 'std_dev_MC_P_kbar':'Std deviation of pressure calculated from all the MC simulations for a single FI',
1477
+ 'std_dev_MC_P_kbar_from_percentile':'Std deviation of pressure calculated from 84th-16th quantile/2 calculated from all the MC simulations for a single FI',
1478
+ 'Mean_MC_D_km': 'Mean depth calculated by averaging all the MC simulations for a single FI',
1479
+ 'Med_MC_D_km':'Median depth calculated by averaging all the MC simulations for a single FI',
1480
+ 'std_dev_MC_D_km':'Std deviation of depth calculated from all the MC simulations for a single FI',
1481
+ 'std_dev_MC_D_km_from_percentile':'Std deviation of depth calculated from 84th-16th quantile/2 calculated from all the MC simulations for a single FI',
1482
+ 'error_T_K': 'Input error in K for the Monte Carlo simulation',
1483
+ 'CO2_dens_gcm3_input': 'Input CO2 content in g/cm3 for the Monte Carlo simulation',
1484
+ 'error_CO2_dens_gcm3': 'Input CO2 error in g/cm3 for the Monte Carlo simulation',
1485
+ 'crust_dens_kgm3_input': 'Selected crustal density for the Monte Carlo simulation',
1486
+ 'error_crust_dens_kgm3':'Input crustal density error for the Monte Carlo simulation',
1487
+ 'model': 'Selected model to convert pressure to depth in the crust',
1488
+ 'EOS': 'Selected EOS to convert density to pressure'
1489
+
1490
+ }
1491
+
1492
+ # Create a list of descriptions based on the lookup key
1493
+ description_row = [lookup_key.get(col, '') for col in df.columns]
1494
+
1495
+ # Create a new DataFrame from the description row
1496
+ description_df = pd.DataFrame([description_row], columns=df.columns)
1497
+
1498
+ # Use pd.concat to combine the description row and original DataFrame
1499
+ df_with_descriptions = pd.concat([description_df, df], ignore_index=True)
1500
+
1501
+ # Display the DataFrame with descriptions
1502
+ df_with_descriptions
1503
+
1504
+ return df_with_descriptions
1505
+
1506
+
1355
1507
 
1356
1508
 
1357
1509
 
@@ -1,87 +1,231 @@
1
1
  import math
2
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
3
152
 
4
- def calculate_sigma(wavelength, vi_dict, T_K):
5
- """
6
- This function calculates the σ cross section according to wavelength based on Burke (2001) EQ(1), you must provide:
7
- ### 1) the peak shift of the species, 2) temp (doesn't really matter) and 3) Σ (wavelength-independent relative Raman scattering cross-sections).
8
- """
9
- c = 2.998 * 10**10 # cm/s light speed
10
- h = 6.626 * 10**-27 # erg.s Planck constant
11
- k = 1.381 * 10**-16 # erg/K Boltzmann's constant
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.
12
155
 
13
- v0 = 1 / (wavelength * 10**-7)
14
156
 
15
- sigma_results = {}
16
- for name, vi_info in vi_dict.items():
17
- vi = vi_info["Peak_shift_cm-1"]
18
- BigSigma = vi_info["Σ"]
157
+ Parameters
158
+ ----------------
159
+ wavelength_nm_1:
160
+ laser wavelength used in nm to calculate the wavelength dependent cross section
19
161
 
20
- result = BigSigma / (((v0 - vi)**-4 / (v0 - 2331)**-4) * (1 - math.exp(-h * c * vi / (k * T_K))))
21
- sigma_results[name] = round(result, 2)
162
+ wavelength_nm_2:
163
+ laser wavelength of the system of interest you are trying to calculate the wavelength dependent cross section for
22
164
 
23
- return sigma_results
165
+ wavelength_dependent_cross_section_wavelength1:
166
+ Wavelength dependent cross section
24
167
 
168
+ T_K:
169
+ absolute temperature in Kelvin
25
170
 
171
+ Raman_shift_cm:
172
+ Raman shift in cm-1 of peak of interest (e.g. 1151 for SO$_2$)
26
173
 
174
+ Returns
175
+ -----------------
176
+ Wavelength dependent cross section for wavelength2
27
177
 
28
- def calculate_mole_percent(components):
29
- """ This function calculates the mole percents of the components entered, based on Burke (2001) EQ(2)
30
- """
31
- def partial_molec_contribution_single(A, sigma, squiggle):
32
- return A / (sigma * squiggle)
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
33
187
 
34
- def partial_molec_contribution_double(A1, sigma1, A2, sigma2, squiggle):
35
- return (A1 + A2) / ((sigma1 + sigma2) * squiggle)
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
+ ------------------
36
193
 
37
- total_partials = 0
38
- partials = []
194
+ SO2_wavelength_ind: Wavelength independent cross section for SO2
39
195
 
40
- for component in components:
41
- if component['name'] == 'CO2':
42
- partial = partial_molec_contribution_double(component['peak_area_1'], component['cross_section_1'],
43
- component['peak_area_2'], component['cross_section_2'],
44
- component['efficiency'])
45
- else:
46
- partial = partial_molec_contribution_single(component['peak_area'], component['cross_section'],
47
- component['efficiency'])
196
+ CO2_diad1_wavelength_ind: Wavelength independent cross section for diad 1 (at 1285)
48
197
 
49
- partials.append(partial)
50
- total_partials += partial
198
+ CO2_diad2_wavelength_ind: Wavelength independent cross section for diad 2 (at 1388)
51
199
 
52
- mole_percentages = [round((partial / total_partials) * 100, 1) for partial in partials]
200
+ wavelength_nm: Laser wavelenth of system in nm
53
201
 
54
- mole_percent_dict = {component['name']: mole_percent for component, mole_percent in zip(components, mole_percentages)}
55
- mole_percent_dict['Mole_Percent_Sum'] = sum(mole_percentages)
202
+ T_C: Temperature of analysis in C.
56
203
 
57
- return mole_percent_dict
204
+ Returns
205
+ ---------------
206
+
207
+ SO2 mol proportion
208
+
209
+
210
+ """
58
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)
59
215
 
60
216
 
217
+ SO2_prop=(A_SO2/SO2_cross_sec)/(A_CO2_Tot /(CO2_diad1_xsec + CO2_diad2_xsec) + (A_SO2/SO2_cross_sec) )
61
218
 
62
- 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):
219
+ return SO2_prop
63
220
 
64
- # First we need to calculate the oarameters
65
221
 
66
- component_dict = {
67
- "SO2": {"Peak_shift_cm-1": 1151, "Σ": sigma_SO2},
68
- "CO2_v1": {"Peak_shift_cm-1": 1285, "Σ": sigma_CO2_v1},
69
- "CO2_2v2": {"Peak_shift_cm-1": 1388, "Σ": sigma_CO2_v2}}
70
- ### "Σ" is the wavelength independent relative cross-section
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"""
71
224
 
72
- sigma_results = calculate_sigma(wavelength=wavelength, vi_dict=component_dict, T_K=T_K)
73
225
 
74
- # Now lets allocate these calculations
75
- components = [
76
- {'name': 'SO2',
77
- 'peak_area': peak_area_SO2,
78
- 'cross_section': sigma_results['SO2'],
79
- 'efficiency': efficiency_SO2},
80
- {'name': 'CO2',
81
- 'peak_area_1':peak_area_diad2, 'cross_section_1': sigma_results['CO2_2v2'],
82
- 'peak_area_2': peak_area_diad1, 'cross_section_2': sigma_results['CO2_v1'], 'efficiency': efficiency_CO2}
83
- ]
84
- mol_perc=calculate_mole_percent(components)
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)
85
229
 
230
+ return Ratio
86
231
 
87
- return pd.DataFrame(mol_perc)
DiadFit/ne_lines.py CHANGED
@@ -348,6 +348,11 @@ def calculate_Ne_line_positions(wavelength=532.05, cut_off_intensity=2000):
348
348
 
349
349
  Intensity=np.array([
350
350
 
351
+
352
+
353
+
354
+
355
+
351
356
  1500,
352
357
  12,
353
358
  500,