matchms.filtering.peak_processing.normalize_intensities module

matchms.filtering.peak_processing.normalize_intensities.normalize_intensities(spectrum_in: Spectrum, clone: bool | None = True, scale_to_max: float = 1.0) Spectrum | None

Normalize peak intensities relative to the maximum peak intensity.

Intensities are divided by the maximum intensity of the spectrum and then multiplied by scale_to_max. By default, this normalizes spectra to unit height, i.e. the most intense peak receives intensity 1.0.

Peaks with zero intensity are removed. Negative peak intensities are not allowed and raise a ValueError.

Parameters:
  • spectrum_in – Input spectrum.

  • clone – Optionally clone the Spectrum.

  • scale_to_max – Desired intensity of the most intense peak after normalization. Default is 1.0. For example, scale_to_max=1000.0 scales the base peak to intensity 1000.

Returns:

Spectrum with normalized intensities, or None if input is None.

Return type:

Spectrum or None