Skip to content

Data types#

Objects the APIs return or accept: fitting results, scan and graph objects, chart builders, and pulse operations. Protocol and library types that appear in their signatures are under Types.

ColumnQuality dataclass #

Invertibility verdict for one decay curve.

snr is peak intensity over the noise estimate; decay_fraction is the fraction of intensity lost across the b-range; residual_rms is the fit residual relative to the curve's own scale. reason is non-None exactly when invertible is False.

snr instance-attribute #

snr: float

decay_fraction instance-attribute #

decay_fraction: float

residual_rms class-attribute instance-attribute #

residual_rms: float = float('nan')

invertible class-attribute instance-attribute #

invertible: bool = True

reason class-attribute instance-attribute #

reason: str | None = None

DiffusionPeak dataclass #

One resolved component of a diffusion distribution.

d instance-attribute #

d: float

weight instance-attribute #

weight: float

width_decades instance-attribute #

width_decades: float

d_lo instance-attribute #

d_lo: float

d_hi instance-attribute #

d_hi: float

d_stderr class-attribute instance-attribute #

d_stderr: float = float('nan')

DosyMap dataclass #

A (diffusion, chemical shift) map ready for contour display.

intensities is [n_d, n_shift]; d_axis is the F1 axis in m^2/s (log-spaced, so plot it on a log scale); shifts is the direct axis in ppm. quality and results are indexed by the same column index as shifts.

d_axis instance-attribute #

d_axis: ndarray

shifts instance-attribute #

shifts: ndarray

intensities instance-attribute #

intensities: ndarray

results instance-attribute #

results: list[InversionResult | None]

quality instance-attribute #

quality: list[ColumnQuality | None]

peaks class-attribute instance-attribute #

peaks: list[tuple[float, DiffusionPeak]] = field(
    default_factory=list
)

temperature_k class-attribute instance-attribute #

temperature_k: float | None = None

viscosity_pa_s class-attribute instance-attribute #

viscosity_pa_s: float | None = None

temperature_source class-attribute instance-attribute #

temperature_source: str = 'unknown'

b_values class-attribute instance-attribute #

b_values: ndarray = field(
    default_factory=lambda: np.zeros(0)
)

measured class-attribute instance-attribute #

measured: ndarray = field(
    default_factory=lambda: np.zeros((0, 0))
)

radii #

radii() -> list[tuple[float, float, float]]

[(shift_ppm, D, r_h in m)] for every resolved peak, empty without T and viscosity.

InversionResult dataclass #

Recovered P(D) for a single decay curve, on d_grid.

d_grid instance-attribute #

d_grid: ndarray

distribution instance-attribute #

distribution: ndarray

method instance-attribute #

method: str

regularisation instance-attribute #

regularisation: float

quality instance-attribute #

quality: ColumnQuality

peaks class-attribute instance-attribute #

peaks: list[DiffusionPeak] = field(default_factory=list)

mean_d property #

mean_d: float

Weight-averaged D (m^2/s) in log space, or NaN for an empty distribution.

DeviceMetadata #

Device metadata information.

hardware_version class-attribute instance-attribute #

hardware_version: str | None = None

firmware_version class-attribute instance-attribute #

firmware_version: str | None = None

api_version class-attribute instance-attribute #

api_version: str | None = None

serial class-attribute instance-attribute #

serial: str | None = None

model_config class-attribute #

model_config: ConfigDict = ConfigDict(extra='allow')

Annotation dataclass #

A text annotation placed at a point on the plot, optionally with an arrow.

x class-attribute instance-attribute #

x: float | str | None = None

y class-attribute instance-attribute #

y: float | str | None = None

text class-attribute instance-attribute #

text: str | None = None

showarrow class-attribute instance-attribute #

showarrow: bool | None = None

textangle class-attribute instance-attribute #

textangle: float | None = None

xanchor class-attribute instance-attribute #

xanchor: (
    Literal["auto", "left", "center", "right"] | None
) = None

yanchor class-attribute instance-attribute #

yanchor: (
    Literal["auto", "top", "middle", "bottom"] | None
) = None

font class-attribute instance-attribute #

font: Font | dict[str, Any] | None = None

xref class-attribute instance-attribute #

xref: str | None = None

yref class-attribute instance-attribute #

yref: str | None = None

ax class-attribute instance-attribute #

ax: float | None = None

ay class-attribute instance-attribute #

ay: float | None = None

arrowcolor class-attribute instance-attribute #

arrowcolor: str | None = None

arrowwidth class-attribute instance-attribute #

arrowwidth: float | None = None

bgcolor class-attribute instance-attribute #

bgcolor: str | None = None

extras class-attribute instance-attribute #

extras: dict[str, Any] = field(default_factory=dict)

Axis dataclass #

Settings for one axis: title, range, scale, gridlines, and ticks.

title class-attribute instance-attribute #

title: str | dict[str, Any] | None = None

range class-attribute instance-attribute #

range: list[float] | tuple[float, float] | None = None

autorange class-attribute instance-attribute #

autorange: bool | Literal['reversed'] | None = None

type class-attribute instance-attribute #

type: (
    Literal["linear", "log", "date", "category"] | None
) = None

showgrid class-attribute instance-attribute #

showgrid: bool | None = None

gridcolor class-attribute instance-attribute #

gridcolor: str | None = None

gridwidth class-attribute instance-attribute #

gridwidth: float | None = None

zeroline class-attribute instance-attribute #

zeroline: bool | None = None

zerolinecolor class-attribute instance-attribute #

zerolinecolor: str | None = None

zerolinewidth class-attribute instance-attribute #

zerolinewidth: float | None = None

tickformat class-attribute instance-attribute #

tickformat: str | None = None

showticklabels class-attribute instance-attribute #

showticklabels: bool | None = None

domain class-attribute instance-attribute #

domain: list[float] | tuple[float, float] | None = None

anchor class-attribute instance-attribute #

anchor: str | None = None

matches class-attribute instance-attribute #

matches: str | None = None

nticks class-attribute instance-attribute #

nticks: int | None = None

