Types#
Enums, result structures and aliases that appear in the signatures and attributes of the signal and spectrum types.
DeconvolutionResult
dataclass
#
DeconvolutionResult(
peaks: list[FittedPeak],
frequencies: ndarray,
fitted_curve: ndarray,
residuals: ndarray,
bic: float,
r_squared: float,
snr: float,
n_iterations: int,
success: bool,
message: str,
raw_result: ModelResult | None = None,
)
Result of peak deconvolution.
Attributes:
| Name | Type | Description |
|---|---|---|
peaks |
list[FittedPeak]
|
List of fitted peaks |
frequencies |
ndarray
|
Frequency array used for fitting |
fitted_curve |
ndarray
|
Fitted model curve |
residuals |
ndarray
|
Residuals (observed - fitted) |
bic |
float
|
Final BIC value |
r_squared |
float
|
Coefficient of determination |
snr |
float
|
Estimated signal-to-noise ratio |
n_iterations |
int
|
Number of BIC optimization iterations |
success |
bool
|
Whether fitting converged |
message |
str
|
Status message |
raw_result
class-attribute
instance-attribute
#
LinewidthMeasurement
dataclass
#
LinewidthMeasurement(
median_points: float,
q90_points: float,
median_hz: float,
q90_hz: float,
hz_per_point: float,
n_lines: int,
)
Robust linewidth summary measured once from an unwindowed FID.
DistributionComponent
dataclass
#
RelaxationDistribution
dataclass
#
Continuous relaxation time distribution from ILT.
Represents a distribution of T1, T2, or diffusion coefficient values with methods for computing moments, binning by cutoffs, and identifying discrete components.
All times are in seconds. Use the ms-suffixed properties for convenience.
geometric_mean
property
#
Log-weighted geometric mean relaxation time (seconds).
T2gm is the key input for the SDR permeability model.
cumulative
#
Cumulative distribution function.
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
(t_grid, cdf) where cdf goes from 0 to 1. |
fraction_below
#
Fraction of distribution below a cutoff time (seconds).
fraction_above
#
Fraction of distribution above a cutoff time (seconds).
fraction_between
#
Fraction of distribution between two cutoff times (seconds).
bin
#
peak_components
#
peak_components(
min_prominence: float = 0.05,
) -> list[DistributionComponent]
Identify discrete peaks within the distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_prominence
|
float
|
Minimum prominence as fraction of max amplitude. |
0.05
|
Returns:
| Type | Description |
|---|---|
list[DistributionComponent]
|
List of DistributionComponent with center, amplitude, width, fraction. |
from_ilt
classmethod
#
from_ilt(ilt_result: ILTResult) -> RelaxationDistribution
Create from an ILTResult.
GroupAlternative
dataclass
#
A correction a user could make to one group.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
str
|
|
at_hz |
float
|
The boundary concerned: midway between the two lines it separates. |
probability |
float
|
Posterior probability that the correction is right. |
split_index |
int
|
For |
ILTResult
dataclass
#
ILTResult(
t_grid: ndarray,
amplitudes: ndarray,
residual_norm: float,
regularization_alpha: float,
snr: float,
kernel_type: Kernel,
offset: float = 0.0,
noise_std: float = 0.0,
)
Result of inverse Laplace transform.
Attributes:
| Name | Type | Description |
|---|---|---|
t_grid |
ndarray
|
Relaxation time grid (seconds). |
amplitudes |
ndarray
|
Distribution amplitudes on |
residual_norm |
float
|
Magnitude of the data residual of the full model. |
regularization_alpha |
float
|
Regularization strength actually used. |
snr |
float
|
Signal-to-noise ratio, |
kernel_type |
Kernel
|
Decay model used. |
offset |
float
|
Fitted constant baseline (0.0 when offset fitting is disabled). |
noise_std |
float
|
Noise standard deviation used for |
Kernel
#
FittedPeak
dataclass
#
FittedPeak(
center: float,
height: float,
width: float,
phase: float = 0.0,
center_stderr: float | None = None,
height_stderr: float | None = None,
width_stderr: float | None = None,
lineshape: Literal[
"lorentzian",
"phased_lorentzian",
"voigt",
"pseudo_voigt",
] = "phased_lorentzian",
gaussian_fraction: float | None = None,
)
Result of fitting a single peak.
Attributes:
| Name | Type | Description |
|---|---|---|
center |
float
|
Peak center frequency (Hz) |
height |
float
|
Peak height (amplitude) |
width |
float
|
Peak width - HWHM for Lorentzian, FWHM for others (Hz) |
phase |
float
|
Phase angle in radians (for phased models) |
center_stderr |
float | None
|
Standard error of center estimate |
height_stderr |
float | None
|
Standard error of height estimate |
width_stderr |
float | None
|
Standard error of width estimate |
lineshape |
Literal['lorentzian', 'phased_lorentzian', 'voigt', 'pseudo_voigt']
|
Type of lineshape fitted |
gaussian_fraction |
float | None
|
Gaussian fraction for pseudo-Voigt (0-1) |
lineshape
class-attribute
instance-attribute
#
lineshape: Literal[
"lorentzian",
"phased_lorentzian",
"voigt",
"pseudo_voigt",
] = "phased_lorentzian"
from_lmfit_params
classmethod
#
from_lmfit_params(
params: Parameters, prefix: str = ""
) -> FittedPeak
Create FittedPeak from lmfit Parameters result.
MultipletReading
dataclass
#
MultipletReading(
best: PatternReading,
alternatives: tuple[PatternReading, ...] = (),
second_order: bool = False,
unnamed: PatternReading | None = None,
)
Every reading of a multiplet worth reporting.
Attributes:
| Name | Type | Description |
|---|---|---|
best |
PatternReading
|
The reported reading; crowded groups can remain unnamed when no specific interpretation has majority support. |
alternatives |
tuple[PatternReading, ...]
|
The next most probable readings, most probable first. |
second_order |
bool
|
The best reading is |
PatternReading
dataclass
#
PatternReading(
label: str,
j_hz: tuple[float, ...],
j_sd_hz: tuple[float, ...],
centre_hz: float,
probability: float,
roof: float = 0.0,
system: str = "",
system_couplings: tuple[str, ...] = (),
shifts_hz: tuple[float, ...] = (),
)
One reading of a multiplet.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
str
|
|
j_hz |
tuple[float, ...]
|
Couplings. For a first-order label, largest first, one per coupling of the label
(a |
j_sd_hz |
tuple[float, ...]
|
Standard error of each coupling. |
centre_hz |
float
|
Centre of the pattern. |
probability |
float
|
Posterior probability of the reading among all those tried. |
roof |
float
|
Fitted lean, log height of the last line over the first. |
system |
str
|
For a strongly coupled reading (label |
system_couplings |
tuple[str, ...]
|
Names of |
shifts_hz |
tuple[float, ...]
|
For a spin system, the shift of each observed site (A, then B). |
Anchor
dataclass
#
Anchor(
hz: float,
f1_hz: float | None = None,
ppm: float | None = None,
f1_ppm: float | None = None,
peak_id: str | None = None,
)
The position an edit points to, in Hz.
Attributes:
| Name | Type | Description |
|---|---|---|
hz |
float
|
Direct-axis (F2) position in Hz. |
f1_hz |
float | None
|
Indirect-axis position in Hz. Non-None marks a 2D crosspeak. |
ppm |
float | None
|
Direct-axis position in ppm, informational only (not resolved against; unaffected by re-referencing). |
f1_ppm |
float | None
|
Indirect-axis position in ppm, informational only. |
peak_id |
str | None
|
Id of the peak this anchor was made against, if known. Used as a resolution hint; not guaranteed to survive re-detection. |
EditKind
#
The kind of change one log entry represents.
EditablePeak
dataclass
#
EditablePeak(
peak_id: str,
frequency_hz: float,
f1_hz: float | None = None,
index: int = -1,
index_f1: int = -1,
frequency_ppm: float | None = None,
f1_ppm: float | None = None,
height: float = 0.0,
area: float = 0.0,
linewidth_hz: float = 0.0,
group_id: int | None = None,
multiplet_pattern: str = "",
j_couplings: tuple[float, ...] = (),
label: str = "",
annotation: str = "",
inferred: bool = False,
manual: bool = False,
tier_override: int | None = None,
edit_ids: list[str] = list(),
linewidth_f1_hz: float = 0.0,
linewidth_f1_ppm: float = 0.0,
linewidth_f2_ppm: float = 0.0,
peak_type: int = 0,
diagonal: bool = False,
)
A plain, backend-independent representation of one peak line.
f1_hz being set marks this as a 2D crosspeak.
Attributes:
| Name | Type | Description |
|---|---|---|
manual |
bool
|
True when this peak was created by an ADD edit rather than detected automatically. The sole indicator of manual origin. |
tier_override |
int | None
|
Chemical-shift tier set by a SET_TIER edit, if any. |
edit_ids |
list[str]
|
Ids of every edit that touched this peak in the current replay. |
linewidth_f1_hz |
float
|
Indirect-axis linewidth in Hz of a crosspeak; 0 when not stated. |
linewidth_f1_ppm |
float
|
Indirect-axis linewidth in ppm of a crosspeak; 0 when not stated. |
linewidth_f2_ppm |
float
|
Direct-axis linewidth in ppm of a crosspeak; 0 when not stated. |
peak_type |
int
|
Class a source tool gave a crosspeak (the wire enum's value); 0 when it gave none. |
diagonal |
bool
|
Whether a source tool marked the crosspeak as lying on the diagonal. |
GroupScope
dataclass
#
GroupScope(
start_hz: float,
end_hz: float,
member_peak_ids: tuple[str, ...] = (),
f1_start_hz: float | None = None,
f1_end_hz: float | None = None,
shift_id: str | None = None,
)
The region and members a group-scoped edit applies to.
Attributes:
| Name | Type | Description |
|---|---|---|
shift_id |
str | None
|
The |
contains
#
contains(peak: EditablePeak) -> bool
Whether peak falls inside this scope's interval on every axis it has.
PeakEdit
dataclass
#
PeakEdit(
edit_id: str,
kind: EditKind,
anchors: tuple[Anchor, ...] = (),
scope: GroupScope | None = None,
created_at: str = "",
author: str = "",
source: str = UI,
reason: str | None = None,
batch_id: str = "",
disabled: bool = False,
reverts_edit_id: str | None = None,
payload: Mapping[str, Any] = dict(),
)
One immutable entry in a peak edit log.
Attributes:
| Name | Type | Description |
|---|---|---|
edit_id |
str
|
Client-generated uuid, unique per entry. Used to deduplicate retried submissions. |
kind |
EditKind
|
What the edit does. |
anchors |
tuple[Anchor, ...]
|
Position(s) the edit applies to. |
scope |
GroupScope | None
|
Interval + member ids, for the group-scoped kinds. |
created_at |
str
|
RFC 3339 UTC timestamp. |
author |
str
|
Profile name of whoever made the edit. |
source |
str
|
|
reason |
str | None
|
Why the edit was made. Required for script, plugin and vendor sources. |
batch_id |
str
|
Groups edits made in one user gesture; one batch is undone as a unit. |
disabled |
bool
|
True once this entry has been reverted. Entries are never removed, only marked disabled. |
reverts_edit_id |
str | None
|
Id of the entry this one undoes, if it is a revert. |
payload |
Mapping[str, Any]
|
Kind-specific values. See :func: |
Raises:
| Type | Description |
|---|---|
EditValidationError
|
If |
payload
class-attribute
instance-attribute
#
GroupingEvidence
dataclass
#
GroupingEvidence(
group_id: int,
member_indices: tuple[int, ...],
probability: float,
reason: str,
label: str,
alternatives: tuple[GroupAlternative, ...],
reading: MultipletReading,
unresolved: bool = False,
)
How firmly the data support one group, and the corrections most likely to fix it.
Attributes:
| Name | Type | Description |
|---|---|---|
group_id |
int
|
The group's |
member_indices |
tuple[int, ...]
|
|
probability |
float
|
Posterior probability that these lines are exactly one multiplet, neither split nor joined with a neighbour. |
reason |
str
|
Competing reading that holds the rest of the probability:
|
label |
str
|
Pattern label of the best model for the group. |
alternatives |
tuple[GroupAlternative, ...]
|
Best split and both merges, most probable first. |
reading |
MultipletReading
|
What the group's lines say its multiplet is, with the alternatives. |
GroupingPlan
dataclass
#
GroupingPlan(groups: list[MultipletGroup])
A segmentation whose multiplet reads have not run yet: the fast half of :func:group_peaks_with_evidence.
Attributes:
| Name | Type | Description |
|---|---|---|
groups |
list[MultipletGroup]
|
The groups, sorted by centre frequency, with bounds and integration; no pattern. |
read
#
read(index: int) -> MultipletReading
The multiplet reading of group index; memoised on its inputs, safe from any thread.
evidence
#
evidence(
readings: list[MultipletReading],
) -> list[GroupingEvidence]
One :class:GroupingEvidence per group, given every group's reading in group order.
SolventBand
dataclass
#
SolventBand(
offset_hz: float,
fwhm_hz: float,
half_width_hz: float,
perturbed_half_width_hz: float,
apex: float,
noise_sigma: float,
multiplet_half_span_hz: float = 0.0,
)
The band of frequencies a solvent line occupies, measured on the FID.
Attributes:
| Name | Type | Description |
|---|---|---|
offset_hz |
float
|
Position of the line relative to the carrier, in Hz. This is what the FID is shifted by, so it is signed. |
fwhm_hz |
float
|
Full width at half maximum of the line, measured by walking down from its apex in the magnitude spectrum of the raw FID. |
half_width_hz |
float
|
Half-width of the band that will be removed, in Hz. |
perturbed_half_width_hz |
float
|
How far from the line the filter changes the
spectrum by more than the noise, in Hz. Never smaller than
|
apex |
float
|
Magnitude of the line at its apex, in the units of the FID. |
noise_sigma |
float
|
Noise sigma the detection threshold was built from. |
SolventHlsvdFit
dataclass
#
SolventHlsvdFit(
center_hz: float,
fwhm_hz: float,
window_half_width_hz: float,
component_frequencies_hz: tuple[float, ...],
component_fwhm_hz: tuple[float, ...],
component_amplitudes: tuple[complex, ...],
n_components: int,
noise_sigma: float,
imaginary_source: ImaginarySource,
)
The solvent signal measured at a known shift, as a sum of damped sinusoids.
Attributes:
| Name | Type | Description |
|---|---|---|
center_hz |
float
|
Measured centre of the line, in Hz on the spectrum's axis. |
fwhm_hz |
float
|
Measured full width at half maximum of the line's real part, in Hz. |
window_half_width_hz |
float
|
Half-width of the selection window around
|
component_frequencies_hz |
tuple[float, ...]
|
Centre of each removed component, in Hz on the axis. |
component_fwhm_hz |
tuple[float, ...]
|
Full width at half maximum of each removed component, in Hz. |
component_amplitudes |
tuple[complex, ...]
|
Complex height of each removed component on the spectrum. |
n_components |
int
|
Components in the whole model of the estimation band. |
noise_sigma |
float
|
Noise standard deviation the model order was chosen against. |
imaginary_source |
ImaginarySource
|
|
evaluate
#
Evaluate the removed solvent model on the full grid it was fitted on.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
Number of points of that grid. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The complex model, one value per grid point, in the grid's own order. |
SolventLineFit
dataclass
#
SolventLineFit(
peak: FittedPeak,
components: tuple[FittedPeak, ...],
search_center_hz: float,
search_half_width_hz: float,
noise_sigma: float,
subtraction_low_hz: float,
subtraction_high_hz: float,
)
The solvent signal measured at a known shift.
Attributes:
| Name | Type | Description |
|---|---|---|
peak |
FittedPeak
|
The tallest fitted component, with center and width in Hz. |
components |
tuple[FittedPeak, ...]
|
Every component of the solvent's own signal, |
search_center_hz |
float
|
The expected shift the search was centered on, in Hz. |
search_half_width_hz |
float
|
Half-width of the window that was searched, in Hz. |
noise_sigma |
float
|
Noise standard deviation the detection threshold was built from. |
half_width_hz
property
#
Half-width of the span the fitted components occupy, in Hz.
evaluate
#
evaluate(frequencies_hz: FloatArray) -> FloatArray
Evaluate the fitted solvent signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies_hz
|
FloatArray
|
Frequencies to evaluate at, in Hz. |
required |
Returns:
| Type | Description |
|---|---|
FloatArray
|
The signal's amplitude at each frequency, real valued. |
SolventRemoval
dataclass
#
SolventRemoval(
method: SolventSuppressionMethod,
center_hz: float,
fwhm_hz: float,
half_width_hz: float,
band: SolventBand | None = None,
fit: SolventLineFit | None = None,
hlsvd: SolventHlsvdFit | None = None,
)
What a solvent removal took out, whichever method took it out.
A removal that found no line to remove is represented by None, not by
an instance of this type.
Attributes:
| Name | Type | Description |
|---|---|---|
method |
SolventSuppressionMethod
|
Which method was used. |
center_hz |
float
|
Where the line was found, in Hz on the spectrum's axis. |
fwhm_hz |
float
|
The line's full width at half maximum, in Hz. |
half_width_hz |
float
|
Half-width of the span the removal treated, in Hz. |
band |
SolventBand | None
|
The measured band, when |
fit |
SolventLineFit | None
|
The fitted component, when |
hlsvd |
SolventHlsvdFit | None
|
The removed sinusoid model, when |
from_band
classmethod
#
from_band(band: SolventBand) -> SolventRemoval
Describe a band removal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
band
|
SolventBand
|
The band that was removed. |
required |
Returns:
| Type | Description |
|---|---|
SolventRemoval
|
The removal record. |
from_fit
classmethod
#
from_fit(fit: SolventLineFit) -> SolventRemoval
Describe a fitted-line subtraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fit
|
SolventLineFit
|
The component that was subtracted. |
required |
Returns:
| Type | Description |
|---|---|
SolventRemoval
|
The removal record. |
from_hlsvd
classmethod
#
from_hlsvd(model: SolventHlsvdFit) -> SolventRemoval
Describe a subtraction of the solvent's sinusoid model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
SolventHlsvdFit
|
The model that was subtracted. |
required |
Returns:
| Type | Description |
|---|---|
SolventRemoval
|
The removal record. |
SolventSuppressionMethod
module-attribute
#
InvalidSignalError
#
Raised when signal data is invalid.
ProcessingParameterError
#
Raised when processing parameters are invalid.
F1AcquisitionMode
#
F1AcquisitionMode = Literal[
"undefined",
"qf",
"qseq",
"tppi",
"states",
"states_tppi",
"echo_antiecho",
]
WindowShape
dataclass
#
WindowShape(
sine_offset: float = 0.5,
sine_power: float = 1.0,
rise_fraction: float = 0.0,
fall_fraction: float = 0.5,
)
Parameters of the windows that take more than a width.
Attributes:
| Name | Type | Description |
|---|---|---|
sine_offset |
float
|
|
sine_power |
float
|
|
rise_fraction |
float
|
|
fall_fraction |
float
|
|
WindowType
#
WindowType = Literal[
"none",
"exponential",
"gaussian",
"hamming",
"hann",
"blackman",
"blackmanharris",
"kaiser",
"bartlett",
"cosine",
"tukey",
"sine_bell",
"trapezoid",
"traf",
"lorentz_gauss",
]
MultiExponentialResult
dataclass
#
MultiExponentialResult(
n_components: int,
time_constants_ms: list[float],
amplitudes: list[float],
offset: float,
residual: float,
)
Result of discrete multi-exponential fitting.
BaselineMethod1D
#
BaselineMethod1D = Literal[
"polynomial",
"median",
"als",
"edge",
"valley",
"arpls",
"airpls",
"asls",
"snip",
"masked_poly",
]
BaselineMethod2D
#
BaselineMethod2D = Literal[
"plane",
"polynomial",
"median",
"als",
"edge",
"valley",
"arpls",
"airpls",
"asls",
"snip",
"masked_poly",
]
AlignmentGeometry
dataclass
#
AlignmentGeometry(
shared_f1: float,
shared_f2: float,
spread_f1: float,
spread_f2: float,
quality: float,
resolution_f1_hz: float,
resolution_f2_hz: float,
n_vectors: int,
reason: str,
)
The direction along which a plane's peaks line up, measured from the peaks.
Attributes:
| Name | Type | Description |
|---|---|---|
shared_f1 |
float
|
F1 coefficient of the shared coordinate, in Hz per Hz. |
shared_f2 |
float
|
F2 coefficient of the shared coordinate, in Hz per Hz. |
spread_f1 |
float
|
F1 component of the unit spread direction, in Hz per Hz. |
spread_f2 |
float
|
F2 component of the unit spread direction, in Hz per Hz. |
quality |
float
|
Concentration of the displacement directions, 0 to 1. |
resolution_f1_hz |
float
|
Measured line width along F1, in Hz. |
resolution_f2_hz |
float
|
Measured line width along F2, in Hz. |
n_vectors |
int
|
Number of short displacement vectors the direction was read from. |
reason |
str
|
Human-readable summary, for logs and for callers explaining a route. |
is_aligned
property
#
Whether the peaks line up well enough for the direction to mean anything.
shear_slope
property
#
Slope s of the shear F2 + s*F1 that collapses the alignment, if any.
None when the shared coordinate does not involve F2 at all.
shared_resolution_hz
property
#
Line width projected onto the shared coordinate, in Hz.
spread_resolution_hz
property
#
Line width projected onto the spread direction, in Hz.
max_spread_spacing_hz
property
#
Widest spacing along the spread direction that still chains two lines.
shared_coordinate
#
Shared coordinate of each point, in Hz.
spread_coordinate
#
Position of each point along the spread direction, in Hz.
shears_the_plane
#
Whether a shear along F2 is what collapses this alignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f1_span_hz
|
float
|
Width of the indirect axis, in Hz. |
required |
f2_span_hz
|
float
|
Width of the direct axis, in Hz. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
False when the shear would move nothing or the alignment runs along |
bool
|
the F2 axis; otherwise whether to shear. |
JresDetection
dataclass
#
JresDetection(
is_jres: bool,
reason: str,
f1_span_hz: float,
f2_span_hz: float,
slope: float | None = None,
quality: float = 0.0,
)
Outcome of J-resolved detection on a 2D plane.
Attributes:
| Name | Type | Description |
|---|---|---|
is_jres |
bool
|
Whether the plane's multiplets lie on a line that a shear can collapse. |
reason |
str
|
Human-readable justification, logged when processing is skipped. |
f1_span_hz |
float
|
Indirect spectral width in Hz. |
f2_span_hz |
float
|
Direct spectral width in Hz. |
slope |
float | None
|
Measured shear slope in Hz of F2 per Hz of F1, or None when no shear applies. |
quality |
float
|
How concentrated the measured alignment is, 0 to 1. |
MultipletGroupsAnalysis
dataclass
#
MultipletGroupsAnalysis(
groups: list[MultipletGroup] = list(),
total_groups: int = 0,
method: str = "structure",
noise_level: float = 0.0,
noise_multiplier: float = 3.0,
inferred_peaks: list[PeakInfo] = list(),
grouping: list[GroupingEvidence] = list(),
)
Result of multi-group multiplet analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
groups |
list[MultipletGroup]
|
List of MultipletGroup objects, one per detected group. |
total_groups |
int
|
Number of detected multiplet groups. |
method |
str
|
Analysis method used ('structure', 'deconvolution', 'pascal'). |
noise_level |
float
|
Estimated noise standard deviation. |
noise_multiplier |
float
|
The threshold multiplier used for detection. |
inferred_peaks |
list[PeakInfo]
|
Lines no detector picked, concluded from a group's own
intensities and confirmed against the trace. Empty unless
|
grouping |
list[GroupingEvidence]
|
How firmly the data support each group, in |
groups
class-attribute
instance-attribute
#
groups: list[MultipletGroup] = field(default_factory=list)
inferred_peaks
class-attribute
instance-attribute
#
grouping
class-attribute
instance-attribute
#
grouping: list[GroupingEvidence] = field(
default_factory=list
)
ShiftIntegrationResult
dataclass
#
ShiftIntegrationResult(
group_id: int,
peaks: list[PeakInfo],
area: float,
normalized_area: float,
bounds: tuple[float, float],
center_ppm: float | None,
center_hz: float | None,
pattern: str | None,
n_peaks: int,
)
Result of chemical shift (multiplet group) integration.
PeakInfo2D
dataclass
#
PeakInfo2D(
index_f1: int,
index_f2: int,
frequency_f1: float,
frequency_f2: float,
height: float,
volume: float | None = None,
group_id: int | None = None,
width_f1: float | None = None,
width_f2: float | None = None,
ridge_id: str | None = None,
signed_height: float | None = None,
)
Information about a detected 2D peak.
PlaneNoiseEstimate
dataclass
#
A magnitude plane's noise, measured in one pass for detection and grouping.
detection is the (level, sigma) find_peaks(noise=...) takes on |z|;
grouping_sigma is the sigma group_peaks and infer_multiplets take.
OrientationCues
dataclass
#
OrientationCues(
reference: tuple[SignedLine, ...] = (),
solvent: tuple[SignedLine, ...] = (),
structure: Callable[[], Sequence[SignedLine]]
| None = None,
structure_window_ppm: float = 0.0,
)
What a mixed-polarity spectrum's half turn may be read from, strongest first.
Attributes:
| Name | Type | Description |
|---|---|---|
reference |
tuple[SignedLine, ...]
|
The declared internal reference compound's line(s). |
solvent |
tuple[SignedLine, ...]
|
The solvent table's line(s) for the sample's solvent. |
structure |
Callable[[], Sequence[SignedLine]] | None
|
The lines the sample's structure predicts, asked for only when no anchor stands. |
structure_window_ppm |
float
|
How far a predicted line may sit from an observed one and still be it. |
structure
class-attribute
instance-attribute
#
structure: Callable[[], Sequence[SignedLine]] | None = None
PhaseRamp
#
A phase along one axis of a spectrum, in degrees.
phi(u) = p0 + p1 * (u - pivot) + p2 * (u - pivot)**2 with u = index / n along the axis in
array order, applied as a multiplication by exp(+i * phi) -- the 1D ps2 convention.
Attributes:
| Name | Type | Description |
|---|---|---|
p0 |
float
|
Phase at the pivot. |
p1 |
float
|
First-order phase across the whole axis. |
p2 |
float
|
Second-order phase across the whole axis. |
pivot |
float
|
The pivot as a fraction of the axis (0 = first point), so |
at_first_point
#
The same phase as (p0, p1, p2) measured from the first point, which ps2 takes.
from_topspin_direct
classmethod
#
from_topspin_direct(phc0: float, phc1: float) -> PhaseRamp
The ramp TopSpin's PHC0/PHC1 of a direct dimension mean on this engine's axis.
TopSpin counts PHC1 from the left (high-frequency) edge and rotates the other way, so
phi(u) = -(PHC0 + PHC1 * (1 - u)) on this engine's ascending axis.
SignedLine
#
RegionMixin2D
#
Mixin giving Spectrum2D the region operations Spectrum1D has, along each axis.
suppress_region
#
suppress_region(
center: float,
width: float,
method: SuppressionMethod = SUPPRESS_INTERPOLATE,
axis: Axis = "f2",
center_f1: float | None = None,
width_f1: float | None = None,
) -> Self
Suppress a band of every row (F2), of every column (F1), or both, in place.
Each row or column is treated exactly as Spectrum1D.suppress_region treats a 1D spectrum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
float
|
Centre of the F2 band, in the F2 axis unit. |
required |
width
|
float
|
Full width of the F2 band, in the F2 axis unit. |
required |
method
|
SuppressionMethod
|
Zero, interpolate across the edges, or fill with a fitted polynomial. |
SUPPRESS_INTERPOLATE
|
axis
|
Axis
|
Which band to suppress. |
'f2'
|
center_f1
|
float | None
|
Centre of the F1 band, in the F1 axis unit; required for |
None
|
width_f1
|
float | None
|
Full width of the F1 band; required for |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
Self for method chaining. |
Raises:
| Type | Description |
|---|---|
ProcessingParameterError
|
When an F1 band is asked for without its centre and width. |
ValueError
|
When a band lies outside its axis. |
suppress_diagonal
#
suppress_diagonal(
width: float,
method: SuppressionMethod = SUPPRESS_INTERPOLATE,
) -> Self
Suppress the band along the F1 = F2 diagonal of a homonuclear plane, in place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
float
|
Full width of the band about the diagonal, in the axis unit. |
required |
method
|
SuppressionMethod
|
How the band is filled, as for |
SUPPRESS_INTERPOLATE
|
Returns:
| Type | Description |
|---|---|
Self
|
Self for method chaining. |
Raises:
| Type | Description |
|---|---|
ProcessingParameterError
|
On a heteronuclear plane, one with unknown nuclei, or axes in different units. |
reference_to_ppm
#
reference_to_ppm(
target_f2_ppm: float | None,
target_f1_ppm: float | None = None,
search_window_f2_ppm: float = 0.5,
search_window_f1_ppm: float = 0.5,
) -> Self
Shift the axes so the tallest peak near a target lies on it.
The peak is the largest magnitude inside the box of the two search windows about the target. An axis with no target is left alone; at least one target is needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_f2_ppm
|
float | None
|
Where the peak should lie on F2, or None to shift F1 only. |
required |
target_f1_ppm
|
float | None
|
Where it should lie on F1, or None to shift F2 only. |
None
|
search_window_f2_ppm
|
float
|
Half-width of the box on F2. |
0.5
|
search_window_f1_ppm
|
float
|
Half-width of the box on F1. |
0.5
|
Returns:
| Type | Description |
|---|---|
Self
|
Self with shifted axes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
When no target is given, the box holds no data, or an axis cannot be put in ppm. |
align_by_correlation
#
align_by_correlation(reference: RegionMixin2D) -> Self
Align to a reference plane by the lag that maximises the correlation of the magnitudes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference
|
RegionMixin2D
|
Plane on the same grid, which is not modified. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
Self with shifted axes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
When the planes differ in shape. |