Hall sensors are placed in different longitudinal positions in the MBA dipole aperture, and then weighted together to estimate the integral field.
The hall sensors also need to be calibrated to remove any nonlinearities that are inherent to the hall sensors
"""
Calibration functions for hall sensors in the measured MBA magnet in 867.
"""
from __future__ import annotations
import numpy as np
import typing
Weights_220 = 2.09186992 / 6.6437142
weights_315 = 0.46247514 / 6.6437142
weights_70 = 2.2717978 / 6.6437142
weights_140 = 1.81757134 / 6.6437142
T_arr = typing.TypeVar("T_arr", np.floating, np.ndarray)
def calibrate(signal: T_arr) -> T_arr:
return 6e-08 * signal**3 + 1e-05 * signal**2 - 0.0011 * signal + 5.1073
def combine(hall315: T_arr, hall220: T_arr, hall140: T_arr, hall70: T_arr) -> T_arr:
hall315 = calibrate(hall315)
hall220 = calibrate(hall220)
hall140 = calibrate(hall140)
hall70 = calibrate(hall70)
return (
hall315 * weights_315
+ hall220 * Weights_220
+ hall140 * weights_140
+ hall70 * weights_70
) / 0.9029556650246306