{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Reflectance FTIR Spectra\n", "\n", "- This Jupyter notebook provides an example workflow for processing reflectance FTIR spectra for thicknesses of olivine and glasses through PyIRoGlass. \n", "\n", "- The Jupyter notebook and data can be accessed here: https://github.com/SarahShi/PyIRoGlass/blob/main/docs/examples/reflectance_ftir/. \n", "\n", "- 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. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#!pip install PyIRoGlass" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Load Python Packages" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Import packages\n", "\n", "import PyIRoGlass as pig\n", "\n", "%matplotlib inline\n", "%config InlineBackend.figure_format = 'retina'\n", "\n", "pig.__version__" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Olivine Thicknesses\n", "\n", "The workflows for processing olivine and glass spectra are slightly different given variable refractive index (`n`) and wavenumbers (`lambda`) of applicability. We will walk through each individually. \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Change paths to direct to folder with olivine reflectance FTIR spectra\n", "\n", "ref_path_ol = 'SPECTRA/OL/'\n", "\n", "ol_loader = pig.SampleDataLoader(spectrum_path=ref_path_ol)\n", "ref_dfs_dict_ol = ol_loader.load_spectrum_directory(wn_high=2700, wn_low=2100)\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Let's look at what `ref_dfs_dict_ol`, a dictionary of reflectance FTIR spectra look like. Samples are identified by their file names and the wavenumber and absorbance data are stored for each spectrum. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ref_dfs_dict_ol" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The reflectance index (`n`) is a key input for this method. In olivine, the refractive index is compositionally dependent. Deer, Howie, and Zussman parameterize this value for olivine in \"An introduction to the rock-forming minerals\". The `pig.reflectance_index_ol` function performs this calculation, inputting forsterite content and returning the reflectance index. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Use DHZ parameterization of olivine reflectance index. \n", "\n", "n_ol = pig.reflectance_index_ol(0.72)\n", "\n", "print(n_ol)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "We're ready to use the `pig.calculate_mean_thickness` function now. We input the arguments:\n", "\n", "- `dfs_dict`: Dictionary where the keys are file identifiers and values are DataFrames with spectral data\n", "- `n`: Reflectance index\n", "- `wn_high` and `wn_low`: Wavenumber range\n", "- `plotting`: Boolean indicating whether figures should be made\n", "- `phaseol`: Boolean indicating whether the phase is olivine\n", "\n", "and return: \n", "\n", "- `thickness`: DataFrame of resultant thickness data\n", "\n", "We use the wavenumber range of 2700-2100 cm $\\mathrm{^{-1}}$ in olivine — see the paper for more details. We remove a baseline from the spectrum to remove variability existing in the absorbances and to allow the data to be centered around 0. This does not change amplitude. We have the `phaseol` boolean for specifying whether your phase is olivine or not. \n", "\n", "`pig.calculate_mean_thickness` function workflow is as follows: \n", "\n", "- Remove baseline to center the data around an absorbance of 0\n", "- Apply a Savitzky-Golay filter to smooth the data for single-spikes\n", "- Identify extrema\n", "- Calculate wavenumber differences between extrema\n", "- Calculate mean and $\\sigma$ thickness" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fuego_thickness = pig.calculate_mean_thickness(ref_dfs_dict_ol, n=n_ol, wn_high=2700, wn_low=2100, plotting=True, phaseol=True)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Display `thickness`, the DataFrame of resultant thickness data. The DataFrame quantifies mean and $\\sigma$ thicknesses just from the maxima, minima, and both. We recommend using `Thickness_M` and `Thickness_STD`, which represent the mean and $\\sigma$ thickness across all extrema. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fuego_thickness" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Glass Thicknesses\n", "\n", "Now, let's turn to glass. Slight variations exist within reflectance index, wavenumbers of interest, and the phaseol boolean. We use the Kumagai and Kaneoka, 2003 reflectance index of 1.546 for basaltic glass in this example. The wavenumber range is extended to 2850-1700 cm $\\mathrm{^{-1}}$. See the paper for more details. \n", "\n", "I won't show all the intermediate steps, and will jump forward to the results since the workflows are identical aside from these parameters. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Change paths to direct to folder with glass reflectance FTIR spectra\n", "\n", "ref_path_gl = 'SPECTRA/GL/'\n", "\n", "gl_loader = pig.SampleDataLoader(spectrum_path=ref_path_gl)\n", "ref_dfs_dict_gl = gl_loader.load_spectrum_directory(wn_high=2850, wn_low=1700)\n", "\n", "# n=1.546 in the range of 2000-2700 cm^-1 following Nichols and Wysoczanski, 2007 for basaltic glass\n", "\n", "n_gl = 1.546\n", "\n", "glass_thickness = pig.calculate_mean_thickness(ref_dfs_dict_gl, n=n_gl, wn_high=2850, wn_low=1700, plotting=True, phaseol=False)\n", "\n", "glass_thickness" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.16" } }, "nbformat": 4, "nbformat_minor": 4 }