Skip to content
Snippets Groups Projects
Commit fc570222 authored by Egor Sobolev's avatar Egor Sobolev
Browse files

Merge branch 'fix/agipd-num-cells' into 'master'

[AGIPD][CORRECT] Add reading of AGIPD number of cells from CONTROL data

See merge request !815
parents 476ebabb c88dca73
No related branches found
No related tags found
1 merge request!815[AGIPD][CORRECT] Add reading of AGIPD number of cells from CONTROL data
...@@ -53,12 +53,19 @@ class AgipdCtrl: ...@@ -53,12 +53,19 @@ class AgipdCtrl:
self.ctrl_src = ctrl_src self.ctrl_src = ctrl_src
self.raise_error = raise_error self.raise_error = raise_error
def get_num_cells(self) -> Optional[int]: def _get_num_cells_ctrl(self) -> Optional[int]:
"""Read number of memory cells from fast data. """Get number of cells from CONTROL source."""
# Attempt to look for number of cells in slow data
ncell_src = (
self.ctrl_src, "bunchStructure.nPulses.value")
if (
ncell_src[0] in self.run_dc.all_sources and
ncell_src[1] in self.run_dc.keys_for_source(ncell_src[0])
):
return int(self.run_dc[ncell_src].as_single_value(reduce_by='max'))
:return mem_cells: Number of memory cells def _get_num_cells_instr(self) -> Optional[int]:
return None, if no data available. """Get number of cells from INSTRUMENT source."""
"""
cells = np.squeeze( cells = np.squeeze(
self.run_dc[ self.run_dc[
self.image_src, "image.cellId"].drop_empty_trains().ndarray() self.image_src, "image.cellId"].drop_empty_trains().ndarray()
...@@ -70,6 +77,20 @@ class AgipdCtrl: ...@@ -70,6 +77,20 @@ class AgipdCtrl:
dists = [abs(o - maxcell) for o in options] dists = [abs(o - maxcell) for o in options]
return options[np.argmin(dists)] return options[np.argmin(dists)]
def get_num_cells(self) -> Optional[int]:
"""Read number of memory cells from fast data.
:return mem_cells: Number of memory cells
return None, if no data available.
"""
ncell = self._get_num_cells_ctrl()
if ncell is not None:
return ncell
# The method implemented in this function doesn't suit for filtered
# data. If DAQ filters data and the last cell is removed, the
# function returns wrong value
return self._get_num_cells_instr()
def _get_acq_rate_ctrl(self) -> Optional[float]: def _get_acq_rate_ctrl(self) -> Optional[float]:
"""Get acquisition (repetition) rate from CONTROL source.""" """Get acquisition (repetition) rate from CONTROL source."""
# Attempt to look for acquisition rate in slow data # Attempt to look for acquisition rate in slow data
...@@ -83,9 +104,6 @@ class AgipdCtrl: ...@@ -83,9 +104,6 @@ class AgipdCtrl:
# about bucketing the rate for managing meta-data. # about bucketing the rate for managing meta-data.
return round(float(self.run_dc[rep_rate_src].as_single_value()), 1) return round(float(self.run_dc[rep_rate_src].as_single_value()), 1)
def _get_acq_rate_instr(self) -> Optional[float]:
"""Get acquisition (repetition rate) from INSTRUMENT source."""
def _get_acq_rate_instr(self) -> Optional[float]: def _get_acq_rate_instr(self) -> Optional[float]:
"""Get acquisition (repetition rate) from INSTRUMENT source.""" """Get acquisition (repetition rate) from INSTRUMENT source."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment