ibex_bluesky_core.utils

Utilities for plans which are not plan stubs.

Members

NamedReadableAndMovable

Abstract class for type checking that an object is readable, named and movable.

calculate_polarisation

Calculate polarisation value and propagate uncertainties.

centred_pixel

Given a centre and range, return a contiguous range of pixels around the centre, inclusive.

get_pv_prefix

Return the PV prefix for the current instrument.

is_matplotlib_backend_qt

Return True if matplotlib is using a qt backend.

class ibex_bluesky_core.utils.NamedReadableAndMovable(*args, **kwargs)[source]

Bases: Readable[Any], NamedMovable[Any], Protocol

Abstract class for type checking that an object is readable, named and movable.

ibex_bluesky_core.utils.calculate_polarisation(a: Variable | DataArray, b: Variable | DataArray) Variable | DataArray[source]

Calculate polarisation value and propagate uncertainties.

This function computes the polarisation given by the formula (a-b)/(a+b) and propagates the uncertainties associated with a and b.

Parameters:
Returns:

polarisation, (a - b) / (a + b), as a scipp Variable or DataArray

On SANS instruments e.g. LARMOR, A and B correspond to intensity in different DAE periods (before/after switching a flipper) and the output is interpreted as a neutron polarisation ratio.

On reflectometry instruments e.g. POLREF, the situation is the same as on LARMOR.

On muon instruments, A and B correspond to measuring from forward/backward detector banks, and the output is interpreted as a muon asymmetry.

ibex_bluesky_core.utils.centred_pixel(centre: int, pixel_range: int) list[int][source]

Given a centre and range, return a contiguous range of pixels around the centre, inclusive.

ie. a centre of 50 with a range of 3 will give [47, 48, 49, 50, 51, 52, 53]

Parameters:
  • centre (int) – The centre pixel number.

  • pixel_range (int) – The range of pixels either side to surround the centre.

Returns a list of pixel numbers.

ibex_bluesky_core.utils.get_pv_prefix() str[source]

Return the PV prefix for the current instrument.

ibex_bluesky_core.utils.is_matplotlib_backend_qt() bool[source]

Return True if matplotlib is using a qt backend.