flaredetector: make sure to only use valid flares

flattening can sometimes invert tips in the lightcurve to cause
a false detection of a flare
This commit is contained in:
2024-11-14 13:35:12 +01:00
parent d005102a09
commit 09902a70e8
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -210,7 +210,7 @@ class FlaredetectorWidget(QtWidgets.QWidget):
self.currentFlattenLC = lc.flatten(window_length=self.FlattenState["WindowLength"], self.currentFlattenLC = lc.flatten(window_length=self.FlattenState["WindowLength"],
polyorder=self.FlattenState["PolynomialOrder"]) polyorder=self.FlattenState["PolynomialOrder"])
self.foldedLC = lc.to_periodogram(method=self.PeriodogramState["Method"]) self.foldedLC = lc.to_periodogram(method=self.PeriodogramState["Method"])
self.peaks, self.fits = calculateFlareFitsForLightcurve(self.currentFlattenLC, num=100) self.peaks, self.fits = calculateFlareFitsForLightcurve(self.currentFlattenLC, num=100, normalizedLC=self.currentLC.normalize())
self.periods = [self.foldedLC.period[i] for i in findMaxIndices(self.foldedLC, num=4, distance=100, sortByHighest=True)] self.periods = [self.foldedLC.period[i] for i in findMaxIndices(self.foldedLC, num=4, distance=100, sortByHighest=True)]
self.epoch_time = getEpochTime(lc) self.epoch_time = getEpochTime(lc)
self.periodsCalculated.emit(self.periods) self.periodsCalculated.emit(self.periods)
+4 -1
View File
@@ -47,7 +47,7 @@ def calculateFitForFlare(lightcurve, peakIndex):
flareFitDataPoints = flareFitDataPoints + peakIndex flareFitDataPoints = flareFitDataPoints + peakIndex
return np.array(Peak+1), flareFitDataPoints, np.array(fit+1) return np.array(Peak+1), flareFitDataPoints, np.array(fit+1)
def calculateFlareFitsForLightcurve(lightcurve, num=100, distance=1, height=0.05): def calculateFlareFitsForLightcurve(lightcurve, num=100, distance=1, height=0.05, normalizedLC=None):
maxIndices = findMaxIndices(lightcurve, num, distance=distance, height=height, maxIndices = findMaxIndices(lightcurve, num, distance=distance, height=height,
sortByHighest=True) sortByHighest=True)
peaks = [] peaks = []
@@ -55,6 +55,9 @@ def calculateFlareFitsForLightcurve(lightcurve, num=100, distance=1, height=0.05
for index in maxIndices: for index in maxIndices:
try: try:
Peak, flareFitDataPoints, fit = calculateFitForFlare(lightcurve, index) Peak, flareFitDataPoints, fit = calculateFitForFlare(lightcurve, index)
if(normalizedLC is not None and
(normalizedLC.flux[index] < 0.95 or Peak > 1.5 * normalizedLC.flux[index])):
continue
peaks.append({"FlarePeak": Peak, peaks.append({"FlarePeak": Peak,
"FlarePeakTime": lightcurve.time[index], "FlarePeakTime": lightcurve.time[index],
"StandardIndex": index, "StandardIndex": index,