processing.phasing
Functions¶
| Name | Description |
|---|---|
| autophase | Automatically calculate and apply phase correction to a spectrum. |
| phase | Apply zero- and first-order (linear) phase correction to a spectrum. |
autophase¶
processing.phasing.autophase(
da,
dim=None,
method='acme',
mode='single',
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¶
| Name | Type | Description | Default |
|---|---|---|---|
| da | xr.DataArray | The input frequency-domain spectrum. Can be N-dimensional. | required |
| dim | str or None | The spectral dimension to operate on. If None (default) it is resolved automatically to the spectral dim present (frequency [Hz] or chemical_shift [ppm]); time-domain input is transformed to a spectrum first. | None |
| 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" |
| mode | (single, all) | Determines how N-dimensional data is handled. - “single”: Calculates the phase parameters using only the 1D slice with the global maximum signal, then applies those parameters across the entire dataset. - “all”: Calculates and applies unique phase parameters for every 1D spectrum individually. By default “single”. | "single" |
| peak_width | float | Width 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_coord | float | None | The 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_only | bool | If True, locks p1=0 and only optimizes the zero-order phase. Highly recommended for sparse spectra evaluated over a narrow peak_width. | False |
| lb | float | Optional 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_dim | str | The name used for the temporary time dimension if lb > 0. | DIMS.time |
| **kwargs | Additional keyword arguments passed to scipy.optimize.differential_evolution. | {} |
Returns¶
| Name | Type | Description |
|---|---|---|
| xr.DataArray | The 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¶
| Name | Type | Description | Default |
|---|---|---|---|
| da | xr.DataArray | The input frequency-domain spectrum. Must be complex-valued. Can be N-dimensional; phase will be broadcast across non-dim dimensions. | required |
| dim | str | The coordinate dimension along which to apply phase correction, by default DIMS.frequency. | DIMS.frequency |
| p0 | float | Zero-order phase angle in degrees. This is a constant phase shift applied uniformly to all coordinates. By default 0.0. | 0.0 |
| p1 | float | First-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 |
| pivot | float | The 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 safely across N-D. | None |
Returns¶
| Name | Type | Description |
|---|---|---|
| xr.DataArray | The phase-corrected spectrum. Phase parameters (p0, p1, pivot, and pivot_coord) are appended to the dataset attributes to preserve lineage. |