agepy.mag.hysteresis.drift_correction

drift_correction(*hysteresis, slope)

Corrects thermal drift.

Thermal correction is applied by subtracting a linear function from the time ordered hysteresis loop. Hysteresis data can be supplied either as one tuple containing the magntic field and magnetization repectively or as multiple tuples containing the two hysteresis branches. This function is purely for subtracting a linear function in time domain and does not determine the optical slope for the drift correction itself.

Parameters:
*hysteresis: ArrayLike

One or two 2-D arrays of shape (2, n) containing the magnetic field and magnetization of length n in the first axis.

slope: float

Slope of the linear function M(H) = slope * H to subtract.

Returns:
NDArray

The corrected magnetization values. If hysteresis is supplied as whole sequence , then a 1-D array with the same length as the magnetization is returned. If hysteresis is two branches, a 2-D array is returned containing the two magnetization branches in the first axis.

Return type:

ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]

Examples

Viable example inputs.

>>> drift_correction((H, M), slope=10)
array([<M-values>])
>>> drift_correction((H1, M1), (H2, M2), slope=10)
array([[<M1-values>], [<M2-values>]])
>>> hyst = array([H, M])
>>> drift_correction(hyst, slope=10)
array([<M-values>])
>>> hyst = array([[H1, M1], [H2, M2]])
>>> drift_correction(*hyst, slope=10)
array([[<M1-values>], [<M2-values>]])