extras class-attribute instance-attribute #

extras: dict[str, Any] = field(default_factory=dict)

Figure dataclass #

A complete plot: one or more data series plus a Layout. Builder methods return self for chaining.

data class-attribute instance-attribute #

data: list[_Trace | dict[str, Any]] = field(
    default_factory=list
)

layout class-attribute instance-attribute #

layout: Layout = field(default_factory=Layout)

add #

add(*traces: _Trace | dict[str, Any]) -> Figure

Add one or more data series (Scatter, Bar, …) to the figure. Returns self for chaining.

add_shape #

add_shape(shape: Shape | dict[str, Any]) -> Figure

Draw a shape (line, box, circle, …) over the figure. Returns self for chaining.

add_annotation #

add_annotation(
    annotation: Annotation | dict[str, Any],
) -> Figure

Add a text label (optionally with an arrow) at a point on the figure. Returns self for chaining.

update_layout #

update_layout(**kwargs: Any) -> Figure

Set figure-wide options (title, xaxis, yaxis, …) by keyword. Returns self for chaining.

to_spec #

to_spec() -> dict[str, Any]

Export the figure as a plain {"data": [...], "layout": {...}} dictionary.

Font dataclass #

Font styling for titles, axis labels, and annotation text.

size class-attribute instance-attribute #

size: float | None = None

color class-attribute instance-attribute #

color: str | float | None = None

family class-attribute instance-attribute #

family: str | None = None

extras class-attribute instance-attribute #

extras: dict[str, Any] = field(default_factory=dict)

Layout dataclass #

The figure's overall look: title, axes, legend, margins, shapes, annotations.

title class-attribute instance-attribute #

title: str | dict[str, Any] | None = None

xaxis class-attribute instance-attribute #

xaxis: Axis | dict[str, Any] | None = None

yaxis class-attribute instance-attribute #

yaxis: Axis | dict[str, Any] | None = None

xaxis2 class-attribute instance-attribute #

xaxis2: Axis | dict[str, Any] | None = None

xaxis3 class-attribute instance-attribute #

xaxis3: Axis | dict[str, Any] | None = None

xaxis4 class-attribute instance-attribute #

xaxis4: Axis | dict[str, Any] | None = None

yaxis2 class-attribute instance-attribute #

yaxis2: Axis | dict[str, Any] | None = None

yaxis3 class-attribute instance-attribute #

yaxis3: Axis | dict[str, Any] | None = None

yaxis4 class-attribute instance-attribute #

yaxis4: Axis | dict[str, Any] | None = None

showlegend class-attribute instance-attribute #

showlegend: bool | None = None

legend class-attribute instance-attribute #

legend: dict[str, Any] | None = None

margin class-attribute instance-attribute #

margin: Margin | dict[str, Any] | None = None

shapes class-attribute instance-attribute #

shapes: list[Shape | dict[str, Any]] = field(
    default_factory=list
)

annotations class-attribute instance-attribute #

annotations: list[Annotation | dict[str, Any]] = field(
    default_factory=list
)

paper_bgcolor class-attribute instance-attribute #

paper_bgcolor: str | None = None

plot_bgcolor class-attribute instance-attribute #

plot_bgcolor: str | None = None

height class-attribute instance-attribute #

height: float | None = None

width class-attribute instance-attribute #

width: float | None = None

font class-attribute instance-attribute #

font: Font | dict[str, Any] | None = None

hovermode class-attribute instance-attribute #

hovermode: (
    Literal[
        "x", "y", "closest", "x unified", "y unified", False
    ]
    | None
) = None

extras class-attribute instance-attribute #

extras: dict[str, Any] = field(default_factory=dict)

Line dataclass #

Line styling: color, width, and dash pattern.

color class-attribute instance-attribute #

color: str | None = None

width class-attribute instance-attribute #

width: float | None = None

dash class-attribute instance-attribute #

dash: (
    Literal[
        "solid",
        "dot",
        "dash",
        "longdash",
        "dashdot",
        "longdashdot",
    ]
    | None
) = None

extras class-attribute instance-attribute #

extras: dict[str, Any] = field(default_factory=dict)

Margin dataclass #

Plot margins in pixels: left, right, top, bottom.

l class-attribute instance-attribute #

l: float | None = None

r class-attribute instance-attribute #

r: float | None = None

t class-attribute instance-attribute #

t: float | None = None

b class-attribute instance-attribute #

b: float | None = None

extras class-attribute instance-attribute #

extras: dict[str, Any] = field(default_factory=dict)

Shape dataclass #

A shape drawn over the plot (line/rect/circle/path/triangle) to highlight a region or point.

type class-attribute instance-attribute #

type: (
    Literal["line", "rect", "circle", "path", "triangle"]
    | None
) = None

x0 class-attribute instance-attribute #

x0: float | str | None = None

x1 class-attribute instance-attribute #

x1: float | str | None = None

y0 class-attribute instance-attribute #

y0: float | str | None = None

y1 class-attribute instance-attribute #

y1: float | str | None = None

path class-attribute instance-attribute #

path: str | None = None

xref class-attribute instance-attribute #

xref: str | None = None

yref class-attribute instance-attribute #

yref: str | None = None

line class-attribute instance-attribute #

line: Line | dict[str, Any] | None = None

fillcolor class-attribute instance-attribute #

fillcolor: str | None = None

opacity class-attribute instance-attribute #

opacity: float | None = None

layer class-attribute instance-attribute #

layer: Literal['above', 'below'] | None = None

tipX class-attribute instance-attribute #

tipX: float | None = None

tipY class-attribute instance-attribute #

tipY: float | None = None

dx class-attribute instance-attribute #

dx: float | None = None

dy class-attribute instance-attribute #

dy: float | None = None

lengthPx class-attribute instance-attribute #

lengthPx: float | None = None

widthPx class-attribute instance-attribute #

widthPx: float | None = None

label class-attribute instance-attribute #

label: str | None = None

labelColor class-attribute instance-attribute #

labelColor: str | None = None

labelFontSize class-attribute instance-attribute #

labelFontSize: float | None = None

