pyaml.magnet.linear_model#
Linear conversion model for single-function magnets.
This model maps one magnet strength to one hardware value using linear calibration parameters and an optional excitation curve.
Classes
|
Linear magnet model for a single magnet function. |
- class pyaml.magnet.linear_model.LinearMagnetModel(unit, hardware_unit, curve=None, powerconverter=None, calibration_factor=1.0, calibration_offset=0.0, crosstalk=1.0)#
Bases:
MagnetModel,DynamicValidationLinear magnet model for a single magnet function.
This model converts between magnet strengths and hardware currents using a single excitation curve or, if no curve is provided, a linear scaling with an optional offset. It is intended for single-function magnets such as correctors or other elements that use one current channel.
- Parameters:
unit (str) – Unit of the magnet strength, for example
"1/m"or"m-1".hardware_unit (str) – Unit of the hardware value, for example
"A"or"V".curve (Curve | None, optional) – Excitation curve used for interpolation. If omitted, a linear conversion is used instead.
powerconverter (str | None, optional) – Name of the power converter device used to apply current.
calibration_factor (float, optional) – Multiplicative correction applied to the curve or linear scaling. Default is
1.0.calibration_offset (float, optional) – Additive correction applied to the curve or linear scaling. Default is
0.0.crosstalk (float, optional) – Crosstalk factor applied together with the calibration factor. Default is
1.0.
Methods
Convert magnet strengths to hardware values.
Convert hardware values to magnet strengths.
Return the units of magnet strengths.
Return the units of hardware values.
Return the associated device names.
Set the magnetic rigidity used for conversion.
Notes
If a curve is provided, the model interpolates between strength and current values using the curve and its inverse. If no curve is provided, the model uses a simple linear relation with the stored scaling factor and offset.
Configuration
type: pyaml.magnet.linear_model unit: 1/m hardware_unit: A calibration_factor: 1.0 calibration_offset: 0.0 curve: type: pyaml.magnet.csvcurve file: path/to/excitation_curve.csv powerconverter: DEVICE/POWER_CONVERTER_CURRENT
- compute_hardware_values(strengths)#
Convert magnet strengths to hardware values.
- Parameters:
strengths (np.array) – Magnet strengths to convert, in the unit reported by
get_strength_unit().- Returns:
np.array – Hardware values corresponding to
strengths.- Return type:
array
- compute_strengths(currents)#
Convert hardware values to magnet strengths.
- Parameters:
currents (np.array) – Hardware values to convert, in the unit reported by
get_hardware_unit().- Returns:
np.array – Strengths corresponding to
currents.- Return type:
array
- get_device_names()#
Return the associated device names.
- get_hardware_units()#
Return the units of hardware values.
- get_strength_units()#
Return the units of magnet strengths.
- set_magnet_rigidity(brho)#
Set the magnetic rigidity used for conversion.
- Parameters:
brho (np.double) – Magnetic rigidity in tesla metres, used to scale strengths into hardware values.