modifinder.Spectrum.keep_top_k

Spectrum.keep_top_k(k: int = 100, change_self: bool = True)[source]

Keep only the top k peaks in the Spectrum object.

Parameters:
  • k (int, default is 100) – The number of peaks to keep.

  • change_self (bool, default is True) – If True, only the top k peaks will be kept in place. If False, a new Spectrum object with only the top k peaks will be returned.

Returns:

  • map from old index to new index – If change_self is True, only the top k peaks will be kept in place and a map from the old index to the new index will be returned.

  • (Spectrum, map from old index to new index) – A new Spectrum object with only the top k peaks and a map from the old index to the new index.