Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

processing.phasing

processing.phasing

Functions

NameDescription
autophaseAutomatically calculate and apply phase correction to a spectrum.
phaseApply zero- and first-order (linear) phase correction to a spectrum.

autophase

processing.phasing.autophase(
    da,
    dim=DIMS.frequency,
    method='acme',
    peak_width=0.5,
    target_coord=None,
    p0_only=False,
    lb=0.0,
    temp_time_dim=DIMS.time,
    **kwargs,
)

Automatically calculate and apply phase correction to a spectrum.

Parameters

NameTypeDescriptionDefault
daxr.DataArrayThe input frequency-domain spectrum.required
dimstrThe coordinate dimension to operate on, by default DIMS.frequency.DIMS.frequency
method(acme, peak_minima, positivity)The scoring algorithm to use. “acme” relies on entropy and is best for multi-peak high SNR spectra. “positivity” and “peak_minima” are optimized for sparse/noisy spectra. By default “acme”."acme"
peak_widthfloatWidth of the ROI (in units of dim, e.g., Hz or ppm) for the local methods. Concentrates the solver on the region surrounding the target peak. By default 0.5.0.5
target_coordfloat | NoneThe explicit coordinate (e.g. 171.0 ppm) to target for local methods. If None, the coordinate of the maximum absolute magnitude is used.None
p0_onlyboolIf True, locks p1=0 and only optimizes the zero-order phase. Highly recommended for sparse spectra evaluated over a narrow peak_width.False
lbfloatOptional exponential line broadening (in Hz). Can help smooth extreme noise for ACME, but usually unnecessary for local methods. By default 0.0.0.0
temp_time_dimstrThe name used for the temporary time dimension if lb > 0.DIMS.time
**kwargsAdditional keyword arguments passed to scipy.optimize.differential_evolution.{}

Returns

NameTypeDescription
xr.DataArrayThe phased spectrum.

phase

processing.phasing.phase(da, dim=DIMS.frequency, p0=0.0, p1=0.0, pivot=None)

Apply zero- and first-order (linear) phase correction to a spectrum.

Parameters

NameTypeDescriptionDefault
daxr.DataArrayThe input frequency-domain spectrum. Must be complex-valued.required
dimstrThe coordinate dimension along which to apply phase correction, by default DIMS.frequency.DIMS.frequency
p0floatZero-order phase angle in degrees. This is a constant phase shift applied uniformly to all coordinates. By default 0.0.0.0
p1floatFirst-order phase angle in degrees. This represents the total phase twist applied across the entire spectral range (max_coord - min_coord). By default 0.0.0.0
pivotfloatThe coordinate value (e.g., ppm or Hz) around which p1 is anchored. At this exact coordinate, the first-order phase contribution is 0.0. If None, standard maximum-magnitude pivoting is used.None

Returns

NameTypeDescription
xr.DataArrayThe phase-corrected spectrum. Phase parameters (p0, p1, pivot, and pivot_coord) are appended to the dataset attributes to preserve lineage.