Created
August 16, 2021 20:25
-
-
Save ZGainsforth/e604374efda48bba400a8e05484c8116 to your computer and use it in GitHub Desktop.
Plot a STXM linescan. It will be a 2D image file with one dimension spatial and the other energy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from skimage.io import imread, imsave | |
from icecream import ic | |
# from QuickPlot import PrettyPlot | |
E = np.genfromtxt('532_210619074_energies.txt') | |
x = imread('532_210619074_CPX_Linescan.tif') | |
# The pixels are 100 nm in length, and the image was rotated 65 degrees. Therefore, the length of a pixel in this raster is (about 110 nm): | |
dx = 100 / np.cos(np.radians(65)) | |
# Normalize all the spectra | |
x = x-x[1,:] # Subtract off pre-edge | |
x = x/x[74,:] # Normalize height to highest peak in Ca-L2. | |
# Crop to just the L2 edge, and cut out a little bit at the beginning and end of the spatial axis since the line scan extends beyond the end of the the crystal in both sides. | |
x = x[53:91, 3:17] | |
# Remove a sliver in the middle of the spatial axis which is the gap between the two microtome shards. | |
x[:, 4:-2] = x[:,6:] | |
x = x[:,:-2] | |
ic(x.shape) | |
# And draw that puppy! | |
plt.imshow(x.T, vmin=0.05,vmax=0.9, extent=[E[53], E[91], 0,dx*x.shape[1]/1000]) | |
plt.ylabel('$\mu$m') | |
plt.xlabel('eV') | |
plt.title('Ca-L$_2$ peaks across CPX grain') | |
plt.savefig('532_210619074_CPX_Linescan_L3_extracted.png', dpi=300) | |
imsave('532_210619074_CPX_Linescan_L3_extracted.tif', x) | |
plt.show() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment