Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Velox(.emd) load gives error in HyperSpy 2 #333

Open
PereraUmesha opened this issue Nov 12, 2024 · 3 comments
Open

Velox(.emd) load gives error in HyperSpy 2 #333

PereraUmesha opened this issue Nov 12, 2024 · 3 comments
Labels
type: bug Something isn't working

Comments

@PereraUmesha
Copy link

Describe the bug

EDS Velox (.emd) file that can be loaded and processed using HyperSpy 1.7, gives errors with the same code in HyperSpy.

To Reproduce

Steps to reproduce the behavior:

import hyperspy.api as hs
test_data = hs.load('Velox_EDS-SI.emd')
print(test_data)

spec_data = hs.load('Velox_EDS-SI.emd', select_type="spectrum_image")
print(spec_data.get_lines_intensity()

Expected behavior

  1. Load the emd file and print the content
  2. Load the spectrum_image datea from emd file and print the lines intensity information

Python environement:

  • RosettaSciIO version: 0.6
  • Python version: 3.9
  • HyperSpy version: 2.1.1 (if relevant)
  • sparse: 0.15.4
  • exspy: 0.3.1 (The error is different depending on exspy is installed or not)

Additional context

When exspy is installed, error occurs at hs.load()

ERROR | Hyperspy | If this file format is supported, please report this error to the RosettaSciIO developers at https://github.com/hyperspy/rosettasciio/issues (hyperspy.io:599)

When exspy is not installed, error occurs at get_lines_intensity()

'Signal1D' object has no attribute 'get_lines_intensity'

@PereraUmesha PereraUmesha added the type: bug Something isn't working label Nov 12, 2024
@ericpre
Copy link
Member

ericpre commented Nov 12, 2024

To use get_lines_intensity, you need exspy to be installed, because it is a method of the EDSSpectrum class.

Can you provide the full error message when loading the file?

@PereraUmesha
Copy link
Author

Please find below the error messages:
(Please note that, not all .emd files give errors I've mentioned. Only .emd files from some EDS equipments give this error with HyperSpy2. All .emd files are working well with HypeerSpy 1.7)

In exspy installed environment: [error occurs at hs.load()]

2024/11/12 10:03:12:744:WARNING:signal_type='EDS_TEM' not understood. See hs.print_known_signal_types() for a list of installed signal types or https://github.com/hyperspy/hyperspy-extensions-list for the list of all hyperspy extensions providing signals.
2024/11/12 10:03:12:197:INFO:emd_spec_data: <Signal1D, title: EDS, dimensions: (512, 512|4096)>
2024/11/12 10:03:13:175:INFO:output data/main_image/Velox_EDS-SI_EDS-spectrum.png
<Signal1D, title: EDS, dimensions: (512, 512|4096)>
2024/11/12 10:03:13:39:ERROR:Traceback (most recent call last):
File "/home/umesha/hyperspy2_test/20241111_eds_velox_wo_exspy/code/main.py", line 34, in main
emd2img.main()
File "/home/umesha/hyperspy2_test/20241111_eds_velox_wo_exspy/code/modules/emd2img.py", line 198, in main
get_spec_images(emd_spec_data, emdfile.name[:-4])
File "/home/umesha/hyperspy2_test/20241111_eds_velox_wo_exspy/code/modules/emd2img.py", line 178, in get_spec_images
make_element_image(spec, name)
File "/home/umesha/hyperspy2_test/20241111_eds_velox_wo_exspy/code/modules/emd2img.py", line 96, in make_element_image
print(signal.get_lines_intensity())
AttributeError: 'Signal1D' object has no attribute 'get_lines_intensity'
Traceback (most recent call last):
File "/home/umesha/hyperspy2_test/20241111_eds_velox_wo_exspy/code/main.py", line 34, in main
emd2img.main()
File "/home/umesha/hyperspy2_test/20241111_eds_velox_wo_exspy/code/modules/emd2img.py", line 198, in main
get_spec_images(emd_spec_data, emdfile.name[:-4])
File "/home/umesha/hyperspy2_test/20241111_eds_velox_wo_exspy/code/modules/emd2img.py", line 178, in get_spec_images
make_element_image(spec, name)
File "/home/umesha/hyperspy2_test/20241111_eds_velox_wo_exspy/code/modules/emd2img.py", line 96, in make_element_image
print(signal.get_lines_intensity())
AttributeError: 'Signal1D' object has no attribute 'get_lines_intensity'

pip list

certifi 2024.8.30
chardet 5.2.0
charset-normalizer 3.4.0
click 8.1.7
cloudpickle 3.1.0
contourpy 1.3.0
cycler 0.12.1
dask 2024.8.0
flexcache 0.3
flexparser 0.4
fonttools 4.54.1
fsspec 2024.10.0
h5py 3.12.1
hyperspy 2.2.0
idna 3.10
imageio 2.36.0
importlib_metadata 8.5.0
importlib_resources 6.4.5
Jinja2 3.1.4
kiwisolver 1.4.7
lazy_loader 0.4
llvmlite 0.43.0
locket 1.0.0
MarkupSafe 3.0.2
matplotlib 3.9.2
mpmath 1.3.0
natsort 8.4.0
networkx 3.2.1
numba 0.60.0
numpy 2.0.2
packaging 24.2
partd 1.4.2
pillow 11.0.0
Pint 0.24.4
pip 22.0.4
platformdirs 4.3.6
pooch 1.8.2
prettytable 3.12.0
pyparsing 3.2.0
python-box 7.2.0
python-dateutil 2.9.0.post0
PyYAML 6.0.2
requests 2.32.3
rosettasciio 0.6
scikit-image 0.24.0
scipy 1.13.1
setuptools 58.1.0
six 1.16.0
sparse 0.15.4
sympy 1.13.3
tifffile 2024.8.30
toolz 1.0.0
tqdm 4.67.0
traits 6.4.3
typing_extensions 4.12.2
urllib3 2.2.3
wcwidth 0.2.13
zipp 3.21.0

In environment without exspy: [error occurs at get_lines_intensity()]

WARNING | RosettaSciIO | The file contains only one spectrum stream (rsciio.emd._emd_velox:582)
ERROR | Hyperspy | If this file format is supported, please report this error to the RosettaSciIO developers at https://github.com/hyperspy/rosettasciio/issues (hyperspy.io:599)
Traceback (most recent call last):
File "", line 1, in
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/hyperspy/io.py", line 536, in load
objects = [
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/hyperspy/io.py", line 537, in
load_single_file(filename, lazy=lazy, **kwds) for filename in filenames
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/hyperspy/io.py", line 596, in load_single_file
return load_with_reader(filename=filename, reader=reader, **kwds)
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/hyperspy/io.py", line 632, in load_with_reader
signal = dict2signal(signal_dict, lazy=lazy)
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/hyperspy/io.py", line 835, in dict2signal
signal = assign_signal_subclass(
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/hyperspy/io.py", line 779, in assign_signal_subclass
signal_class = getattr(importlib.import_module(value["module"]), key)
File "/home/umesha/local/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 972, in _find_and_load_unlocked
File "", line 228, in _call_with_frames_removed
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 972, in _find_and_load_unlocked
File "", line 228, in _call_with_frames_removed
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/exspy/init.py", line 22, in
from . import components
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/exspy/components/init.py", line 4, in
from .eels_cl_edge import EELSCLEdge
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/exspy/components/eels_cl_edge.py", line 29, in
from exspy._misc.eels.gosh_gos import GoshGOS, _GOSH_SOURCES
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/exspy/_misc/eels/init.py", line 2, in
from exspy._misc.eels.gosh_gos import GoshGOS
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/exspy/_misc/eels/gosh_gos.py", line 23, in
import pooch
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/pooch/init.py", line 19, in
from .processors import Unzip, Untar, Decompress
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/pooch/processors.py", line 15, in
import lzma
File "/home/umesha/local/lib/python3.9/lzma.py", line 27, in
from _lzma import *
ModuleNotFoundError: No module named '_lzma'

pip list

appdirs 1.4.4
certifi 2024.8.30
chardet 5.2.0
charset-normalizer 3.4.0
click 8.1.7
cloudpickle 3.1.0
contourpy 1.3.0
cycler 0.12.1
dask 2024.8.0
exspy 0.3.1
flexcache 0.3
flexparser 0.3.1
fonttools 4.54.1
fsspec 2024.10.0
h5py 3.12.1
hyperspy 2.1.1
idna 3.10
imageio 2.36.0
importlib_metadata 8.5.0
importlib_resources 6.4.5
Jinja2 3.1.4
kiwisolver 1.4.7
lazy_loader 0.4
llvmlite 0.43.0
locket 1.0.0
MarkupSafe 3.0.2
matplotlib 3.9.2
mpmath 1.3.0
natsort 8.4.0
networkx 3.2.1
numba 0.60.0
numpy 2.0.2
packaging 24.1
partd 1.4.2
pillow 11.0.0
Pint 0.24.3
pip 22.0.4
platformdirs 4.3.6
pooch 1.8.2
prettytable 3.12.0
pyparsing 3.2.0
python-box 7.2.0
python-dateutil 2.9.0.post0
PyYAML 6.0.2
requests 2.32.3
rosettasciio 0.6
scikit-image 0.24.0
scipy 1.13.1
setuptools 58.1.0
six 1.16.0
sparse 0.15.4
sympy 1.13.3
tifffile 2024.8.30
toolz 1.0.0
tqdm 4.66.6
traits 6.4.3
typing_extensions 4.12.2
urllib3 2.2.3
wcwidth 0.2.13
zipp 3.20.2

@ericpre
Copy link
Member

ericpre commented Nov 14, 2024

Based on the last part of the error message:

import pooch
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/pooch/**init**.py", line 19, in
from .processors import Unzip, Untar, Decompress
File "/home/umesha/hyperspy2_test/20241101_EDS_Velox/lib/python3.9/site-packages/pooch/processors.py", line 15, in
import lzma
File "/home/umesha/local/lib/python3.9/lzma.py", line 27, in
from _lzma import *
ModuleNotFoundError: No module named '_lzma'

It seems that your python installation is broken. If you have issue with installation, the easiest is to use the hyperspy bundle installer, other methods will need better understanding of how python distribution works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants