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
'''
# axis 0
print('\n\n')
print('----- information in axis 0 -----')
print('size = '+ str(sp.axes_manager[0].size))
print('offset = '+ str(sp.axes_manager[0].offset))
print('scale = ' + str(sp.axes_manager[0].scale))
print('units : ' + sp.axes_manager[0].units+'\n')
'''
----- information in axis 0 -----
size = 272
offset = -0.0
scale = 0.0025309091433882713
units : µm
'''
# axis 1
print('----- Operation in axis 1 -----')
print(sp.axes_manager[1].name)
print('Energy shift = '+ str(sp.axes_manager[1].offset) +' '+ sp.axes_manager[1].units)
print('Scale = '+ str(sp.axes_manager[1].scale) +' '+ sp.axes_manager[1].units)
'''
----- Operation in axis 1 -----
Energy loss
Energy shift = 320.9004211425781 eV
Scale = 1.0 eV
'''
--
# 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
'''
# axis 0
print('\n\n')
print('----- information in axis 0 -----')
print('size = '+ str(sp.axes_manager[0].size))
print('offset = '+ str(sp.axes_manager[0].offset))
print('scale = ' + str(sp.axes_manager[0].scale))
print('units : ' + sp.axes_manager[0].units+'\n')
'''
----- information in axis 0 -----
size = 272
offset = -0.0
scale = 0.0025309091433882713
units : µm
'''
# axis 1
print('----- Operation in axis 1 -----')
print(sp.axes_manager[1].name)
print('Energy shift = '+ str(sp.axes_manager[1].offset) +' '+ sp.axes_manager[1].units)
print('Scale = '+ str(sp.axes_manager[1].scale) +' '+ sp.axes_manager[1].units)
'''
----- Operation in axis 1 -----
Energy loss
Energy shift = 320.9004211425781 eV
Scale = 1.0 eV
'''
Comments
Post a Comment