From f2a7cc08dc53251bb42fefaa1e2f0993d259d247 Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Mon, 15 Apr 2024 15:04:51 +0200 Subject: [PATCH] flaredetector: util: add argument if peaks should be sorted or not by highest --- main/flaredetector/util.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main/flaredetector/util.py b/main/flaredetector/util.py index 72a730a..2735594 100644 --- a/main/flaredetector/util.py +++ b/main/flaredetector/util.py @@ -4,7 +4,7 @@ from scipy.signal import find_peaks from lightkurve.periodogram import Periodogram from lightkurve.lightcurve import LightCurve -def findMaxIndices(lc, num=3, distance=100, height=(None, None)): +def findMaxIndices(lc, num=3, distance=100, height=(None, None), sortByHighest=False): if(isinstance(lc, Periodogram)): data = lc.power elif(isinstance(lc, LightCurve)): @@ -14,5 +14,7 @@ def findMaxIndices(lc, num=3, distance=100, height=(None, None)): peak_indices, peak_dict = find_peaks(data, height=height, distance=distance) peak_heights = peak_dict["peak_heights"] - maxIndices = peak_indices[np.argsort(peak_heights)[-num:][::-1]] - return maxIndices \ No newline at end of file + if(sortByHighest): + return peak_indices[np.argsort(peak_heights)[-num:][::-1]] + else: + return peak_indices[0:num] \ No newline at end of file