diff --git a/docs/changelog.md b/docs/changelog.md index a50493d5..ef0f0695 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -18,6 +18,7 @@ Added: +- The [Scantool.step_sizes][extra.components.Scantool.step_sizes] property (!58). - The [Scan][extra.components.Scan] component to automatically detect steps within a motor scan (!4). - [DldPulses][extra.components.DldPulses] to access pulse information saved during delay line detector event reconstruction (!42). diff --git a/src/extra/components/scantool.py b/src/extra/components/scantool.py index 59867d22..589d8a5a 100644 --- a/src/extra/components/scantool.py +++ b/src/extra/components/scantool.py @@ -88,6 +88,10 @@ def get_first_value(keys): self._stop_positions = dict(zip(self.motors, values["scanEnv.stopPoints.value"][:n_motors])) + # Calculate the step size + self._step_sizes = { motor: abs(self.start_positions[motor] - self.stop_positions[motor]) / self.steps[motor] + for motor in self.motors } + @property def source_name(self) -> str: """The name of the scantool device.""" @@ -140,6 +144,15 @@ def steps(self) -> dict: scanned over.""" return self._steps + @property + def step_sizes(self) -> dict: + """A dictionary mapping motor aliases to their step size. + + Unlike most other properties, this is calculated from the step + information rather than being read from a property. + """ + return self._step_sizes + @property def start_positions(self) -> dict: """A dictionary mapping motor aliases to their start positions."""