fpd_to_hyperspy fails using latest Hyperspy version
By default, when installing fpd
via pip
the latest version of HyperSpy is installed (currently v1.6.1) Changes to the EMD file reader in this version cause fpd_to_hyperspy to fail. The previous version of Hyperspy (v1.5.2) works just fine.
It looks like a problem on the Hyperspy side so maybe I will open an issue there. In the meantime, maybe the Hyperspy version should be pinned at 1.5.2 to ensure compatibility?
Here is code that causes the error.
import fpd.fpd_file as fpdf
import hyperspy as hs
print(hs.__version__)
1.6.1
signals = fpdf.fpd_to_hyperspy(h5filename)
~/miniconda3/envs/fpd2/lib/python3.9/site-packages/fpd/fpd_file.py in fpd_to_hyperspy(fpg, fpd_check, assume_yes, group_names)
3063 from hyperspy.io import dict2signal
3064
-> 3065 ds = emd.file_reader(h5f_fn, lazy=True)
3066 titles = [d['original_metadata']['General']['title'].split('/')[-1] for d in ds]
3067 indices = _check_titles(titles, group_names, hs_non_lazy)
~/miniconda3/envs/fpd2/lib/python3.9/site-packages/hyperspy/io_plugins/emd.py in file_reader(filename, lazy, **kwds)
1830 raise IOError("The file is not a supported EMD file.")
1831 except Exception as e:
-> 1832 raise e
1833 finally:
1834 if not lazy:
~/miniconda3/envs/fpd2/lib/python3.9/site-packages/hyperspy/io_plugins/emd.py in file_reader(filename, lazy, **kwds)
1825 stack_group = kwds.pop('stack_group', None)
1826 emd_reader = EMD_NCEM(**kwds)
-> 1827 emd_reader.read_file(file, lazy=lazy, dataset_path=dataset_path,
1828 stack_group=stack_group)
1829 else:
~/miniconda3/envs/fpd2/lib/python3.9/site-packages/hyperspy/io_plugins/emd.py in read_file(self, file, lazy, dataset_path, stack_group)
571
572 om = self._parse_original_metadata()
--> 573 data, axes = self._read_data_from_groups(
574 group_paths,
575 dataset_name,
~/miniconda3/envs/fpd2/lib/python3.9/site-packages/hyperspy/io_plugins/emd.py in _read_data_from_groups(self, group_path, dataset_name, stack_key, original_metadata)
658 chunks = array_list[0].chunks
659 if chunks is None:
--> 660 chunks = calculate_chunks(array_list[0].shape, array_list[0].dtype)
661
662 if len(array_list) > 1:
~/miniconda3/envs/fpd2/lib/python3.9/site-packages/hyperspy/io_plugins/emd.py in calculate_chunks(shape, dtype, chunk_size_mb)
96 chunks += (shape[i],)
97 # At least one signal
---> 98 chunks += (shape[-1], )
99 return chunks
100
IndexError: tuple index out of range