ibex_bluesky_core.devices.simpledae.reducers

DAE data reduction strategies.

Members

GoodFramesNormalizer

Sum a set of user-specified spectra, then normalize by total good frames.

MonitorNormalizer

Normalize a set of user-specified detector spectra by user-specified monitor spectra.

PeriodGoodFramesNormalizer

Sum a set of user-specified spectra, then normalize by period good frames.

PeriodSpecIntegralsReducer

A DAE Reducer which simultaneously exposes integrals of many spectra in the current period.

ScalarNormalizer

Sum a set of user-specified spectra, then normalize by a scalar signal.

sum_spectra

Read and sum a number of spectra from the DAE.

tof_bounded_spectra

Sum a set of neutron spectra between the specified time of flight bounds.

wavelength_bounded_spectra

Sum a set of neutron spectra between the specified wavelength bounds.

class ibex_bluesky_core.devices.simpledae.reducers.GoodFramesNormalizer(prefix: str, detector_spectra: ~collections.abc.Sequence[int], sum_detector: ~collections.abc.Callable[[~collections.abc.Collection[~ibex_bluesky_core.devices.dae.dae_spectra.DaeSpectra]], ~collections.abc.Awaitable[~scipp._scipp.core.Variable | ~scipp._scipp.core.DataArray]] = <function sum_spectra>)[source]

Bases: ScalarNormalizer

Sum a set of user-specified spectra, then normalize by total good frames.

Init.

Parameters:
  • prefix – the PV prefix of the instrument to get spectra from (e.g. IN:DEMO:)

  • detector_spectra – a sequence of spectra numbers (detectors) to sum.

  • sum_detector – takes spectra objects, reads from them, and returns a scipp scalar describing the detector intensity. Defaults to summing over the entire spectrum.

denominator(dae: SimpleDae) SignalR[int][source]

Get normalization denominator (total good frames).

class ibex_bluesky_core.devices.simpledae.reducers.MonitorNormalizer(prefix: str, detector_spectra: ~collections.abc.Sequence[int], monitor_spectra: ~collections.abc.Sequence[int], sum_detector: ~collections.abc.Callable[[~collections.abc.Collection[~ibex_bluesky_core.devices.dae.dae_spectra.DaeSpectra]], ~collections.abc.Awaitable[~scipp._scipp.core.Variable | ~scipp._scipp.core.DataArray]] = <function sum_spectra>, sum_monitor: ~collections.abc.Callable[[~collections.abc.Collection[~ibex_bluesky_core.devices.dae.dae_spectra.DaeSpectra]], ~collections.abc.Awaitable[~scipp._scipp.core.Variable | ~scipp._scipp.core.DataArray]] = <function sum_spectra>)[source]

Bases: Reducer, StandardReadable

Normalize a set of user-specified detector spectra by user-specified monitor spectra.

Init.

Parameters:
  • prefix – the PV prefix of the instrument to get spectra from (e.g. IN:DEMO:)

  • detector_spectra – a sequence of spectra numbers (detectors) to sum.

  • monitor_spectra – a sequence of spectra number (monitors) to sum and normalize by.

  • sum_detector – takes spectra objects, reads from them, and returns a scipp scalar describing the detector intensity. Defaults to summing over the entire spectrum.

  • sum_monitor – takes spectra objects, reads from them, and returns a scipp scalar describing the monitor intensity. Defaults to summing over the entire spectrum.

Scipp scalars are described in further detail here: https://scipp.github.io/generated/functions/scipp.scalar.html

additional_readable_signals(dae: SimpleDae) list[Device][source]

Publish interesting signals derived or used by this reducer.

async reduce_data(dae: SimpleDae) None[source]

Apply the normalization.

class ibex_bluesky_core.devices.simpledae.reducers.PeriodGoodFramesNormalizer(prefix: str, detector_spectra: ~collections.abc.Sequence[int], sum_detector: ~collections.abc.Callable[[~collections.abc.Collection[~ibex_bluesky_core.devices.dae.dae_spectra.DaeSpectra]], ~collections.abc.Awaitable[~scipp._scipp.core.Variable | ~scipp._scipp.core.DataArray]] = <function sum_spectra>)[source]

Bases: ScalarNormalizer

Sum a set of user-specified spectra, then normalize by period good frames.

Init.

Parameters:
  • prefix – the PV prefix of the instrument to get spectra from (e.g. IN:DEMO:)

  • detector_spectra – a sequence of spectra numbers (detectors) to sum.

  • sum_detector – takes spectra objects, reads from them, and returns a scipp scalar describing the detector intensity. Defaults to summing over the entire spectrum.

denominator(dae: SimpleDae) SignalR[int][source]

Get normalization denominator (period good frames).

