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:
@@ -210,7 +210,7 @@ class FlaredetectorWidget(QtWidgets.QWidget):
|
||||
self.currentFlattenLC = lc.flatten(window_length=self.FlattenState["WindowLength"],
|
||||
polyorder=self.FlattenState["PolynomialOrder"])
|
||||
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.epoch_time = getEpochTime(lc)
|
||||
self.periodsCalculated.emit(self.periods)
|
||||
|
||||
@@ -47,7 +47,7 @@ def calculateFitForFlare(lightcurve, peakIndex):
|
||||
flareFitDataPoints = flareFitDataPoints + peakIndex
|
||||
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,
|
||||
sortByHighest=True)
|
||||
peaks = []
|
||||
@@ -55,6 +55,9 @@ def calculateFlareFitsForLightcurve(lightcurve, num=100, distance=1, height=0.05
|
||||
for index in maxIndices:
|
||||
try:
|
||||
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,
|
||||
"FlarePeakTime": lightcurve.time[index],
|
||||
"StandardIndex": index,
|
||||
|
||||
Reference in New Issue
Block a user