bioniumx.detection.equivalent_width

bioniumx.detection.equivalent_width(spectrum: BioniumXObject, line_min: float, line_max: float, continuum: tuple | None = None)[source]

Calculate the equivalent width (EW) of a spectral absorption feature.

Equivalent width is a measure of the area of a spectral line relative to the continuum. In transmission spectroscopy, it correlates with atmospheric abundance.

Parameters:
  • spectrum (BioniumXObject) – The input spectrum (must be continuum-normalized).

  • line_min (float) – Wavelength bounds of the absorption feature (in microns).

  • line_max (float) – Wavelength bounds of the absorption feature (in microns).

  • continuum (tuple of (float, float), optional) – Wavelength bounds to compute the local continuum level. If None, assumes the spectrum is already normalized to 1.0.

Returns:

  • ew (float) – The equivalent width in microns.

  • ew_err (float) – 1-sigma uncertainty on the equivalent width.

Raises:

ValueError – If the integration range is invalid.

Notes

Mathematical derivation: .. math:

EW = \int_{\lambda_1}^{\lambda_2} \left(1 - \frac{F(\lambda)}{F_c}\right) d\lambda

Examples

>>> ew, ew_err = equivalent_width(spec_norm, 1.38, 1.42)
>>> print(f"H2O EW = {ew:.4f} ± {ew_err:.4f} μm")