calamari.sweeps.increasing_field_branch#
- calamari.sweeps.increasing_field_branch(field, moment)#
Fold an M(H) sweep to its initial increasing-|field| branch.
Many M(H) files ramp
0 -> +H_max -> 0(and sometimes on into negative field): a hysteresis loop or a bidirectional sweep. Running a step/kink detector on the whole trace would (a) report a metamagnetic feature twice, once from the up-leg and once from the down-leg, and (b) let the return leg contribute spurious high-field candidates. This helper returns the leading monotonically-increasing run of|field|from the start of the sweep, paired with the corresponding moment values, so a feature is counted once on a clean monotone field axis.The function is unit-agnostic: it operates purely on
|field|and monotonicity, so the returned field array is in whatever unitfieldwas supplied in (Oe or Tesla). The parameter is therefore named plainlyfieldrather than carrying a unit suffix – attaching one would be an active lie whenever the other unit is passed. Callers that need a specific output unit should pass that unit in.- Parameters:
- Return type:
- Returns:
(numpy.ndarray,numpy.ndarray)–(field_increasing, moment)–|field|over the leading increasing run and the matching moments. If the sweep starts on a decreasing leg (leading run shorter than three points, e.g. a+H_max -> 0 -> -H_maxsweep), falls back to the whole sweep sorted by|field|so a usable monotone axis is still returned rather than nothing.- Raises:
SweepInputError – If
fieldandmomenthave different lengths.