calamari.sweeps.split_isotherms#
- calamari.sweeps.split_isotherms(measurement, *, t_round=0.5, min_points=3)#
Split a stacked multi-isotherm M(H) file into per-temperature sweeps.
An ordinary single-temperature M(H) file yields one
(T_K, Measurement)pair. A multi-isotherm “phase-diagram” file – where each temperature setpoint is a full field ramp laid end to end – yields one pair per temperature plateau, each a realMeasurement(built viaMeasurement.restrictwith a row mask, so it carries the full row set of that isotherm and every accessor keeps working) rather than a bare array triple.Grouping is by temperature quantised to a
t_roundgrid: each row’s temperature is snapped to the nearest multiple oft_roundand consecutive rows sharing a snapped value form one isotherm (viasegment_by_constant()on the snapped column withtol=0). Snapping first – rather than segmenting the raw temperature with a jitter tolerance – reproduces the reference extractor’s behaviour exactly and is robust to a setpoint that drifts within its ownt_roundcell. As a guard, a file whose whole temperature span is within onet_roundstep is treated as a single isotherm outright (its mean temperature), so ordinary M(H) files with a little thermometry jitter are never spuriously split across a grid boundary.- Parameters:
measurement (
Measurement) – A DC field-sweep measurement (single isotherm or a stack). Must expose a temperature column; aValueErroris raised otherwise, since splitting by temperature is meaningless without one.t_round (
float) – Temperature grid (K) rows are snapped to before grouping. Default 0.5 K – comfortably finer than the ~1 K setpoint steps of a typical stacked run yet coarse enough to absorb per-isotherm jitter. Tune to the setpoint spacing of the file at hand.min_points (
int) – Isotherms with fewer than this many rows are dropped (a handful of points is too coarse to trust). Default 3; notecalamari.transitions.find_transitions()itself needs at least 5 finite points, so raise this for isotherms headed there.
- Return type:
- Returns:
listof(float,Measurement)–(T_K, sub_measurement)pairs in file order, whereT_Kis the mean of that isotherm’s raw (unsnapped) temperature column.- Raises:
SweepInputError – If
measurementhas no temperature column.
Examples
A stacked multi-isotherm file needs no dedicated simulate writer – the existing per-column writers already express it once the caller concatenates the isotherms, because a stacked file is literally its constituent sweeps laid end to end:
import numpy as np from calamari import simulate from calamari.io import load from calamari.sweeps import split_isotherms field_oe = np.linspace(0.0, 25_000.0, 40) # one 0 -> 2.5 T ramp temps_k = [2.0, 3.0, 4.0] temperature_K = np.concatenate([np.full_like(field_oe, t) for t in temps_k]) field_stacked = np.tile(field_oe, len(temps_k)) moment_emu = np.concatenate([ # a step that moves down in T simulate.synthetic_mh_curve(field_oe, m_sat_emu=1e-3, h_knee_oe=knee) for knee in (12_000.0, 9_000.0, 6_000.0) ]) path = simulate.write_mpms3_file( "stacked.dat", app="SQUID DC", temperature_K=temperature_K, field_oe=field_stacked, dc_moment_emu=moment_emu, ) isotherms = split_isotherms(load(path)) # -> 3 (T_K, Measurement) pairs