extras class-attribute instance-attribute #

extras: dict[str, Any] = field(default_factory=dict)

DeviceState #

connected instance-attribute #

connected: bool

vendor instance-attribute #

vendor: str

metadata instance-attribute #

metadata: DeviceMetadata

FittedLine dataclass #

One fitted line.

Attributes:

Name Type Description
frequency_hz float

Centre in Hz, in the frame the peaks are shown in.

frequency_ppm float

Centre in ppm.

height float

Height in the spectrum's units.

width_hz float

Half width at half height in Hz.

area float

Area under the line, intensity times Hz.

area_se float

Standard error of the area, or 0 when it could not be estimated.

shape_fraction float

Share of the line that is Lorentzian, between 0 and 1.

line_class str

"compound", "solvent" or "impurity".

reason str

What the line matched when it is not a compound line; empty otherwise.

fixed bool

Whether the line was held at the value given as its start.

warnings tuple[str, ...]

Notes on the line's fit.

frequency_hz instance-attribute #

frequency_hz: float

frequency_ppm instance-attribute #

frequency_ppm: float

height instance-attribute #

height: float

width_hz instance-attribute #

width_hz: float

area instance-attribute #

area: float

area_se instance-attribute #

area_se: float

shape_fraction instance-attribute #

shape_fraction: float

line_class instance-attribute #

line_class: str

reason instance-attribute #

reason: str

fixed instance-attribute #

fixed: bool

warnings instance-attribute #

warnings: tuple[str, ...]

FittedRegion dataclass #

The fit of one region of the spectrum.

Attributes:

Name Type Description
name str

The region's name, empty when it has none.

kind str

"lines" for a line fit, "spin_system" for a spin-system fit.

start_ppm float

Low end of the region in ppm.

end_ppm float

High end of the region in ppm.

lines tuple[FittedLine, ...]

The fitted lines; empty for a failed region or a spin-system fit.

model str

Name of the line shape fitted.

baseline_order int

Order of the polynomial baseline fitted with the lines.

r_squared float

Share of the region's variance the fit explains.

residual_rms float

Root mean square of the residual.

noise_sigma float

Noise level the fit was judged against; 0 when none was measured.

misfit bool

Whether the residual stands above the noise.

warnings tuple[str, ...]

Notes on the region's fit.

error str

Why the region could not be fitted; empty when it was.

parameters tuple[LineFitParameter, ...]

Parameters of a spin-system fit; empty for a line fit.

axis_ppm tuple[float, ...]

Chemical-shift axis of the region.

data tuple[float, ...]

Spectrum values over the region.

fitted tuple[float, ...]

Fitted curve over the region.

residual tuple[float, ...]

Data minus fit over the region.

baseline tuple[float, ...]

Fitted baseline over the region.

fit LineFit | None

The fit as the application stores it; None for a failed region.

name instance-attribute #

name: str

kind instance-attribute #

kind: str

start_ppm instance-attribute #

start_ppm: float

end_ppm instance-attribute #

end_ppm: float

lines instance-attribute #

lines: tuple[FittedLine, ...]

model instance-attribute #

model: str

baseline_order instance-attribute #

baseline_order: int

r_squared instance-attribute #

r_squared: float

residual_rms instance-attribute #

residual_rms: float

noise_sigma instance-attribute #

noise_sigma: float

misfit instance-attribute #

misfit: bool

warnings instance-attribute #

warnings: tuple[str, ...]

error instance-attribute #

error: str

parameters instance-attribute #

parameters: tuple[LineFitParameter, ...]

axis_ppm instance-attribute #

axis_ppm: tuple[float, ...]

data instance-attribute #

data: tuple[float, ...]

fitted instance-attribute #

fitted: tuple[float, ...]

residual instance-attribute #

residual: tuple[float, ...]

baseline instance-attribute #

baseline: tuple[float, ...]

fit instance-attribute #

fit: LineFit | None

LineFitResults #

LineFitResults(scan: Scan, regions: list[FittedRegion])

The outcome of Scan.line_fit: one FittedRegion per region, and the means to keep them.

regions property #

regions: list[FittedRegion]

Every region asked for, in order; a region that could not be fitted says why in error.

fitted property #

fitted: list[FittedRegion]

The regions that were fitted.

failed property #

failed: list[FittedRegion]

The regions that could not be fitted.

accept #

accept() -> int

Keep the fits on the scan and make its peak list say what they found, as the line-fit panel's Accept does.

A fitted line on an existing line moves it; one with no line near it adds a hand-placed line. A stored fit of the same region is replaced.

Returns:

Type Description
int

The number of peak edits written.

Raises:

Type Description
ValueError

When no region was fitted, or the scan is not the active scan.

SecurityError

When the project is a review copy that does not accept changes.

GeneratedReport dataclass #

GeneratedReport(
    status: ReportStatus,
    filename: str,
    path: str,
    report_id: str,
    format: ReportFormatType,
    warnings: tuple[str, ...],
    missing: tuple[str, ...],
    failure_report: bool,
    error: str,
)

A report reporting.generate made.

Attributes:

Name Type Description
status ReportStatus

Whether the report is complete, incomplete, or about a failed run.

filename str

The report's file name.

path str

Where the report was archived with the project.

report_id str

Id of the archive entry.

format ReportFormatType

The file format.

warnings tuple[str, ...]

What the engine warned about while filling the template.

missing tuple[str, ...]

Placeholders that nothing resolved.

failure_report bool

Whether this is the failure report that stands in for a report that could not be made.

error str

Why the requested report could not be made, when failure_report is set; empty otherwise.

status instance-attribute #

status: ReportStatus

filename instance-attribute #

filename: str

path instance-attribute #

path: str

report_id instance-attribute #

report_id: str

format instance-attribute #

warnings instance-attribute #

warnings: tuple[str, ...]

missing instance-attribute #

missing: tuple[str, ...]

failure_report instance-attribute #

failure_report: bool

error instance-attribute #

error: str

GraphResult #

GraphResult(
    results: dict[str, object],
    nodes: list[PostprocessingNode],
    output_id: str,
)

Read-only results of running a processing pipeline over one scan; output is its pipeline output's value.

output property #

output: SignalNd | SpectrumNd

The pipeline output's value: the run's result.

outputs property #

outputs: dict[str, object]

Each final step's id mapped to the value it produced, for inspection; the result is output.

signal property #

signal: SignalNd | None

The pipeline output when it is a signal, else None.

spectrum property #

spectrum: SpectrumNd | None

The pipeline output when it is a spectrum, else None.

GraphSpec module-attribute #

GraphSpec = (
    str
    | rpc.Postprocessing
    | list[rpc.postprocessing.PostprocessingNode]
)

Page dataclass #

Page(
    title: str,
    layout: str,
    view: str,
    normalize: bool,
    scans: list[Scan],
)

One workspace page as a script sees it: its scans (proxies, data loaded lazily) and how it shows them.

title instance-attribute #

title: str

layout instance-attribute #

layout: str

view instance-attribute #

view: str

normalize instance-attribute #

normalize: bool

scans instance-attribute #

scans: list[Scan]

Peak module-attribute #

Peak = rpc.PeakInfo | rpc.PeakInfo2D

PeakEditBatch #

PeakEditBatch(peaks: PeakSet)

One gesture's worth of peak edits; everything added inside the with block becomes one undo entry.

batch_id instance-attribute #

batch_id = new_edit_id()

add #

add(edit: PeakEdit) -> None

Queue one edit for the end of the block.

PeakSet #

PeakSet(
    scan: Scan,
    peaks: list[PeakInfo] | list[PeakInfo2D],
    *,
    spectrum: Spectrum1D | Spectrum2D | None = None,
    project: str | None = None,
)

The scan's peaks, plus edit-log operations on them; every edit method requires a reason.

log property #

log: list[PeakEdit]

Every edit ever made to this scan's peaks, disabled ones included.

find #

find(predicate: Callable[[Peak], bool]) -> list[Peak]

Every peak the predicate accepts, e.g. s.peaks.find(lambda p: p.area > 3).

by_id #

by_id(peak_id: str) -> Peak | None

The peak with this peak_id, or None.

batch #

batch() -> PeakEditBatch

Context manager grouping several edits into one undo entry.

add_peak #

add_peak(
    frequency_hz: float,
    *,
    reason: str,
    f1_hz: float | None = None,
    height: float = 0.0,
    area: float = 0.0,
) -> str

Place a peak the detector did not find. Returns the new edit's id.

delete_peak #

delete_peak(
    *,
    reason: str,
    peak_id: str | None = None,
    frequency_hz: float | None = None,
    f1_hz: float | None = None,
    mirror: bool = False,
) -> str

Remove a peak for good; a re-detected line at the same position is removed again on replay.

Parameters:

Name Type Description Default
reason str

Why the peak is removed.

required
peak_id str | None

The peak, by id.

None
frequency_hz float | None

The peak, by position on the direct axis, when no id is given.

None
f1_hz float | None

Position on the indirect axis of a 2D peak.

None
mirror bool

Also remove the partner across the diagonal of a COSY, TOCSY, NOESY or ROESY plane. Ignored for other experiments, as in the plane's context menu.

False

Returns:

Type Description
str

The id of the first edit made.

Raises:

Type Description
ValueError

When no peak is addressed, or peak_id names none.

PermissionError

When the profile or a review copy does not allow editing.

move_peak #

move_peak(
    to_hz: float,
    *,
    reason: str,
    peak_id: str | None = None,
    frequency_hz: float | None = None,
) -> str

Reposition a peak.

set_field #

set_field(
    *,
    reason: str,
    peak_id: str | None = None,
    frequency_hz: float | None = None,
    f1_hz: float | None = None,
    integral: float | None = None,
    pattern: str | None = None,
    j_couplings: list[float] | None = None,
    label: str | None = None,
    peak_type: Peak2DType | None = None,
    sign: int | None = None,
    bond_distance: int | None = None,
    mirror: bool = False,
) -> str

Override reported values of a peak; each value is its own edit, all in one undo entry.

Parameters:

Name Type Description Default
reason str

Why the value is overridden.

required
peak_id str | None

The peak, by id.

None
frequency_hz float | None

The peak, by position on the direct axis, when no id is given.

None
f1_hz float | None

Position on the indirect axis of a 2D peak.

None
integral float | None

Reported integral.

None
pattern str | None

Multiplet pattern.

None
j_couplings list[float] | None

Coupling constants in Hz.

None
label str | None

Free-text label.

None
peak_type Peak2DType | None

Class of a 2D cross peak.

None
sign int | None

1 or -1, the multiplicity sign of an HSQC-ME cross peak.

None
bond_distance int | None

Bonds between the coupled nuclei of an HMBC or H2BC cross peak.

None
mirror bool

Also set the values on the partner across the diagonal of a COSY, TOCSY, NOESY or ROESY plane. Ignored for other experiments, as in the plane's context menu.

False

Returns:

Type Description
str

The id of the first edit made.

Raises:

Type Description
ValueError

When no value is given, no peak is addressed, a 2D-only value is set on a 1D line, sign is not +1 or -1, or the experiment does not take sign (HSQC-ME) or bond_distance (HMBC, H2BC).

PermissionError

When the profile or a review copy does not allow editing.

set_cluster #

set_cluster(
    group_id: int,
    *,
    reason: str,
    pattern: str | None = None,
    j_couplings: list[float] | None = None,
    label: str | None = None,
) -> list[str]

Set the multiplicity pattern, couplings and label of a 2D cluster, as the plane's cluster editor does.

Parameters:

Name Type Description Default
group_id int

The cluster, as PeakInfo2D.group_id of its members.

required
reason str

Why the values are set.

required
pattern str | None

Multiplet pattern; blank leaves it.

None
j_couplings list[float] | None

Coupling constants in Hz; None leaves them.

None
label str | None

Free-text label; None leaves it.

None

Returns:

Type Description
list[str]

The ids of the edits made, one per value set.

Raises:

Type Description
ValueError

