Commit 2ef0dce9 authored by Thomas Vincent's avatar Thomas Vincent

Add saving of acquisition parameters to QSpaceConverter

parent 41349b6d
......@@ -207,6 +207,30 @@ class QSpaceH5(XsocsH5Base):
with self.qspace_dset_ctx() as dset:
return dset.shape[1:]
@property
def beam_energy(self):
"""Returns the beam energy in eV.
It might be None if not stored.
"""
return self._get_scalar_data(self.params_path + '/beam_energy')
@property
def direct_beam(self):
"""Returns direct beam calibration position.
It might be None if not stored.
"""
return self._get_array_data(self.params_path + '/direct_beam')
@property
def channels_per_degree(self):
"""Returns channels per degree calibration.
It might be None if not stored.
"""
return self._get_array_data(self.params_path + '/channels_per_degree')
class QSpaceH5Writer(QSpaceH5):
cube_dtype = _np.float32
......@@ -400,5 +424,35 @@ class QSpaceH5Writer(QSpaceH5):
' {0}.'.format(sample_roi))
self._set_array_data(path, _np.array(sample_roi))
def set_beam_energy(self, beam_energy):
"""Stores the beam_energy used when converting to q space
:param float beam_energy:
"""
path = self.params_path + '/beam_energy'
self._set_scalar_data(path, float(beam_energy))
def set_direct_beam(self, direct_beam):
"""Stores the direct beam calibration position.
:param direct_beam: a 2 elements array.
"""
path = self.params_path + '/direct_beam'
if direct_beam is None or len(direct_beam) != 2:
raise ValueError('direct_beam must be a 2 elements array : '
'{0}.'.format(direct_beam))
self._set_array_data(path, _np.array(direct_beam))
def set_channels_per_degree(self, channels_per_degree):
"""Stores channels per degree calibration.
:param channels_per_degree: a 2 elements array.
"""
path = self.params_path + '/channels_per_degree'
if channels_per_degree is None or len(channels_per_degree) != 2:
raise ValueError('channels_per_degree must be a 2 elements array : '
'{0}.'.format(channels_per_degree))
self._set_array_data(path, _np.array(channels_per_degree))
if __name__ == '__main__':
pass
......@@ -856,7 +856,10 @@ class QSpaceConverter(object):
qspace_chunks=chunks,
qspace_sum_chunks=qspace_sum_chunks,
overwrite=self.__overwrite,
shiftH5=shiftH5)
shiftH5=shiftH5,
beam_energy=beam_energy,
direct_beam=center_chan,
channels_per_degree=chan_per_deg)
manager = mp.Manager()
self.__term_evt = term_evt = manager.Event()
......@@ -1128,7 +1131,10 @@ def _create_result_file(h5_fn,
qspace_chunks=None,
qspace_sum_chunks=None,
overwrite=False,
shiftH5=None):
shiftH5=None,
beam_energy=None,
direct_beam=None,
channels_per_degree=None):
"""
Initializes the output file.
:param h5_fn: name of the file to initialize
......@@ -1149,7 +1155,9 @@ def _create_result_file(h5_fn,
:param qspace_sum_chunks:
:param overwrite: True to force overwriting the file if it already exists.
:param shiftH5: file containing the shifts applied to the selected entries
:return:
:param beam_energy: Beam energy in eV
:param direct_beam: Direct beam calibration position
:param channels_per_degree: Channels per degree calibration
"""
if not overwrite:
......@@ -1176,6 +1184,9 @@ def _create_result_file(h5_fn,
qspace_h5.set_image_binning(image_binning)
qspace_h5.set_medfilt_dims(medfilt_dims)
qspace_h5.set_sample_roi(sample_roi)
qspace_h5.set_beam_energy(beam_energy)
qspace_h5.set_direct_beam(direct_beam)
qspace_h5.set_channels_per_degree(channels_per_degree)
if shiftH5:
sample_shifts = []
......
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