Importing Data

We walk through an implementation of PyIRoGlass here. We recommend following this tutorial as-is for those not familiar with navigating between directories in Python. This file structure should be locally replicaated:

PyIRoGlass/
├── Inputs/
│   ├── ChemThick.csv
│   ├── ReflectanceSpectra/
│   └── TransmissionSpectra/
│       └── YourDirectoryName
│           ├── a.CSV
│           ├── b.CSV
│           └── c.CSV
│
└── PyIRoGlass_RUN.py

Users can batch process their FTIR data by creating directories containing all spectra files, called TransmissionSpectra/YourDirectoryName here, in comma separated values (.CSV). Users should format their glass composition and thickness data as a spreadsheet of comma separated values (.CSV) file with each analysis having its own row and columns of sample name, oxide components in weight percentages, and thicknesses and uncertainties in thickness in micrometers. The spectrum file name must match the sample name input in the chemistry and thickness file. The order of columns does not matter, as the Python pandas package will identify the column heading regardless of its location.

The following columns are required for this ChemThick.CSV file:

  • \(\text{Sample}\)

  • \(\text{SiO}_{2}\)

  • \(\text{TiO}_{2}\)

  • \(\text{Al}_{2}\text{O}_{3}\)

  • \(\text{Fe}_{2}\text{O}_{3}\)

  • \(\text{FeO}_{t}\)

  • \(\text{MnO}\)

  • \(\text{MgO}\)

  • \(\text{CaO}\)

  • \(\text{Na}_{2}\text{O}\)

  • \(\text{K}_{2}\text{O}\)

  • \(\text{P}_{2}\text{O}_{5}\)

  • \(\text{Thickness}\)

  • \(\text{Sigma_Thickness}\)

For example, here is an example of a .CSV table containing the glass composition and thickness data (scroll across to see the entire table). You can use the ChemThickTemplate.CSV from the PyIRoGlass GitHub repository to create your own. You should fill every cell, else PyIRoGlass will assume that oxide was not analyzed or detected. For oxides that were not analyzed or not detected, enter 0 into the cell.

Sample

SiO2

TiO2

Al2O3

Fe2O3

FeO

MnO

MgO

CaO

Na2O

K2O

P2O5

Thickness

Sigma_Thickness

AC4_EUH33

53.02

0.96

18.28

2.16

7.89

0.23

3.48

7.18

4.48

1.15

0.28

49.60

3.00

AC4_EUH102

50.26

0.92

17.60

2.17

7.92

0.21

4.31

9.30

3.57

0.69

0.16

45.63

3.00

AC4_OL3

51.87

1.01

18.20

2.16

7.89

0.23

3.52

6.94

4.73

1.14

0.16

49.33

3.00

AC4_OL21

50.36

1.25

17.51

2.08

7.59

0.18

3.78

8.23

4.01

0.85

0.20

31.67

3.00

For the liquid composition, PyIRoGlass allows users to specify how they partition \(\text{Fe}\) between ferrous and ferric iron, because glass density changes due to the proportion of \(\text{Fe}^{3+}\). Both the Lesher and Spera [2015] and Iacovino and Till [2019] density models are available for use. To avoid ambiguity, the ChemThick.CSV handles this by providing two columns for \(\text{FeO}\) and \(\text{Fe}_2\text{O}_3\). If the speciation is unknown, input all \(\text{Fe}\) as \(\text{FeO}\) and leave the \(\text{Fe}_2\text{O}_3\) cells empty. This will not constitute the largest uncertainty, as the molar absorptivities and thicknesses impact concentrations more significantly.

Importing Package

We import the package PyIRoGlass in Python.

import PyIRoGlass as pig

PyIRoGlass for Transmission FTIR Spectra

We use the os package in Python to facilitate navigation to various directories and files. To load the transmission FTIR spectra, you must provide the path to the directory. Specify the wavenumbers of interest to fit all species peaks between 5500 and 1000 cm-1.

path = os.getcwd() + '/Inputs/TransmissionSpectra/YourDirectoryName/'
loader = pig.SampleDataLoader(spectrum_path=path)
dfs_dict = loader.load_spectrum_directory()

pig.SampleDataLoader and load_spectrum_directory() returns dfs_dict, a dictionary of the wavenumber and absorbance of each sample.

To load the .CSV containing glass chemistry and thickness information, provide the path to the file.

chemistry_thickness_path = os.getcwd() + '/Inputs/ChemThick.csv'
loader = pig.SampleDataLoader(chemistry_thickness_path=chemistry_thickness_path)
chemistry, thickness = loader.load_chemistry_thickness()

Inspect each returned data type to ensure that the data imports are successful.

Thicknesses from Reflectance FTIR Spectra

Loading reflectance FTIR spectra occurs through a near-identical process. Define your path to the file, but modify the wavenumbers of interest for either glass or olivine.

ref_path = os.getcwd() + '/Inputs/ReflectanceSpectra/YourDirectoryName/'
loader = pig.SampleDataLoader(spectrum_path=ref_path)
ref_dfs_dict = loader.load_spectrum_directory(wn_high=wn_high, wn_low=wn_low)

For olivine, specify the following wavenumber range based on Nichols and Wysoczanski [2007] and calculate the relevant reflectance index \(n\) for your given \(X_{Fo}\) from Howie et al. [1992].

ref_dfs_dict_ol = loader.load_spectrum_directory(wn_high=2700, wn_low=2100)
n_ol = pig.reflectance_index(XFo)

For glass, specify the following wavenumber range based on Nichols and Wysoczanski [2007] and enter the relevant reflectance index \(n\). We use the reflectance index for basaltic glasses from Nichols and Wysoczanski [2007] here.

ref_dfs_dict_gl = loader.load_spectrum_directory(wn_high=2850, wn_low=1700)
n_gl = 1.546

Data Import Complete

That is all for loading files! You are ready to get rolling with PyIRoGlass. See the example notebook PyIRoGlass_RUN.ipynb, under the big examples heading, to see how to run PyIRoGlass and export files.