ibex_bluesky_core.utils
Utilities for plans which are not plan stubs.
Members
Abstract class for type checking that an object is readable, named and movable. |
|
Calculate polarisation value and propagate uncertainties. |
|
Compute the centre of mass of the area under a curve defined by a series of (x, y) points. |
|
Given a centre and range, return a contiguous range of pixels around the centre, inclusive. |
|
Return the PV prefix for the current instrument. |
|
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.
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.center_of_mass_of_area_under_curve(x: ndarray[tuple[Any, ...], dtype[float64]], y: ndarray[tuple[Any, ...], dtype[float64]]) tuple[float, float] [source]
Compute the centre of mass of the area under a curve defined by a series of (x, y) points.
The “area under the curve” is a shape bounded by: - min(y), along the bottom edge - min(x), on the left-hand edge - max(x), on the right-hand edge - straight lines joining (x, y) data points to their nearest neighbours along the x-axis, along the top edge
This is implemented by geometric decomposition of the shape into a series of trapezoids, which are further decomposed into rectangular and triangular regions.
Returns a tuple of the centre of mass and the total area under the curve.
- 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:
Returns a list of pixel numbers.