Commit f74220a1 authored by Thomas Vincent's avatar Thomas Vincent

Handle multiple energies in merge widget

parent 6aa8a783
......@@ -910,8 +910,11 @@ class MergeWidget(Qt.QDialog):
try:
name = 'Beam Energy'
self.__merger.beam_energy = \
assert_non_none(self.__acqParamWid.beam_energy)
if self.__acqParamWid.beamEnergyEditor.isEnabled():
self.__merger.beam_energy = \
assert_non_none(self.__acqParamWid.beam_energy)
else: # Read from scan
self.__merger.beam_energy = None
name = 'Direct beam'
dir_beam_v = assert_non_none(self.__acqParamWid.direct_beam_v)
......@@ -1180,15 +1183,29 @@ class MergeWidget(Qt.QDialog):
self.__acqParamsGbx.setEnabled(len(selected_ids) > 0)
self.__imageROIGbx.setEnabled(len(selected_ids) > 0)
self.__acqParamWid.clear()
# Set-up default values from first selected scan
if len(selected_ids) > 0:
energies = []
for scan_id in selected_ids:
calib = self.__merger.get_calibration(scan_id)
if 'mononrj' in calib:
energies.append(calib['mononrj'] * 1000.)
else: # Missing energy
energies = None
break
# Disable beam energy input if available in scans
self.__acqParamWid.beamEnergyEditor.setEnabled(energies is None)
if energies is not None:
self.__acqParamWid.beamEnergyEditor.setText(
"[%g;%g]" % (min(energies), max(energies)))
calib = self.__merger.get_calibration(selected_ids[0])
if calib:
_logger.info("Load calibration information from scan %s",
selected_ids[0])
if 'mononrj' in calib:
# Convert from keV to eV
self.__acqParamWid.beam_energy = calib['mononrj'] * 1000
if 'pixperdeg' in calib:
self.__acqParamWid.chperdeg_v = calib['pixperdeg']
self.__acqParamWid.chperdeg_h = calib['pixperdeg']
......@@ -1196,6 +1213,10 @@ class MergeWidget(Qt.QDialog):
self.__acqParamWid.direct_beam_h = calib['cen_pix_x']
if 'cen_pix_y' in calib:
self.__acqParamWid.direct_beam_v = calib['cen_pix_y']
if energies is None and 'mononrj' in calib:
# Not all scans have beam energy, use that of first scan
# Convert from keV to eV
self.__acqParamWid.beam_energy = calib['mononrj'] * 1000
self.__totalScansEdit.setText(str(len(matched_ids)))
self.__selectedScansEdit.setText(str(len(selected_ids)))
......
......@@ -69,14 +69,12 @@ class AcqParamsWidget(Qt.QWidget):
layout = Qt.QGridLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
# ===========
# beam energy
# ===========
row = 0
h_layout = Qt.QHBoxLayout()
self.__beam_nrg_edit = _dblLineEditWidget(8, read_only)
self.__beam_nrg_edit = _dblLineEditWidget(12, read_only)
h_layout.addWidget(self.__beam_nrg_edit)
h_layout.addWidget(Qt.QLabel('<b>eV</b>'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment