Classes
Multiplet
PeakAligner
High-level helper to detect multiplets and align spectra around them.
Typical use: pa = PeakAligner(spectra, ppm, sf_mhz=600) windows, mptable = pa.auto_windows(top_n=30) X_aligned, shifts = pa.align(windows)
Methods
__init__(self, spectra: pd.DataFrame, ppm: np.ndarray, sf_mhz: float)
auto_windows(self, top_n: int=30, max_group_width_ppm: float=0.03)
Generate non-overlapping windows centered on strongest multiplets of the median spectrum.
align(self, windows: List[Tuple[float, float]], reference: str='median', max_shift_ppm: float=0.02)
Functions
detect_multiplets(spectrum: pd.Series, ppm: np.ndarray, sf_mhz: float, smooth_window: int=11, smooth_poly: int=2, prominence: float=0.01, width: int=3, max_group_width_ppm: float=0.03)
Detect and classify multiplets on a single spectrum.
Parameters
spectrum1D intensities indexed like ppmppmppm axis as float array, same length as spectrumsf_mhzspectrometer frequency in MHz (e.g., 600 for 600 MHz)max_group_width_ppmgroup peaks within this span as a multipleticoshift_align(spectra: pd.DataFrame, ppm: np.ndarray, windows: List[Tuple[float, float]], reference: str='median', max_shift_ppm: float=0.02)
Interval-correlation optimized shifting (icoshift-like).
Parameters
spectrarows=spectra, cols=ppmppmppm vector matching columns (ascending or descending OK)windowslist of (ppm_min, ppm_max) intervals to align independentlyreference'median' or 'mean' for the reference spectrummax_shift_ppmmax allowed shift magnitude within each windowReturns