This page was generated from
docs/examples/ftir_functions/PyIRoGlass_Functions.ipynb.
Interactive online version:
.
Useful FTIR Functions for Density and Molar Absorptivity
This Jupyter notebook demonstrates the use of useful Python functions for calculating density and molar absorptivity.
The Jupyter notebook and data can be accessed here: https://github.com/SarahShi/PyIRoGlass/blob/main/docs/examples/ftir_functions/.
You need to have the PyIRoGlass PyPi package on your machine once. If you have not done this, please uncomment (remove the #) symbol and run the cell below.
[ ]:
#!pip install PyIRoGlass
Load Python Packages and Data
Load Python Packages
[3]:
# Import packages
import PyIRoGlass as pig
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
pig.__version__
Set paths to data
Update the path to the chemistry and thickness data.
[ ]:
chemistry_thickness_path = 'ChemThick.csv'
print(chemistry_thickness_path)
Load chemistry and thickness data
We will use the class pig.SampleDataLoader to load all FTIR spectra and chemistry and thickness data. The class takes the arguments:
spectrum_path: String or list path to the directory with spectral datachemistry_thickness_path: String path to CSV file with glass chemistry and thickness data
and contains the methods:
load_spectrum_directory: Loads spectral dataload_chemistry_thickness: Loads chemistry and thickness dataload_all_data: Loads spectral and chemistry and thickness data
Here, we use load_chemistry_thickness. This returns the outputs of:
chemistry: DataFrame of chemical datathickness: DataFrame of thickness data
The file names from the spectra (what comes before the .CSV) are important when we load in melt compositions and thicknesses. Unique identifiers identify the same samples. Make sure that this ChemThick.CSV file has the same sample names as the loaded spectra.
[ ]:
loader = pig.SampleDataLoader(chemistry_thickness_path=chemistry_thickness_path)
chemistry, thickness = loader.load_chemistry_thickness()
Display chemistry, the DataFrame of glass compositions.
[ ]:
chemistry
We’re ready to use the pig.calculate_density function now. We input the arguments:
chemistry: DataFrame of chemical dataT: Room temperature at time of FTIR analysis, given the sensitivity of density to temperatureP: Room pressure at time of FTIR analysis, given the sensitivity of density to pressuremodel: Density model; default is"LS"for Lesher and Spera (2015), alternative is"IT"for Iacovino and Till (2019)
and output:
mol: DataFrame containing oxide mole fraction for glass compositiondensity: DataFrame of glass density at the given room temperature and pressure during FTIR analysis
[ ]:
T = 25 # C
P = 1 # Bar
mol, density = pig.calculate_density(chemistry, T, P, model="LS")
Display mol, the DataFrame of oxide mole fractions for the given glass composition.
[ ]:
mol
Display density, the DataFrame of glass density at given room temperature and pressure during FTIR analysis.
[ ]:
density
We’re ready to use the pig.calculate_epsilon function now. We input the arguments:
chemistry: DataFrame of chemical dataT: Room temperature at time of FTIR analysis, given the sensitivity of density to temperature.P: Room pressure at time of FTIR analysis, given the sensitivity of density to pressure.
and output:
epsilon: DataFrame of molar absorptivities with their uncertainties.
Note that a UserWarning is returned if your compositions lie outside the calibration ranges for Tau or Eta and Epsilon. Use these molar absorptivities with caution.
[ ]:
T = 25 # C
P = 1 # Bar
epsilon = pig.calculate_epsilon(chemistry, T, P)
epsilon
There are a few things to note. Tau references the \(\mathrm{(Si^{4+}+Al^{3+})/Total \, Cations}\) value and Eta references the \(\mathrm{(Na^{+}/(Na^{+}+Ca^{2+}))}\) value. Each column with the prefix Epsilon represents the mean molar absorptivity, Sigma_Epsilon represents the uncertainty on the molar absorptivity.