This page was generated from
docs/Examples/Fitting_Fermi_Diads/Example1f_Diad_Peak_Assymetry/Asessing_Diad_Skewness.ipynb.
Interactive online version:
.
Assesing diad skewness
This notebook uses the protocol of DeVitre et al. (in review) to assess diad skewness. This can be useful to identify liquid CO\(_2\) in room temperature diad acqusitions
[1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import DiadFit as pf
pf.__version__
[1]:
'1.0.0'
Set path, and filetype
[2]:
filetype='headless_txt'
import os
spectra_path=os.getcwd()
file_ext='.txt'
exclude_str=['Ne']
Diad_Files=pf.get_files(path=spectra_path,
file_ext=file_ext, exclude_str=exclude_str)
Diad_Files
[2]:
['G170_004_1_4_0.5MW_1800G_45S_5ACC (CRR) (1).txt',
'G170_004_1_4_0.5MW_1800G_45S_5ACC (CRR).txt',
'G170_004_2_4_10MW_1800G_5S_1ACC (CRR).txt',
'G170_004_2_4_10MW_1800G_5S_5ACC (CRR).txt',
'G170_004_2_4_5MW_1800G_10S_1ACC (CRR).txt',
'G170_004_2_4_5MW_1800G_10S_3ACC (CRR).txt']
Tweak fit for 1 file before you loop
[3]:
filename=Diad_Files[0]
# Cut off intensity from peak to assess skewness
int_cut_off=0.3
# Calculates absolute skewness, e.g., biggest possible value
skewness='abs'
[4]:
diad1_config=pf.diad1_fit_config(upper_bck_diad1=(1330, 1350))
print(diad1_config)
diad1_fit_config(model_name='PseudoVoigtModel', fit_peaks=2, N_poly_bck_diad1=1, lower_bck_diad1=(1180, 1220), upper_bck_diad1=(1330, 1350), fit_gauss=False, gauss_amp=1000, diad_sigma=0.2, diad_sigma_min_allowance=0.2, diad_sigma_max_allowance=5, diad_prom=100, HB_prom=20, x_range_baseline=75, y_range_baseline=100, dpi=200, x_range_residual=20, return_other_params=False)
Try these parameters for Diad1
[5]:
prominence=10 # prominence for Scipy find peaks
AR_test_diad1=pf.assess_diad1_skewness(config1=diad1_config,
int_cut_off=int_cut_off,
skewness=skewness, path=spectra_path, filename=filename,
filetype=filetype, prominence=prominence)
AR_test_diad1
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:1463: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:895: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(self._y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:754: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
posy = float(self.convert_yunits(self._y))
[5]:
| filename | Skewness_diad1 | LHS_tie_diad1 | RHS_tie_diad1 | |
|---|---|---|---|---|
| 0 | G170_004_1_4_0.5MW_1800G_45S_5ACC (CRR) (1).txt | 2.697283 | 1281.135853 | 1285.983107 |
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:1463: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:754: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
posy = float(self.convert_yunits(self._y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:895: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(self._y))
Try these parameters for diad2
[6]:
diad2_config=pf.diad2_fit_config(lower_bck_diad2=(1330, 1360))
print(diad2_config)
diad2_fit_config(model_name='PseudoVoigtModel', fit_peaks=3, N_poly_bck_diad2=1, lower_bck_diad2=(1330, 1360), upper_bck_diad2=(1440, 1470), fit_gauss=False, gauss_amp=1000, diad_sigma=0.2, diad_sigma_min_allowance=0.2, diad_sigma_max_allowance=5, diad_prom=100, HB_prom=20, C13_prom=10, x_range_baseline=75, y_range_baseline=100, plot_figure=True, dpi=200, x_range_residual=20, return_other_params=False)
[7]:
AR_test_diad2=pf.assess_diad2_skewness(config1=diad2_config,
int_cut_off=int_cut_off, prominence=prominence,
skewness=skewness, path=spectra_path, filename=filename,
filetype=filetype)
AR_test_diad2
[7]:
| Skewness_diad2 | LHS_tie_diad2 | RHS_tie_diad2 | |
|---|---|---|---|
| 0 | 2.037267 | 1385.54434 | 1388.961252 |
Now lets loop through all the files
[8]:
df_combo=pf.loop_diad_skewness(Diad_files=Diad_Files,
path=spectra_path, skewness=skewness, prominence=prominence,
filetype=filetype,config_diad1=diad1_config, config_diad2=diad2_config,
int_cut_off=int_cut_off)
df_combo
working on file #0
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:1463: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:895: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(self._y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:754: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
posy = float(self.convert_yunits(self._y))
working on file #1
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:1463: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:895: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(self._y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:754: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
posy = float(self.convert_yunits(self._y))
working on file #2
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:1463: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:895: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(self._y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:754: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
posy = float(self.convert_yunits(self._y))
working on file #3
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:1463: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:895: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(self._y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:754: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
posy = float(self.convert_yunits(self._y))
working on file #4
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:1463: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:895: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(self._y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:754: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
posy = float(self.convert_yunits(self._y))
working on file #5
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:1463: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:895: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(self._y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:754: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
posy = float(self.convert_yunits(self._y))
[8]:
| filename | Skewness_diad1 | Skewness_diad2 | LHS_tie_diad1 | RHS_tie_diad1 | LHS_tie_diad2 | RHS_tie_diad2 | |
|---|---|---|---|---|---|---|---|
| 0 | G170_004_1_4_0.5MW_1800G_45S_5ACC (CRR) (1).txt | 2.697283 | 2.037267 | 1281.135853 | 1285.983107 | 1385.544340 | 1388.961252 |
| 0 | G170_004_1_4_0.5MW_1800G_45S_5ACC (CRR).txt | 2.681303 | 1.827020 | 1281.471667 | 1285.879649 | 1385.843407 | 1388.972432 |
| 0 | G170_004_2_4_10MW_1800G_5S_1ACC (CRR).txt | 1.075834 | 1.167500 | 1282.302722 | 1285.784672 | 1386.324151 | 1388.747433 |
| 0 | G170_004_2_4_10MW_1800G_5S_5ACC (CRR).txt | 1.036585 | 1.041332 | 1281.980476 | 1285.379321 | 1386.062816 | 1388.547589 |
| 0 | G170_004_2_4_5MW_1800G_10S_1ACC (CRR).txt | 1.246673 | 1.405337 | 1281.994044 | 1285.716831 | 1386.076792 | 1388.722277 |
| 0 | G170_004_2_4_5MW_1800G_10S_3ACC (CRR).txt | 2.353796 | 1.616774 | 1281.763384 | 1285.284343 | 1385.944028 | 1388.778178 |
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:1463: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:754: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
posy = float(self.convert_yunits(self._y))
c:\Users\penny\anaconda3\Lib\site-packages\matplotlib\text.py:895: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
y = float(self.convert_yunits(self._y))
[9]:
## This is the outputted data
df_combo
[9]:
| filename | Skewness_diad1 | Skewness_diad2 | LHS_tie_diad1 | RHS_tie_diad1 | LHS_tie_diad2 | RHS_tie_diad2 | |
|---|---|---|---|---|---|---|---|
| 0 | G170_004_1_4_0.5MW_1800G_45S_5ACC (CRR) (1).txt | 2.697283 | 2.037267 | 1281.135853 | 1285.983107 | 1385.544340 | 1388.961252 |
| 0 | G170_004_1_4_0.5MW_1800G_45S_5ACC (CRR).txt | 2.681303 | 1.827020 | 1281.471667 | 1285.879649 | 1385.843407 | 1388.972432 |
| 0 | G170_004_2_4_10MW_1800G_5S_1ACC (CRR).txt | 1.075834 | 1.167500 | 1282.302722 | 1285.784672 | 1386.324151 | 1388.747433 |
| 0 | G170_004_2_4_10MW_1800G_5S_5ACC (CRR).txt | 1.036585 | 1.041332 | 1281.980476 | 1285.379321 | 1386.062816 | 1388.547589 |
| 0 | G170_004_2_4_5MW_1800G_10S_1ACC (CRR).txt | 1.246673 | 1.405337 | 1281.994044 | 1285.716831 | 1386.076792 | 1388.722277 |
| 0 | G170_004_2_4_5MW_1800G_10S_3ACC (CRR).txt | 2.353796 | 1.616774 | 1281.763384 | 1285.284343 | 1385.944028 | 1388.778178 |
[ ]: