Skip to content

state#

The app's current working data: signal, spectrum, scan, project, peaks.

Read these to get whatever is currently loaded, and assign to signal / spectrum to replace it — assigning also redraws the plot automatically. To change the data without redrawing, use set_signal / set_spectrum with plot=False.

Example
sig = state.signal  # read the current signal
state.signal = new_signal  # replace it and redraw
state.set_signal(new_signal, plot=False)  # replace without redrawing

current_scan #

current_scan() -> Scan | None

The scan currently loaded in the app, or None if none is active.

peaks #

peaks() -> list[PeakInfo] | list[PeakInfo2D]

The peaks picked on the current spectrum (1D or 2D; empty if none).

project #

project() -> Project

The open project (its settings, sample, processing graph, and scans).

sample #

sample() -> Sample | None

The sample attached to the open project, or None if unset.

signal #

signal() -> Signal1D | Signal2D | None

The current signal (FID), 1D or 2D. Assigning redraws the plot.

None when nothing is loaded.

spectrum #

spectrum() -> Spectrum1D | Spectrum2D | None

The current spectrum, 1D or 2D. Assigning redraws the plot.

None when nothing is loaded.

clear #

clear() -> None

Clear the current signal and spectrum and wipe all plots.

set_signal #

set_signal(
    value: Signal1D | Signal2D | None, plot: bool = True
) -> None

Replace the current signal, optionally without redrawing.

Same as assigning state.signal, but lets you skip the plot update — useful in tight loops where you only want to redraw once at the end.

Parameters:

Name Type Description Default
value Signal1D | Signal2D | None

The signal to set (1D or 2D), or None to clear it.

required
plot bool

Whether to redraw the plot afterwards.

True

set_spectrum #

set_spectrum(
    value: Spectrum1D | Spectrum2D | None, plot: bool = True
) -> None

Replace the current spectrum, optionally without redrawing.

Same as assigning state.spectrum, but lets you skip the plot update — useful in tight loops where you only want to redraw once at the end.

Parameters:

Name Type Description Default
value Spectrum1D | Spectrum2D | None

The spectrum to set (1D or 2D), or None to clear it.

required
plot bool

Whether to redraw the plot afterwards.

True