linear_model#

class ConfigModel(*, curve=None, powerconverter, calibration_factor=1.0, calibration_offset=0.0, crosstalk=1.0, unit)[source]#

Bases: BaseModel

Linear magnet model.

Parameters:
  • curve (Curve or None, optional) – Curve object used for interpolation. By default, identity curve is used.

  • powerconverter (DeviceAccess or None, optional) – Power converter device to apply currrent

  • calibration_factor (float, optional) – Correction factor applied to the curve. Default: 1.0

  • calibration_offset (float, optional) – Correction offset applied to the curve. Default: 0.0

  • crosstalk (float, optional) – Crosstalk factor. Default: 1.0

  • unit (str) – Unit of the strength (i.e. 1/m or m-1)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

calibration_factor: float#
calibration_offset: float#
crosstalk: float#
curve: Curve | None#
powerconverter: DeviceAccess | None#
unit: str#
class LinearMagnetModel(cfg)[source]#

Bases: MagnetModel

Class that handle manget current/strength conversion using linear interpolation for a single function magnet

compute_hardware_values(strengths)[source]#

Compute hardware value(s) from magnet strength(s)

Parameters:

strengths (npt.NDArray[np.float64]) – Array of strengths. For a single multipole, strengths is an array of 1 item.

Returns:

npt.NDArray[np.float64] – Array of hardware values (i.e. currents or voltages).

compute_strengths(currents)[source]#

Compute magnet strength(s) from hardware value(s)

Parameters:

hardware_values (npt.NDArray[np.float64]) – Array of hardware values (i.e. currents or voltages)

Returns:

npt.NDArray[np.float64] – Array of strengths. For a single multipole, returns an array of 1 item

get_devices()[source]#

Get device handles

Returns:

list[DeviceAccess] – Array of DeviceAcess

get_hardware_units()[source]#

Get hardware units

Returns:

list[str] – Array of hardware units. For a single multipole, returns a list of 1 item

get_strength_units()[source]#

Get strength units

Returns:

list[str] – Array of strength units. For a single multipole, returns a list of 1 item

set_magnet_rigidity(brho)[source]#

Set magnet rigidity

Parameters:

brho (np.double) – Magnet rigidity used to calculate power supply setpoints