calamari.scales.scan_smoothing#
- calamari.scales.scan_smoothing(measurements, *, windows, track_tol_k=None, track_tol_t=None, link=None, **detect_kwargs)#
Run detection at every declared smoothing window and track each feature across them.
Why this exists: the smoothing window is an analysis choice, and a weak feature’s significance – a kink’s especially, and sometimes its sign – can depend strongly on it. Trying windows until one looks good and quoting that one is a forking path. This runs a set of windows the caller declares before looking, keeps every result, and describes how each feature behaves across the whole set. It picks nothing.
Persistence is robustness to an analysis choice, not evidence: every window sees the same data, so the per-window significances are strongly correlated, and they must never be combined across windows (no Stouffer sum, no mean used as a score). That is why
tracksholds the range of the significance and no combined statistic, and why there is nobest_window: report the whole declared set. The window dependence of Fisher’s offset (docs/DETECTION.md) is one thing a scan makes visible. See the module docstring for what a persistent or a transient feature does and does not tell you.How it works, deterministically (TR-1):
For each window
w, ascending, rundetect_transitions_all(measurements, smooth_window=w, **detect_kwargs), then.link(**link)iflinkwas given. Every result is kept.Within each
(sweep_id, signal, method, swept_axis), walk the windows exactly aslink()walks a family of sweeps, with the window’s position in the sorted set as the family coordinate and the swept location as the position: seeds in descending significance (ties to the smaller window, then the lower location), each taking the nearest unclaimed candidate at the adjacent window within the tolerance and stopping at the first window that offers none. Every declared window is in the ordering, so a window where the feature is absent ends the track instead of being stepped over.signis not a matching key (seeTRACK_BY). Every candidate is in exactly one track; a candidate that matches nothing is a track of one.Summarise each track over its members.
- Parameters:
measurements (
Measurement|Iterable) – Whatdetect_transitions_all()accepts: Measurements and/orsplit_isotherms(T_K, Measurement)pairs. A single Measurement is taken as a batch of one. The input is read once, so a generator is fine;sweep_idis the input position, the same in every window.windows (
Sequence[float]) – The smoothing windows to run, in the swept axis’s units (K for a T-scan, T for an H-scan). Required, at leastMIN_WINDOWS, each positive, finite and distinct. There is no default set: which range of windows is reasonable depends on the sweep’s sampling and the feature’s width, which only you know. Recorded as given and sorted.track_tol_k (
float|None) – How far a T-swept feature may move between adjacent windows and still be the same feature, in K. Required when any T-swept candidate is found; there is no default, as forlink().track_tol_t (
float|None) – The same for H-swept features, in Tesla.link (
dict|None) – Keyword arguments forTransitionResult.link, applied to every window’s result. The chain columns are then carried per member, and each track reports the range of its chain statistic.**detect_kwargs – Forwarded to
detect_transitions_all()unchanged at every window, and recorded.criterion='kink'is the natural companion when the question is a slope change. Arobust=given here filters every window’s result before the tracking, so the tracks then describe the filtered candidates.
- Return type:
- Returns:
SmoothingScanResult–resultsper window, themembersandtrackstables, and the recipe inparams.- Raises:
SmoothingSensitivityError – If
smooth_windowis passed (the scan sets it); ifwindowshas fewer than three entries, or one that is non-numeric, non-positive, non-finite or repeated; if a given tolerance is not a positive, finite number; or if candidates on a swept axis were found and that axis’s tolerance was not given. Each message names the fix.- Warns:
UserWarning – Once per sweep on which two or more declared windows resolved to the same point count. A window is clamped to at least 5 points and at most the sweep, and rounded to an odd count, so on a short or coarse sweep two windows can be one analysis. They are counted once, and the groups are recorded in
params['resolved_together'].
Examples
>>> from calamari.scales import scan_smoothing >>> scan = scan_smoothing(sweeps, windows=(1.0, 1.5, 2.0, 3.0), ... track_tol_k=0.5, criterion="kink", ... methods=("peak", "derivative", "kink")) >>> scan.tracks.query("method == 'kink'")