Skip to content

Instantly share code, notes, and snippets.

View ZGainsforth's full-sized avatar

Zack Gainsforth ZGainsforth

  • University of California at Berkeley
  • Los Angeles, CA, USA
View GitHub Profile
@ZGainsforth
ZGainsforth / RadialIntegrateAndFitHRTEMImageStack.py
Last active July 7, 2023 17:24
FFT an HRTEM image stack, Radially integrate it and then fit the integration with a background and gaussians.
import numpy as np
import hyperspy.api as hs
from scipy.ndimage import map_coordinates
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
from tifffile import imwrite, TiffWriter, TiffFile
from lmfit import Model, CompositeModel, Parameters
from lmfit.models import GaussianModel, QuadraticModel, PseudoVoigtModel
from functools import reduce
import operator
@ZGainsforth
ZGainsforth / Decomposition on FTIR map.ipynb
Created May 17, 2023 16:57
PCA, ICA, NMF on an FTIR map
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZGainsforth
ZGainsforth / AcquireStack.py
Created May 11, 2023 23:08
Using Tescan SharkSEM interface, acquire a stack of images rapidly in sequence.
import pdb
import os
import sys
sys.path.append(os.path.join('..', 'remote'))
import time
import sem
import struct
import base64
from sem_v3_lib import *
@ZGainsforth
ZGainsforth / Plot Oxford Stack.ipynb
Created May 11, 2023 19:51
Plot maps from h5ino file exported by Oxford Aztec SEM software. Make RGBs.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZGainsforth
ZGainsforth / PlotSPA.ipynb
Created January 27, 2023 02:45
Read Omnic spa files and plot them.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZGainsforth
ZGainsforth / Decomposition on NanoIR Spectrum Grid Array.ipynb
Created December 23, 2022 05:05
ICA, NMF, and PCA decomposition on a NanoIR spectrum grid array.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZGainsforth
ZGainsforth / QuantMap Bruker Stack.ipynb
Created October 7, 2022 07:47
Using hyperspy, quantify each pixel in a Bruker EDS map and output RGBs and quantitative images.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZGainsforth
ZGainsforth / Element Map Scatter Plots.ipynb
Created October 7, 2022 07:46
Make joint maps and pair plots from elemental maps using seaborn.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZGainsforth
ZGainsforth / Fityk fit three peaks together.fit
Created August 24, 2022 04:40
Fityk script file to fit three peaks in an EDS spectrum and output areas. Does all peak simultaneously and includes edge jumps pinned to fluoresence line intensities.
# Fityk script. Fityk version: 1.3.1. Created: Tue Aug 23 16:58:39 2022
set verbosity = -1 #the rest of the file is not shown
set autoplot = 0
reset
# ------------ settings ------------
set box_constraints = 1
set default_sigma = sqrt
set domain_percent = 30
set epsilon = 1e-012
@ZGainsforth
ZGainsforth / Fityk fit three peaks individually.fit
Last active August 24, 2022 04:38
Fityk script file to fit three peaks in an EDS spectrum and output areas. Does each peak independently. Does not include edge jumps.
# Fityk script. Fityk version: 1.3.1. Created: Fri Aug 19 12:09:17 2022
set verbosity = -1 #the rest of the file is not shown
set autoplot = 0
reset
# ------------ settings ------------
set box_constraints = 1
set default_sigma = sqrt
set domain_percent = 30
set epsilon = 1e-012