From b8c38762b1d7bae1db7b0f6408904e5d6cce4c2d Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Mon, 15 Apr 2024 15:19:54 +0200 Subject: [PATCH] flaredetector: add calculateFlareFitsForLightcurve this function fits all flares for a lightcurve --- main/flaredetector/flaredetector.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main/flaredetector/flaredetector.py b/main/flaredetector/flaredetector.py index 55c5e56..8c9ab07 100644 --- a/main/flaredetector/flaredetector.py +++ b/main/flaredetector/flaredetector.py @@ -22,6 +22,18 @@ def calculateFitForFlare(lightcurve, peakIndex): flareFitDataPoints = flareFitDataPoints + peakIndex return Peak+1, flareFitDataPoints, fit+1 +def calculateFlareFitsForLightcurve(lightcurve, num=100, distance=1, height=0.05): + maxIndices = findMaxIndices(lightcurve, num, distance=distance, height=height) + fits = [] + for index in maxIndices: + Peak, flareFitDataPoints, fit = calculateFitForFlare(lightcurve, index) + fits.append({"FlarePeak": Peak, + "FlarePeakTime": lightcurve.time[index], + "FlareFit": fit, + "FlareFitTime": lightcurve.time[flareFitDataPoints]}) + + return fits + def getFlareRange(flux, peakIndex): minInd = -np.inf maxInd = np.inf