Skip to main content

Posts

Showing posts from March, 2019

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...