Problem
Following the fit of Fit piecewise-linear fn to I-B v3 the lack of points at beginning of flat top remains evident, see figure below (and it’s zoomed in version around 4800 A.


The waviness of the plot is evident. These are artefacts from linearly interpolating between two points that are too far spaced in the current axis. We aim to remedy this by increasing the number of points on the xaxis.
Outcome
Development results have concluded in the creation of the ~/cernbox/hysteresis/scripts/add_points_to_calibration_fn.py script, which allows the user to automatically add linearly spaced point between start and end.
The outcome is replacing the points between 162 A and 5784.4 A with 563 linear space points, increasing the resolution by at least 10 times. The result can be seen in the plot below to compare against the one above..
The results can be found in the ~/cernbox/hysteresis/calibration_fn/SPS_MB_I2B_CALIBRATION_FN_v4.csv.

Results
Default LSA calibration function
tune-calibration-fn -c ~/cernbox/hysteresis/calibration_fn/SPS_MB_B2I_CALIBRATION_FN_LSA.csv
The residual ranges from 0 to 200 G, with many ripples that are not entirely physical due to the miscalibration of the function.
Improved calibration function (v2)
tune-calibration-fn -c ~/cernbox/hysteresis/calibration_fn/SPS_MB_I2B_CALIBRATION_FN_v2.csv
Here we clearly see an improvement with +/- 35G (70 G range), still with some large deviations from 0 in both positive and negative direction. Especially at LHCPILOT flat top the offset is too much in the negative in magnitude. This indicates a potential shift in the calibration function.
Improved calibration function (v3)
Proposed in this experiment by first making an automatic fit, and then tuning the points manually in the interactive plot.

It is shown that the major effects are during ramps, which correspond to the lagging effects caused by eddy currents, whereas flat bottom are not as pronounced.
As remedy for the drowning out caused b eddy currents we plot also B/I vs I as seen below, where flat bottom has significantly larger effects than the rest of the cycle.

Improved calibration function v4

The fitted calibration is the same as v3, however with more points for higher linear interpolation accuracy.