spectrochempy.nmr.Experiment

class Experiment(dataset)[source]

NMR-specific scientific interpretation of an NDDataset.

Wraps an existing dataset and provides NMR-specific classification, validation, and state-aware processing orchestration. Does not copy, subclass, or mutate the underlying dataset.

The current public processing workflow is intentionally limited to validated 1D experiments. Multi-dimensional datasets may still be classified and inspected, but their processing remains outside the public supported scope until the scientific characterization work is complete.

Parameters

dataset (NDDataset or list of NDDataset) – The NMR dataset (or list of datasets for pseudo-2D experiments) to interpret.

Examples

>>> import spectrochempy as scp
>>> fid = scp.nmr.read(path)
>>> experiment = scp.nmr.Experiment(fid)
>>> experiment.summary()
>>> spectrum = experiment.process(
...     apodization="em", lb=10.0, phase="manual", phc0=45.0
... )

Attributes Summary

dataset

The primary source dataset (first dataset for lists).

datasets

All datasets (useful for pseudo-2D series).

datatype

Reader-reported datatype ('FID', 'SER', '1D', '2D').

domain

'time', 'frequency', 'mixed', or 'unknown'.

domains

'time' or 'frequency'.

encoding

Per-dimension quadrature encoding.

experiment_type

Best-guess experiment type from pulse program (may be None).

is_frequency_domain

True if all dimensions are in frequency domain.

is_mixed_domain

True if dimensions span both time and frequency domains.

is_multi_dataset

Whether this Experiment wraps multiple datasets.

is_processable

True if the data can be meaningfully processed further.

is_processed

True if the data appears to be fully processed frequency-domain.

is_raw

True if the data appears to be raw (unprocessed) time-domain.

is_time_domain

True if all dimensions are in time domain.

ndim

Number of data dimensions.

nuclei

Observed nucleus per dimension.

source_kind

Source data classification.

Methods Summary

process(*[, apodization, lb, gb, ssb, pow, ...])

State-aware NMR processing.

summary()

Return a concise human-readable summary of the experiment.

validate()

Validate NMR-specific requirements of the dataset.

Attributes Documentation

dataset

The primary source dataset (first dataset for lists).

datasets

All datasets (useful for pseudo-2D series).

datatype

Reader-reported datatype ('FID', 'SER', '1D', '2D').

domain

'time', 'frequency', 'mixed', or 'unknown'.

Type

Summarized domain

domains

'time' or 'frequency'.

Type

Per-dimension domain

encoding

Per-dimension quadrature encoding.

experiment_type

Best-guess experiment type from pulse program (may be None).

is_frequency_domain

True if all dimensions are in frequency domain.

is_mixed_domain

True if dimensions span both time and frequency domains.

is_multi_dataset

Whether this Experiment wraps multiple datasets.

is_processable

True if the data can be meaningfully processed further.

Time-domain data is processable (FFT, apodization, etc.). Frequency-domain data is processable (phasing, baseline, etc.). Mixed-domain and unknown data are not processable in this PR.

is_processed

True if the data appears to be fully processed frequency-domain.

is_raw

True if the data appears to be raw (unprocessed) time-domain.

is_time_domain

True if all dimensions are in time domain.

ndim

Number of data dimensions.

nuclei

Observed nucleus per dimension.

source_kind

Source data classification.

One of: 'fid', 'ser', 'processed_1d', 'processed_2d', 'partially_processed', 'unknown'.

Methods Documentation

process(*, apodization=None, lb=None, gb=None, ssb=None, pow=None, size=None, phase=None, phc0=0.0, phc1=0.0)[source]

State-aware NMR processing.

Applies only operations that are scientifically appropriate for the current data domain. Never modifies the source dataset.

The supported public processing workflow currently covers validated 1D experiments only.

Parameters
  • apodization (str, optional) – Apodization function name ('em', 'gm', 'sp'). Only accepted for time-domain data. Frequency-domain datasets reject explicit apodization requests.

  • lb (float or Quantity, optional) – Explicit line-broadening parameter for 'em' and Lorentzian term for 'gm'. If omitted, the selected core apodization function uses its own default.

  • gb (float or Quantity, optional) – Explicit Gaussian broadening parameter for 'gm'. If omitted, the selected core apodization function uses its own default.

  • ssb (float, optional) – Explicit sine-bell shift parameter for 'sp'. Must be positive when provided. If omitted, the selected core apodization function uses its own default.

  • pow (float, optional) – Explicit exponent parameter for 'sp'. Only 1 and 2 are accepted by the public API. If omitted, the selected core apodization function uses its own default.

  • size (int, optional) – Zero-fill target size. Only applied to time-domain data.

  • phase (str, optional) – 'manual' to apply explicit phc0/phc1, 'metadata' to apply the dataset’s current phase metadata via pk(), or None for no phasing. 'metadata' uses the dataset’s own meta.phc0 / meta.phc1 state when present; it does not replay vendor_profile or TopSpin procs values.

  • phc0 (float) – Zero-order phase correction in degrees (manual mode).

  • phc1 (float) – First-order phase correction in degrees (manual mode).

Returns

NDDataset – Processed dataset (copy of the source).

Raises
  • RuntimeError – If the data domain does not support the requested operations.

  • NotImplementedError – If the dataset is multi-dimensional and therefore outside the current public supported processing scope.

  • ValueError – If an apodization parameter combination is incompatible with the selected apodization mode.

summary()[source]

Return a concise human-readable summary of the experiment.

validate() -> ExperimentValidation: """ Validate NMR-specific requirements of the dataset. Uses canonical :class:`~spectrochempy_nmr.nmr_metadata.NMRMetadata` fields no Bruker-specific field names are referenced. Returns ------- ExperimentValidation Report with ``errors``, ``warnings``, and ``info`` lists. """ report = ExperimentValidation() if not self._has_meta()[source]

Validate NMR-specific requirements of the dataset.

Uses canonical NMRMetadata fields — no Bruker-specific field names are referenced.

Returns

ExperimentValidation – Report with errors, warnings, and info lists.

Examples using spectrochempy.nmr.Experiment

Processing a 1D NMR spectrum

Processing a 1D NMR spectrum

Processing a 1D NMR spectrum

Processing a 1D NMR spectrum