class ibex_bluesky_core.devices.simpledae.reducers.PeriodSpecIntegralsReducer(*, monitors: ndarray[tuple[int, ...], dtype[int64]], detectors: ndarray[tuple[int, ...], dtype[int64]])[source]

Bases: Reducer, StandardReadable

A DAE Reducer which simultaneously exposes integrals of many spectra in the current period.

Two types of integrals are available: detectors and monitors. Other than defaults, their behaviour is identical. No normalization is performed in this reducer - exactly how the detector and monitor integrals are used is defined downstream.

By itself, the data from this reducer is not suitable for use in a scan - but it provides raw data which may be useful for further processing as part of callbacks (e.g. LiveDispatchers).

Init.

Parameters:
  • monitors – an array representing the mapping of monitors to acquire integrals from. For example, passing np.array([1]) selects spectrum 1.

  • detectors – an array representing the mapping of detectors to acquire integrals from. For example, passing np.array([5, 6, 7, 8]) would select detector spectra 5-8 inclusive, and so the output of this reducer would be an array of dimension 4.

additional_readable_signals(dae: SimpleDae) list[Device][source]

Publish interesting signals derived or used by this reducer.

property detectors: ndarray[tuple[int, ...], dtype[int64]]

Get the detectors used by this reducer.

property monitors: ndarray[tuple[int, ...], dtype[int64]]

Get the monitors used by this reducer.

async reduce_data(dae: SimpleDae) None[source]

Expose detector & monitor integrals.

After this method returns, it is valid to read from det_integrals and mon_integrals.

Note

Could use SPECINTEGRALS PV here, which seems more efficient initially, but it gets bounded by some areadetector settings under-the-hood which may be a bit surprising on some instruments.

We can’t just change these settings in this reducer, as they only apply to new events that come in.

class ibex_bluesky_core.devices.simpledae.reducers.ScalarNormalizer(prefix: str, detector_spectra: ~collections.abc.Sequence[int], sum_detector: ~collections.abc.Callable[[~collections.abc.Collection[~ibex_bluesky_core.devices.dae.dae_spectra.DaeSpectra]], ~collections.abc.Awaitable[~scipp._scipp.core.Variable | ~scipp._scipp.core.DataArray]] = <function sum_spectra>)[source]

Bases: Reducer, StandardReadable, ABC

Sum a set of user-specified spectra, then normalize by a scalar signal.

Init.

Parameters:
  • prefix – the PV prefix of the instrument to get spectra from (e.g. IN:DEMO:)

  • detector_spectra – a sequence of spectra numbers (detectors) to sum.

  • sum_detector – takes spectra objects, reads from them, and returns a scipp scalar describing the detector intensity. Defaults to summing over the entire spectrum.

additional_readable_signals(dae: SimpleDae) list[Device][source]

Publish interesting signals derived or used by this reducer.

abstractmethod denominator(dae: SimpleDae) SignalR[int] | SignalR[float][source]

Get the normalization denominator, which is assumed to be a scalar signal.

async reduce_data(dae: SimpleDae) None[source]

Apply the normalization.

async ibex_bluesky_core.devices.simpledae.reducers.sum_spectra(spectra: Collection[DaeSpectra]) Variable | DataArray[source]

Read and sum a number of spectra from the DAE.

Returns a scipp scalar, which has .value and .variance properties for accessing the sum and variance respectively of the summed counts.

More info on scipp scalars can be found here: https://scipp.github.io/generated/functions/scipp.scalar.html

ibex_bluesky_core.devices.simpledae.reducers.tof_bounded_spectra(bounds: Variable) Callable[[Collection[DaeSpectra]], Awaitable[Variable | DataArray]][source]

Sum a set of neutron spectra between the specified time of flight bounds.

Parameters:

bounds – A scipp array of size 2, no variances, unit of us, where the second element must be larger than the first.

Returns a scipp scalar, which has .value and .variance properties for accessing the sum and variance respectively of the summed counts.

More info on scipp arrays and scalars can be found here: https://scipp.github.io/generated/functions/scipp.scalar.html

ibex_bluesky_core.devices.simpledae.reducers.wavelength_bounded_spectra(bounds: Variable, total_flight_path_length: Variable) Callable[[Collection[DaeSpectra]], Awaitable[Variable | DataArray]][source]

Sum a set of neutron spectra between the specified wavelength bounds.

Parameters:
  • bounds – A scipp array of size 2 of wavelength bounds, in units of angstrom, where the second element must be larger than the first.

  • total_flight_path_length – A scipp scalar of Ltotal (total flight path length), the path length from neutron source to detector or monitor, in units of meters.

Time of flight is converted to wavelength using scipp neutron’s library function

wavelength_from_tof, more info on which can be found here: https://scipp.github.io/scippneutron/generated/modules/scippneutron.conversion.tof.wavelength_from_tof.html

Returns a scipp scalar, which has .value and .variance properties for accessing the sum and variance respectively of the summed counts.