Skip to main content

Posts

Showing posts with the label EELS

HyperSpy for EELS

HyperSpy is really an awesome package for EELS analysis in python. It's very convenient for use and we can get more detail information from the dm files. Here are some sample code of HyperSpy for EELS spectrum image. ====================================  import hyperspy.api as hs ds=hs.load('si.dm3') ch=100 w=3 # average spectrum w=w//2 linesig=ds.inav[ch-w:ch+w+1].mean() # Get the x-axis and y-axis values xx=linesig.axes_manager[-1].axis yy=linesig.data print(' Figure 1 ') plt.figure(1) plt.plot(xx,yy) plt.xlabel(' %s (%s) ' % (linesig.axes_manager[-1].name, linesig.axes_manager[-1].units)) plt.ylabel(' Counts (a.u.) ') plt.legend([' smooth data ']) plt.show() # signal silcing E0=405 Ee=580 print( 'Assignd by energy range --> using float(E0)' ) E0=float(E0) Ee=float(Ee) lin01=linesig.isig[E0:Ee] print(' E0=%6.0f. , Ee=%6.0f. , data points=%i ' % (E0,Ee,linesig.isig[E0:Ee].axes_man...

HyperSpy - read the calibration information in a dm3/dm4 file

Some example of dm3 file reading by using Python HyperSpy package, which can read the detail information of the dm file. -- # import packages import numpy as np import hyperspy.api as hs # load file sp=hs.load('sp.dm3') # Read the axis information      # Print all the calibration detail print(sp.axes_manager) ''' <Axes manager, axes: (272|2042)>             Name |   size |  index |  offset |   scale |  units  ================ | ======= | ====== | ======= | ======= | ======                     x |    272 |      0 |       -0 |  0.0025 |     µm   --------------- |  ------ | ----- |  ------ | ------- | ------    Energy loss |  2042 |         | 3.2e+02 |       1 |     eV...

MLLS in matlab

MLLS stands for  multiple linear least squares fitting, which is the common strategy for the solving EELS edge overlapping and which is also built-in the GMS software. The target spectrum Y and the reference spectrum X Y = A * X Assuming Y is 1*256 matrix and we have three reference spectrums, ie, X is 3*256 matrix. So A is 1*3 matrix. The target is to solve A. If Y and X are n*n matrices, we can use the simple formula Y * inv(X) = A * X * inv(X), ie., A = Y * inv(X). However, Y and X are not n*n  matrices, it is necessary to have some trick to solve it. We can multiply the transpose matrix to produce n*n matrix. Y * X' = A * X * X'  (ps X' means the transpose matrix of X) so A = Y * X' * inv(X * X') Here is the Matlab code: =========  % create target spectrum x=0:256; c=[90,120,155]; sig=[5,10,8]; int=[5,10,8]; xn=zeros(size(x)); ref=zeros(length(c),length(x)); factor=rand(size(c))'; for i=1:length(c)     xn=xn+int(i)*ex...

Some test for Top-hat filter

1. Peak standard deviation:     Set the peak std for 1, 2.5, 5, 10 and 20. After std=10, the signals are difficult to identify. 2. Noise:     Set different noise for 0%, 25%, 50%, 75% and 100%. The peaks are hard to identify from 75% noise. 3. Different THF signal window:     Set the noise to 100% and use the different signal window to identify the signal. The result shows the wider window can improve the peak identification. Summary: The THF can help us to identify the weak signal from the high exponential background. It is noted that the S/N ratio would affect the THF result. If we want to identify the rare element in the material, we may use the high S/N ratio spectrum for applying THF or using the large signal window for noisy data.