flaredetector: flares need to have a certain duration
either have 1 point before and after the peak above a threshold or have 2 points after the peak above a threhold
This commit is contained in:
@@ -18,8 +18,18 @@ def moveFluxForFit(curPeakIndex, flux):
|
|||||||
Peak = flux[curPeakIndex] - 1
|
Peak = flux[curPeakIndex] - 1
|
||||||
return flarePoints, flareFitDataPoints, Peak
|
return flarePoints, flareFitDataPoints, Peak
|
||||||
|
|
||||||
|
def isValidFlarePoint(flareData):
|
||||||
|
threshold = 0.005
|
||||||
|
peakIndex = np.argmax(flareData)
|
||||||
|
if((flareData[peakIndex-1] > threshold and flareData[peakIndex+1] > threshold) or
|
||||||
|
(flareData[peakIndex+1] > threshold and flareData[peakIndex+2] > threshold)):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def calculateFitForFlare(lightcurve, peakIndex):
|
def calculateFitForFlare(lightcurve, peakIndex):
|
||||||
flarePoints, flareFitDataPoints, Peak = moveFluxForFit(peakIndex, lightcurve.flux)
|
flarePoints, flareFitDataPoints, Peak = moveFluxForFit(peakIndex, lightcurve.flux)
|
||||||
|
if(not isValidFlarePoint(lightcurve.flux[flarePoints]-1)):
|
||||||
|
raise Exception("Flare not valid: not enough datapoints above mean")
|
||||||
popt, pcov = curve_fit(lambda x, l, w: GaussExpo(x, Peak, l, w), flareFitDataPoints, lightcurve.flux[flarePoints]-1)
|
popt, pcov = curve_fit(lambda x, l, w: GaussExpo(x, Peak, l, w), flareFitDataPoints, lightcurve.flux[flarePoints]-1)
|
||||||
fit = GaussExpo(flareFitDataPoints, Peak, *popt)
|
fit = GaussExpo(flareFitDataPoints, Peak, *popt)
|
||||||
flareFitDataPoints = flareFitDataPoints + peakIndex
|
flareFitDataPoints = flareFitDataPoints + peakIndex
|
||||||
|
|||||||
Reference in New Issue
Block a user