When no value is given or no 2D peak belongs to the cluster.

PermissionError

When the profile or a review copy does not allow editing.

merge #

merge(
    frequencies_hz: list[float] | None = None,
    *,
    reason: str,
    f1_hz: list[float] | None = None,
    peak_ids: list[str] | None = None,
) -> str

Merge lines into one multiplet, or 2D cross peaks into one cluster.

Naming a subset of a cluster's peaks splits them off as a new cluster, as the plane does.

Parameters:

Name Type Description Default
frequencies_hz list[float] | None

Positions of the lines on the direct axis.

None
reason str

Why they are merged.

required
f1_hz list[float] | None

Positions on the indirect axis, one per entry of frequencies_hz, for 2D peaks.

None
peak_ids list[str] | None

The peaks, by id, instead of positions.

None

Returns:

Type Description
str

The id of the edit made.

Raises:

Type Description
ValueError

When no peak is named, an id names none, or f1_hz and frequencies_hz differ in length.

PermissionError

When the profile or a review copy does not allow editing.

split #

split(
    start_hz: float,
    end_hz: float,
    boundary_hz: float,
    *,
    reason: str,
) -> str

Split the multiplet in [start_hz, end_hz] at the frequency boundary_hz; 1D only.

A 2D cluster is split by merge naming the peaks that form the new cluster.

set_tier #

set_tier(
    start_hz: float,
    end_hz: float,
    *,
    tier: int,
    reason: str,
) -> str

Override the automatic chemical-shift tier for the signal in this interval.

set_line_class #

set_line_class(
    frequency_hz: float,
    *,
    artifact_kind: int,
    reason: str,
    peak_id: str | None = None,
) -> str

Override the automatic class of the line at frequency_hz: an ArtifactKind (0 is compound).

set_integral_scale #

set_integral_scale(
    start_hz: float,
    end_hz: float,
    *,
    value: float,
    reason: str,
) -> str

Make the signal or region in this interval read value; every other integral keeps its ratio to it.

annotate #

annotate(
    text: str,
    *,
    reason: str,
    peak_id: str | None = None,
    frequency_hz: float | None = None,
) -> str

Attach free text to a peak.

revert #

revert(edit_id: str, *, reason: str | None = None) -> None

Undo one edit by appending a compensating entry. Nothing is erased.

clear_edits #

clear_edits(*, reason: str) -> None

Withdraw every edit on this scan, as one undo entry; back to what the detector found on its own.

replay #

replay() -> list

Re-run the log over freshly detected peaks; one outcome per edit (applied/reanchored/ambiguous/orphaned).

Scan #

Scan(
    ref: AnalysisScanRef,
    scan: Scan | None = None,
    *,
    view: LoadedScan | None = None,
)

One stored scan; data loads lazily. Assigning signal/spectrum/peaks is in-memory until save.

id property #

id: str

Scan id (UUID).

project property #

project: str

Name of the project this scan belongs to.

label property #

label: str | None

User/UI-assigned label for this scan within the working set.

group property #

group: str | None

Group/folder path of the scan, if any.

name property #

name: str

Display name (falls back to the scan id).

timestamp property #

timestamp: object

Acquisition timestamp.

experiment_type property #

experiment_type: ExperimentType

Experiment type in effect (COSY, T1_IR, …): the user's choice when set, else the detected one.

detected_experiment_type property #

detected_experiment_type: ExperimentType

Experiment type detected on import, whatever the user chose since.

sample property #

sample: object | None

Sample snapshot taken at acquisition time, if any.

metadata property #

metadata: object | None

Acquisition metadata (pulse program, gains, …).

is_loaded property #

is_loaded: bool

Whether the full scan is currently materialized in memory.

signal property writable #

signal: Signal1D | Signal2D | None

Accumulated signal (FID) as a Signal1D/Signal2D.

spectrum property writable #

spectrum: Spectrum1D | Spectrum2D | None

Accumulated spectrum as a Spectrum1D/Spectrum2D, on a ppm axis wherever it is referenced.

peaks property writable #

peaks: PeakSet

Picked peaks (a PeakSet) from the most recent perform_analysis call; not auto-detected on access.

integration_regions property #

integration_regions: list[IntegrationRegion]

Integration regions defined on the scan.

raw property #

raw: Scan

The underlying stored scan record; prefer signal/spectrum/peaks/metadata where possible.

compatible_experiment_types #

compatible_experiment_types() -> list[ExperimentType]

The experiment types this scan's axes allow it to be set to.

Returns:

Type Description
list[ExperimentType]

The types, in catalogue order.

set_experiment_type #

set_experiment_type(kind: ExperimentType | None) -> None

Override the scan's experiment type, or remove the override, as the scan list's type menu does.

The change is audited and the scan's processing and plot follow it.

Parameters:

Name Type Description Default
kind ExperimentType | None

The type to use; None removes the override so the detected type applies again.

required

Raises:

Type Description
DataError

When the scan's axes rule kind out; nothing is changed.

SecurityError

When the profile is an operator, or the project is a review copy.

perform_analysis #

perform_analysis(
    *,
    settings: PeakDetectionSettings | None = None,
    adaptive: bool | None = None,
    min_distance_hz: float | None = None,
    min_height_ratio: float | None = None,
    prominence: float | None = None,
    integration_width_hz: float | None = None,
    normalize_to_peak: int | None = None,
    multiplet_search_width_hz: float | None = None,
) -> list[PeakInfo]

Detect peaks and integrate them on this scan's spectrum; empty list for non-1D. Unset args use globals.

classify_lines #

classify_lines(
    impurity_hints: Sequence[str] = (),
) -> list[PeakInfo]

Class every picked line as compound, solvent or impurity.

Lines are matched against the sample's solvent and the tabulated impurities. Each line's line_artifact_kind (an ArtifactKind), line_class_reason and line_class_source are set; a class a person set with peaks.set_line_class is kept. The scan's own peaks are not changed.

Parameters:

Name Type Description Default
impurity_hints Sequence[str]

Names of impurities the sample is known to hold; they are accepted on weaker evidence.

