bioniumx.detection.cross_correlate_template

bioniumx.detection.cross_correlate_template(spectrum: TransmissionSpectrum, template_wavelength: ndarray, template_depth: ndarray, velocity_range: tuple = (-150, 150), velocity_step: float = 0.5) dict[source]

Cross-correlate a transmission spectrum against a molecular template.

Shifts the template across a range of radial velocities and computes the Pearson correlation coefficient at each shift. A peak in the CCF near 0 km/s indicates the molecule is present.

Parameters:
  • spectrum (TransmissionSpectrum) – Observed spectrum to analyze.

  • template_wavelength (array-like) – Template wavelength grid (microns).

  • template_depth (array-like) – Template transit depth at each wavelength.

  • velocity_range (tuple of (float, float), optional) – Min and max velocity shift to test in km/s. Default (-150, 150).

  • velocity_step (float, optional) – Velocity resolution in km/s. Default 0.5.

Returns:

result – Dictionary with keys: - ‘velocity’ : np.ndarray — velocity axis (km/s) - ‘ccf’ : np.ndarray — cross-correlation function values - ‘peak_velocity’ : float — velocity of CCF peak (km/s) - ‘peak_ccf’ : float — peak CCF value - ‘significance’ : float — peak significance in σ (Gaussian)

Return type:

dict

References

Snellen, I. A. G. et al. (2010), Nature, 465, 1049. Brogi, M. & Line, M. R. (2019), AJ, 157, 114.

Examples

>>> from bioniumx.molecules import get_template
>>> wl_t, depth_t = get_template("H2O", resolving_power=100)
>>> result = cross_correlate_template(spec, wl_t, depth_t)
>>> print(f"H2O peak at {result['peak_velocity']:.1f} km/s, "
...       f"significance={result['significance']:.1f}σ")