Skip to content

Commit

Permalink
Bugfix for experiment lists with 1 item only
Browse files Browse the repository at this point in the history
(thanks @nksauter)
  • Loading branch information
phyy-nx committed May 28, 2020
1 parent 74d125e commit 4e02a48
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions model/experiment_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"][()]

Expand All @@ -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."""
Expand Down

0 comments on commit 4e02a48

Please sign in to comment.