Skip to content

Instantly share code, notes, and snippets.

@mfhars
mfhars / Quant Bruker spx.ipynb
Created March 13, 2024 09:24 — forked from ZGainsforth/Quant Bruker spx.ipynb
Read in a Bruker spx spectrum and do basic TEM quantification to get area under the peaks.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mfhars
mfhars / ExtractSpectrumFromBruker.py
Created March 13, 2024 09:24 — forked from ZGainsforth/ExtractSpectrumFromBruker.py
Script to manually extract spectra out of a bruker bcf file by using a mask image. Written by Michael and Roger.
#1/5/2022 Michael Ofengenden & Roger Yu & A LOT A LOT of help from Zack Gainsforth
import sys, os
import hyperspy.api as hs
import numpy as np
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
import tifffile as tif
import skimage
from skimage.transform import resize
@mfhars
mfhars / DrawSpec.py
Created March 13, 2024 09:24 — forked from ZGainsforth/DrawSpec.py
Draw a spectrum and compare it against another. Using streamlit enable rescaling, shifting and gaussian convolution of spectra.
import streamlit as st
import numpy as np
import matplotlib.pyplot as plt
import os, sys
from scipy.ndimage.filters import gaussian_filter1d
from scipy.interpolate import interp1d
def ConvolveGaussian(Eraw, Iraw, Sigma):
E = np.linspace(Eraw[0], Eraw[-1], 10000)
dE = E[1] - E[0]
@mfhars
mfhars / PlotIR.py
Created March 13, 2024 09:23 — forked from ZGainsforth/PlotIR.py
A quick way to plot some IR spectra extracted from a NanoIR stack.
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import medfilt, convolve
from scipy.signal.windows import gaussian
import os, sys
SpectraPath = os.path.join(".")
SpectraFiles = {
"Top Crystal" : os.path.join(SpectraPath, "Top Crystal.txt"),
@mfhars
mfhars / BackgroundSubtractBrukerSpectra.ipynb
Created March 13, 2024 09:23 — forked from ZGainsforth/BackgroundSubtractBrukerSpectra.ipynb
Subtract the elements from one Bruker quant from another after normalizing one element. Useful for getting the composition of an inclusion or one phase out of a mixed phase where the other phase is known.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mfhars
mfhars / ReadSPA.py
Created March 13, 2024 09:23 — forked from ZGainsforth/ReadSPA.py
Read an SPA file from Omnic
# Created 2015, Zack Gainsforth
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import struct
from numpy.fft import fft, fftfreq
def LoadSPAInterferogram(FileName):
# Open the SPA file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mfhars
mfhars / PlotSPA.ipynb
Created March 13, 2024 09:22 — forked from ZGainsforth/PlotSPA.ipynb
Read Omnic spa files and plot them.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.