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"],
|
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)
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user