()

Returns:

Type Description
list[PeakInfo]

The scan's 1D lines as the application shows them (the peak edits applied), classed.

Raises:

Type Description
ValueError

When the scan has no 1D spectrum.

signal_crop #

signal_crop(
    exclude_ppm: Sequence[tuple[float, float]] = (),
) -> SignalCrop

The window of the spectrum that holds its signals, for 1D and 2D.

Parameters:

Name Type Description Default
exclude_ppm Sequence[tuple[float, float]]

Spans, in ppm, that hold no analyte signal (reference, solvent, water).

()

Returns:

Type Description
SignalCrop

The window of the direct axis, and of the indirect axis for a plane, in ppm; found says whether any

SignalCrop

signal stood out.

Raises:

Type Description
ValueError

When the scan has no spectrum.

line_fit #

line_fit(
    regions: Literal["auto"]
    | Sequence[tuple[float, float]] = "auto",
    *,
    shape: Literal[
        "auto", "lorentzian", "gaussian", "pseudo_voigt"
    ] = "auto",
    baseline_order: int = 1,
    add_lines: bool = False,
    range_ppm: tuple[float, float] | None = None,
    exclude_ppm: Sequence[tuple[float, float]] = (),
) -> LineFitResults

Fit lines in regions of the spectrum, as the line-fit panel does; the scan must be the active scan.

Parameters:

Name Type Description Default
regions Literal['auto'] | Sequence[tuple[float, float]]

"auto" to find the regions, or (start_ppm, end_ppm) pairs.

'auto'
shape Literal['auto', 'lorentzian', 'gaussian', 'pseudo_voigt']

Shape of the fitted lines; "auto" lets the fit choose.

'auto'
baseline_order int

Order of the polynomial baseline fitted with the lines.

1
add_lines bool

Whether the fit may add lines to the ones it starts from.

False
range_ppm tuple[float, float] | None

With "auto", the span searched; the whole spectrum when omitted.

None
exclude_ppm Sequence[tuple[float, float]]

With "auto", spans kept clear of.

()

Returns:

Type Description
LineFitResults

Per-region results: lines (centre, height, width, area and its standard error, shape fraction, class and

LineFitResults

reason), region quality and residual. Nothing is kept until accept.

Raises:

Type Description
ValueError

When the scan is not the active scan, has no 1D spectrum, shape is unknown, or no region could be fitted.

auto_line_fit_regions #

auto_line_fit_regions(
    range_ppm: tuple[float, float] | None = None,
) -> list[tuple[float, float]]

The regions an automatic line fit takes, without fitting them; the scan must be the active scan.

Parameters:

Name Type Description Default
range_ppm tuple[float, float] | None

The span searched; the whole spectrum when omitted.

None

Returns:

Type Description
list[tuple[float, float]]

(start_ppm, end_ppm) of each region.

Raises:

Type Description
ValueError

When the scan is not the active scan or has no 1D spectrum.

stored_line_fits #

stored_line_fits() -> list[FittedRegion]

The line fits and spin-system fits kept on the scan.

Returns:

Type Description
list[FittedRegion]

One entry per stored fit, in the frame the peaks are shown in; empty when none is kept.

region_area #

region_area(
    region: IntegrationRegion | tuple[float, float],
    source: AreaSource | None = None,
) -> IntegrationRegionResult

The area of a region, from the trace integral or from the sum of the compound lines a line fit finds in it.

Parameters:

Name Type Description Default
region IntegrationRegion | tuple[float, float]

The region, or its (start_ppm, end_ppm).

required
source AreaSource | None

AreaSource.INTEGRAL or AreaSource.LINE_FIT; omitted, the region's own choice, else the scan's, else the project's.

None

Returns:

Type Description
IntegrationRegionResult

The region's result: area, the source it came from, its standard error for a line fit, and fit quality.

Raises:

Type Description
ValueError

When the scan has no spectrum.

fit_spin_system #

fit_spin_system(
    seed: SeedSpinSystemResponse | FitSpinSystemResult,
    range_ppm: tuple[float, float],
    *,
    linewidth_hz: float = 1.0,
    baseline_order: int = 1,
    lock_linewidth: bool = False,
    max_seconds: float = 60.0,
) -> FitSpinSystemResult

Fit a spin system to a range of the spectrum; the scan must be the active scan.

Parameters:

Name Type Description Default
seed SeedSpinSystemResponse | FitSpinSystemResult

The spin system to start from, from spin.seed or an earlier fit.

required
range_ppm tuple[float, float]

The span of the spectrum fitted.

required
linewidth_hz float

Start value of the line width.

1.0
baseline_order int

Order of the polynomial baseline fitted with the system.

1
lock_linewidth bool

Hold the line width at its start value.

False
max_seconds float

Longest the fit runs; it returns the best parameters it had.

60.0

Returns:

Type Description
FitSpinSystemResult

The fitted shifts, couplings and line width, with the fit's quality and its curves.

Raises:

Type Description
ValueError

When the scan is not the active scan, has no 1D spectrum, or the fit could not be made.

stored_analysis #

stored_analysis() -> ScanPlotAnalysis

Peaks (manual lines and edits applied), multiplets and integration-region results, as the app shows them.

Uses the global detection settings and this scan's current data; empty for non-1D. Nothing is saved or published, and peaks is not changed.

save #

save(
    *,
    signed: bool = False,
    password: str | None = None,
    comment: str = "",
) -> None

Write modifications back to this scan's own file on disk; never touches the current/active scan.

After apply or reprocess the scan is written with the pipeline's execution record, its snapshot and the input it read.

reload #

reload() -> Scan

Drop the cached data so the next access re-reads from disk.

preprocess #

preprocess(
    *,
    settings: PreprocessingSettings | None = None,
    phase_correction: PhaseCorrectionSettings | None = None,
    baseline_correction: BaselineCorrectionSettings
    | None = None,
    apodization: ApodizationSettings | None = None,
    zero_fill: ZeroFillSettings | None = None,
    fft: FftSettings | None = None,
    reference_correction: ReferenceCorrectionSettings
    | None = None,
    group_delay: GroupDelaySettings | None = None,
    solvent_suppression: SolventSuppressionSettings
    | None = None,
    linear_prediction: LinearPredictionSettings
    | None = None,
    reference_deconvolution: ReferenceDeconvolutionSettings
    | None = None,
) -> Scan

