Commit 491bc01e authored by Thomas Vincent's avatar Thomas Vincent

Make kmap merger support multiple energies

parent f74220a1
...@@ -44,6 +44,7 @@ img_base = '/path/to/img/dir/' ...@@ -44,6 +44,7 @@ img_base = '/path/to/img/dir/'
# the beam energy (note that this value can be changed later when calling the # the beam energy (note that this value can be changed later when calling the
# img_2_qpeak function) # img_2_qpeak function)
# Set to None to read it from scan headers
beam_energy = 8000. beam_energy = 8000.
# merge_scan_data will take all scans from the spec file that have a matching # merge_scan_data will take all scans from the spec file that have a matching
......
...@@ -152,6 +152,11 @@ class AcqParamsWidget(Qt.QWidget): ...@@ -152,6 +152,11 @@ class AcqParamsWidget(Qt.QWidget):
self.__chpdeg_h_edit.clear() self.__chpdeg_h_edit.clear()
self.__chpdeg_v_edit.clear() self.__chpdeg_v_edit.clear()
@property
def beamEnergyEditor(self):
"""Beam energy editor widget (QLineEdit)"""
return self.__beam_nrg_edit
@property @property
def beam_energy(self): def beam_energy(self):
text = self.__beam_nrg_edit.text() text = self.__beam_nrg_edit.text()
......
...@@ -147,6 +147,14 @@ class KmapMerger(object): ...@@ -147,6 +147,14 @@ class KmapMerger(object):
self.__thread = None self.__thread = None
self.beam_energy = None
"""Beam energy in eV to set for all scans.
If None (the default) the energy is read from SPEC for each scan.
Union[float,None]
"""
self.prefix = None self.prefix = None
self.__set_status(self.READY) self.__set_status(self.READY)
...@@ -266,13 +274,22 @@ class KmapMerger(object): ...@@ -266,13 +274,22 @@ class KmapMerger(object):
results = {} results = {}
self.__proc_indices = {} self.__proc_indices = {}
for proc_idx, (scan_id, infos) in enumerate(scans.items()): for proc_idx, (scan_id, infos) in enumerate(scans.items()):
# Get beam energy
if self.beam_energy is not None: # Use forced beam energy
beam_energy = self.beam_energy
else: # Read beam energy from each scan header
nrj_kev = self.get_calibration(scan_id).get('mononrj', None)
if nrj_kev is None:
raise RuntimeError("Cannot read beam energy")
beam_energy = nrj_kev * 1000. # From keV to eV
args = (scan_id, args = (scan_id,
proc_idx, proc_idx,
self.__spec_h5, self.__spec_h5,
self.__output_dir, self.__output_dir,
infos['output'], infos['output'],
infos['image'], infos['image'],
self.beam_energy, beam_energy,
self.chan_per_deg, self.chan_per_deg,
self.center_chan, self.center_chan,
self.compression, self.compression,
...@@ -465,8 +482,6 @@ class KmapMerger(object): ...@@ -465,8 +482,6 @@ class KmapMerger(object):
def check_parameters(self): def check_parameters(self):
errors = [] errors = []
if self.beam_energy is None:
errors.append('invalid "Beam energy"')
if self.output_dir is None: if self.output_dir is None:
errors.append('invalid "Output directory"') errors.append('invalid "Output directory"')
if self.center_chan is None: if self.center_chan is None:
...@@ -475,12 +490,6 @@ class KmapMerger(object): ...@@ -475,12 +490,6 @@ class KmapMerger(object):
errors.append('invalid "Channel per degree"') errors.append('invalid "Channel per degree"')
return errors return errors
beam_energy = property(lambda self: self.__params['beam_energy'])
@beam_energy.setter
def beam_energy(self, beam_energy):
self.__params['beam_energy'] = float(beam_energy)
chan_per_deg = property(lambda self: self.__params['chan_per_deg']) chan_per_deg = property(lambda self: self.__params['chan_per_deg'])
@chan_per_deg.setter @chan_per_deg.setter
......
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