calamari.plot.plot_detection_curve#
- calamari.plot.plot_detection_curve(result, *, sweep_id=0, signal=None, representation='y_smooth', ax=None, candidates=True, **style)#
Draw one smoothed curve a detection searched, with that sweep’s candidates on it.
Why this exists: every candidate was found in a smoothed representation – a cusp in the smoothed signal, a derivative extremum in dy/dx, a kink in d²y/dx² – and auditing one means looking at that curve, not at the raw points. The result keeps those curves (
curve()); this draws one of them against the swept axis, with a dashed rule at each candidate of that sweep and signal and the method’sMETHODSmarker where the rule meets the curve. On the'd2ydx2'curve a kink’s marker should sit on a curvature extremum; if it does not, the figure shows it.The raw data are not in the result, so this does not draw them. Draw the raw sweep first and this curve on the same axes:
r = detect_transitions(m, methods=("peak", "derivative", "kink")) ax = plot_chi_vs_t(m, linestyle="none", marker=".") plot_detection_curve(r, ax=ax) # 'y_smooth', the default
Units. The curves are in the searched signal’s file units, never converted: chi’ and chi’’ in emu/Oe, a moment in emu; against temperature in K, or against mu0 H in Tesla for a field sweep. That is what
plot_chi_vs_t()andplot_mt()draw by default, so that composition shares one scale. Two others do not:a field sweep drawn by
plot_chi_vs_h()orplot_mh()with their defaultfield_unit='oe'puts the raw points 10^4 times further along x than the curve. Draw them withfield_unit='tesla';chi drawn with
units='molar','mass'or'molar_per_ion'is the curve times the sample’s conversion factor, so the two would sit orders of magnitude apart under one label.
Both are refused, naming the fix, whenever the axes carry the label calamari wrote for the other unit. A label you wrote yourself is yours, and is not checked. Two more mismatches are not units, and are not refused: a multi-frequency file is searched at one frequency (
params['frequency_hz']) whileplot_chi_vs_t()draws every frequency, and a field sweep detected withbranch='increasing'is a curve against abs(mu0 H) on that branch only. Say so in the caption when either applies.The curve is on the uniform grid detection resampled the searched range to (after any
t_window_k/h_window_oeand outlier drop), so it can be shorter than the raw sweep.- Parameters:
result (
TransitionResult) – Fromdetect_transitions()ordetect_transitions_all(), any filtered or linked view of one (robust(),select(),link()), or one window of a scan (scan.at(window)). The candidates drawn are the view’s own, so arobust()view draws only what survived. An array-levelfind_transitions()result is refused: it records no swept axis or signal.sweep_id (
int) – The sweep, as in thesweep_idcolumn;0(the default) for a single-sweep result.signal (
str|None) – The searched signal;Nonetakes the sweep’s only one. Resolved and refused exactly as bycurve().representation (
str) – The smoothed signal (default), its first or second derivative along the swept axis, or Fisher’s d(yT)/dT, which exists only when'fisher'was among the detection’s methods.ax (
Axes|None) – Draw into these axes – normally those the raw sweep is on; omitted, a new single-axes figure is created.candidates (
bool) – Mark the sweep’s candidates (defaultTrue). Each gets a rule and a marker; the first marker of each (method, sign) pair carries a legend label naming both ('curvature extremum (down)'), soax.legend()explains them. Calling the legend is left to you.**style (
Any) – Forwarded toax.plotfor the curve (color=,label=, …). The candidate marks have a fixed style and ignore it.
- Return type:
- Returns:
matplotlib.axes.Axes– The axes drawn into. The x-label names the swept axis and the y-label the representation, in mathtext with its unit ($\mathrm{d}\chi'/\mathrm{d}T$ (emu/(Oe K))). A batch sweep with no candidates at all records its swept axis nowhere, so its x-label is left as it was.- Raises:
PlotInputError – For an unknown
representation(naming the valid ones);'dyT_dT'when Fisher did not run (namingmethods=(..., 'fisher')); an array-level result; and axes whose calamari label names another unit (see above). Raised before drawing.calamari.exceptions.CurveInputError – An unknown
sweep_idorsignal(fromcurve(), naming the choices). Raised before drawing; also aValueError.