Apply preprocessing to this scan's 1D signal; no-op for non-1D. Unset stages use globals. Returns self.

Raises:

Type Description
PreprocessingError

If a stage cannot be applied as configured.

ProcessingParameterError

If a stage parameter is out of range.

analyze #

analyze(*, with_preprocessing: bool | None = None) -> Scan

Run the app's automatic processing (optionally preprocess, then peak detection). Returns self.

process #

process(graph: GraphSpec | None = None) -> GraphResult

Run a processing pipeline over this scan, without touching scans.current or this scan's data.

The pipeline reads what pipelines read for the scan: its data, or for a scan a pipeline produced, the input that pipeline read.

Parameters:

Name Type Description Default
graph GraphSpec | None

The project's pipeline (None), a saved pipeline's name, a pipeline, or a node list. It must hold exactly one pipeline output.

None

Returns:

Type Description
GraphResult

The run's results; output is the pipeline output's value.

Raises:

Type Description
PipelineError

The pipeline has no output, several, or its output was not produced.

apply #

apply(graph: GraphSpec | None = None) -> Scan

Run a processing pipeline over this scan and keep its output as this scan's data. Returns self.

A signal output brings the spectrum computed from it; a spectrum output keeps the signal it was processed from. save then writes it over this scan, save_as_new beside it, either with the execution record.

Parameters:

Name Type Description Default
graph GraphSpec | None

As for process.

None

Returns:

Type Description
Scan

This scan.

Raises:

Type Description
PipelineError

The pipeline cannot run, or its output is no signal or spectrum.

reprocess #

reprocess() -> Scan

Run the pipeline that produced this scan's data again, on the input it stores. Returns self.

Nothing is written until save, which records the new run.

Returns:

Type Description
Scan

This scan.

Raises:

Type Description
PipelineError

No pipeline produced this scan's data, or it cannot run.

save_as_new #

save_as_new(
    *, name: str | None = None, pipeline_name: str = ""
) -> str

Save this scan's data as a new scan derived from it, beside it; this scan's file is not touched.

Sample, group, experiment and acquisition metadata are carried over; after apply the new scan holds the execution record.

Parameters:

Name Type Description Default
name str | None

The new scan's name; this scan's name and the pipeline's when None.

None
pipeline_name str

The pipeline's name for the default name; the applied pipeline's when "".

''

Returns:

Type Description
str

The new scan's id.

SeriesRegionFit dataclass #

The fit of one model to one region's trend.

Attributes:

Name Type Description
region_id str

The region, as it was named in the definition.

x_label str

Name of the series variable.

x_unit str

Unit of the series variable.

x tuple[float, ...]

The variable at each point.

values tuple[float, ...]

The region's measure at each point.

sigmas tuple[float, ...]

Standard error of each value.

fit SeriesFit

The fit: parameters with standard errors, starts and whether each start was automatic, derived values, R², the fitter used and the fitted value at each point (fitted).

region_id instance-attribute #

region_id: str

x_label instance-attribute #

x_label: str

x_unit instance-attribute #

x_unit: str

x instance-attribute #

x: tuple[float, ...]

values instance-attribute #

values: tuple[float, ...]

sigmas instance-attribute #

sigmas: tuple[float, ...]

fit instance-attribute #

fit: SeriesFit

SignalCrop dataclass #

The window of a spectrum that holds its signals.

Attributes:

Name Type Description
found bool

Whether any signal stood out; when False both windows are None.

direct tuple[float, float] | None

(low, high) of the direct axis, in ppm for a frequency axis.

indirect tuple[float, float] | None

(low, high) of the indirect axis of a plane; None for a 1D spectrum and for an arrayed scan, whose indirect axis is not cropped.

found instance-attribute #

found: bool

direct instance-attribute #

direct: tuple[float, float] | None

indirect instance-attribute #

indirect: tuple[float, float] | None

SmartFittingResult dataclass #

Result from SmartFittingAPI.fit with comprehensive metadata.

success instance-attribute #

success: bool

parameters instance-attribute #

parameters: tuple[float, ...]

loss instance-attribute #

loss: float

message instance-attribute #

message: str

execution_time instance-attribute #

execution_time: float

model_name instance-attribute #

model_name: str

n_iterations instance-attribute #

n_iterations: int

initial_guess instance-attribute #

initial_guess: tuple[float, ...]

r_squared instance-attribute #

r_squared: float | None

Coefficient of determination; None when the fit failed or the data is constant.

algorithm_used instance-attribute #

algorithm_used: str

model_info instance-attribute #

model_info: FunctionAnalysisResult

data_info instance-attribute #

data_info: DataAnalysisInfo

auto_selected instance-attribute #

auto_selected: bool

FunctionAnalysisResult dataclass #

function_name class-attribute instance-attribute #

function_name: str = 'unknown'

parameter_count class-attribute instance-attribute #

parameter_count: int = 0

function_type class-attribute instance-attribute #

function_type: str = 'unknown'

confidence class-attribute instance-attribute #

confidence: float = 0.0

recommended_algorithm class-attribute instance-attribute #

recommended_algorithm: str = 'scipy'

algorithm_confidence class-attribute instance-attribute #

algorithm_confidence: float = 0.0

characteristics class-attribute instance-attribute #

characteristics: dict[str, Any] = field(
    default_factory=dict
)

analysis_methods class-attribute instance-attribute #

analysis_methods: list[str] = field(default_factory=list)

recommendation_reason class-attribute instance-attribute #

recommendation_reason: str = ''

signature class-attribute instance-attribute #

signature: SignatureInfo = field(
    default_factory=SignatureInfo
)

source_analysis class-attribute instance-attribute #

source_analysis: SourceAnalysis | None = None

name_analysis class-attribute instance-attribute #

