From 4e02a48c4c8c5f4a8200ec7ccbf28f0deaf1723b Mon Sep 17 00:00:00 2001 From: Aaron Brewster Date: Thu, 21 May 2020 14:00:37 -0700 Subject: [PATCH] Bugfix for experiment lists with 1 item only (thanks @nksauter) --- model/experiment_list.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/model/experiment_list.py b/model/experiment_list.py index 712fa097a..1776433d6 100644 --- a/model/experiment_list.py +++ b/model/experiment_list.py @@ -384,7 +384,7 @@ def _read_spectra_h5(self, beams): import h5py - f = h5py.File(self._obj["spectra_h5"], "r") + f = h5py.File(os.path.join(self._directory, self._obj["spectra_h5"]), "r") all_energies = f["all_energies"][()] all_weights = f["all_weights"][()] @@ -395,11 +395,16 @@ def _read_spectra_h5(self, beams): spectrum_index = self._obj["beam"][i].get("spectrum_index") if spectrum_index is not None: if len(all_energies.shape) == 1: - beam.set_spectrum(all_energies, all_weights[spectrum_index]) + spectrum = all_energies else: - beam.set_spectrum( - all_energies[spectrum_index], all_weights[spectrum_index] - ) + spectrum = all_energies[spectrum_index] + + if len(all_weights.shape) == 1: + weights = all_weights + else: + weights = all_weights[spectrum_index] + + beam.set_spectrum(spectrum, weights) def _make_mem_imageset(self, imageset): """Can't make a mem imageset from dict."""