name_analysis: NameAnalysis = field(
    default_factory=NameAnalysis
)

numerical_analysis class-attribute instance-attribute #

numerical_analysis: NumericalAnalysis | None = None

BaseOp #

Base class for all operations.

op_id class-attribute #

op_id: str

display_name class-attribute instance-attribute #

display_name: str | None = None

category class-attribute instance-attribute #

category: str | None = None

model_config class-attribute instance-attribute #

model_config = ConfigDict(arbitrary_types_allowed=True)

get_visualization #

get_visualization() -> dict[str, Any] | None

Get visualization data for this operation, or None.

get_duration_ns #

get_duration_ns() -> float

Get operation duration in nanoseconds.

to_struct #

to_struct() -> Struct

Serialize this operation to a protobuf Struct.

from_struct classmethod #

from_struct(struct: Struct) -> BaseOp

Deserialize an operation from a protobuf Struct.

PulseOp #

phase instance-attribute #

duration instance-attribute #

duration: Duration

op_id class-attribute #

op_id: str

display_name class-attribute instance-attribute #

display_name: str | None = None

category class-attribute instance-attribute #

category: str | None = None

model_config class-attribute instance-attribute #

model_config = ConfigDict(arbitrary_types_allowed=True)

get_duration_ns #

get_duration_ns() -> float

get_visualization #

get_visualization() -> dict[str, Any]

to_struct #

to_struct() -> Struct

Serialize this operation to a protobuf Struct.

from_struct classmethod #

from_struct(struct: Struct) -> BaseOp

Deserialize an operation from a protobuf Struct.

RecordOp #

duration instance-attribute #

duration: Duration

op_id class-attribute #

op_id: str

display_name class-attribute instance-attribute #

display_name: str | None = None

category class-attribute instance-attribute #

category: str | None = None

model_config class-attribute instance-attribute #

model_config = ConfigDict(arbitrary_types_allowed=True)

get_duration_ns #

get_duration_ns() -> float

get_visualization #

get_visualization() -> dict[str, Any]

to_struct #

to_struct() -> Struct

Serialize this operation to a protobuf Struct.

from_struct classmethod #

from_struct(struct: Struct) -> BaseOp

Deserialize an operation from a protobuf Struct.

SilenceOp #

duration instance-attribute #

duration: Duration

op_id class-attribute #

op_id: str

display_name class-attribute instance-attribute #

display_name: str | None = None

category class-attribute instance-attribute #

category: str | None = None

model_config class-attribute instance-attribute #

model_config = ConfigDict(arbitrary_types_allowed=True)

get_duration_ns #

get_duration_ns() -> float

get_visualization #

get_visualization() -> dict[str, Any]

to_struct #

to_struct() -> Struct

Serialize this operation to a protobuf Struct.

from_struct classmethod #

from_struct(struct: Struct) -> BaseOp

Deserialize an operation from a protobuf Struct.

LoadedScan dataclass #

LoadedScan(
    scan: Scan,
    project: str,
    signal: Signal | None = None,
    spectrum: Spectrum | None = None,
    preprocessed: bool = False,
    stored_metadata: tuple[dict[str, str], ...] = (),
    placeholder: bool = False,
    source: tuple[Signal | None, Spectrum | None]
    | None = None,
    applied_pipeline: Postprocessing | None = None,
)

A scan as the session holds it: the record (never its arrays), where it is stored, and the data shown.

project is "" for a scan that exists only in memory. stored_metadata is the metadata of the stored signal and spectrum traces, kept because processing may not carry it over. placeholder is True for a record taken from the project file whose scan has not been read yet: it may be light and stale, so it must never be written to the scan. source is what processing pipelines read for the scan: the signal and spectrum it showed before a pipeline output was applied over them, or the input a stored pipeline output was produced from; None when that is the data shown. A pipeline therefore never processes its own output. applied_pipeline is the pipeline whose output an apply shows; saving the scan records it in place of the record's own.

scan instance-attribute #

scan: Scan

project instance-attribute #

project: str

signal class-attribute instance-attribute #

signal: Signal | None = None

spectrum class-attribute instance-attribute #

spectrum: Spectrum | None = None

preprocessed class-attribute instance-attribute #

preprocessed: bool = False

stored_metadata class-attribute instance-attribute #

stored_metadata: tuple[dict[str, str], ...] = field(
    default=()
)

placeholder class-attribute instance-attribute #

placeholder: bool = False

source class-attribute instance-attribute #

source: tuple[Signal | None, Spectrum | None] | None = None

applied_pipeline class-attribute instance-attribute #

applied_pipeline: Postprocessing | None = None

is_2d property #

is_2d: bool

is_3d property #

is_3d: bool

input_signal property #

input_signal: Signal | None

The signal pipeline inputs read: the source one, never an applied output.

input_spectrum property #

input_spectrum: Spectrum | None

The spectrum pipeline inputs read: the source one, never an applied output.

with_arrays #

with_arrays() -> Scan

The record with the shown signal and spectrum written into it, for saving the data as a scan.

Shown pipeline output keeps the input it was produced from and the pipeline's snapshot.

from_stored classmethod #

from_stored(scan: Scan, project: str) -> LoadedScan

scan with the data it stores, unprocessed, and the input a pipeline produced it from.

scan itself is not changed.

unsaved classmethod #

unsaved(
    signal: Signal | None, spectrum: Spectrum | None
) -> LoadedScan

A new in-memory scan, under a record of its own, showing signal and spectrum.

Signal #

Signal = Signal1D | Signal2D

Spectrum #

Spectrum = Spectrum1D | Spectrum2D

AnalysisScanRef dataclass #

AnalysisScanRef(
    project: str,
    scan_id: str,
    label: str | None = None,
    group: str | None = None,
)

Lightweight identity of a scan in the multi-scan analysis working set.

Holds only identifiers; the actual scan is resolved lazily from the repository.

project instance-attribute #

project: str

scan_id instance-attribute #

scan_id: str

label class-attribute instance-attribute #

label: str | None = None

group class-attribute instance-attribute #

group: str | None = None