oinj = np.copy(injdata) flarelcinj = bf.Lightcurve() flarelcinj.clc = np.copy(oinj) flarelcinj.cts = np.copy(ts) flarelcinj.cle = np.zeros(len(ts)) flarelcinj.cadence = 'long' flarelc.clc = flarelc.clc + injdata if opts.onoise: noiseest = opts.noisemethod tmpcurve = copy(flarelc) tmpcurve.detrend(opts.bglen, opts.bgorder) if noiseest == 'powerspectrum': sig = bf.estimate_noise_ps(tmpcurve, estfrac=opts.psest)[0] elif noiseest == 'tailveto': sig = bf.estimate_noise_tv(tmpcurve.clc, sigma=opts.tvsigma)[0] else: print "Error... noise estimation method %s not recognised." % noiseest sys.exit(0) detrendedsk, f = tmpcurve.psd() # convert back to one-sided power spectral density sig = 2. * (sig**2) / flarelc.fs() # set matplotlib defaults mplparams = { \ 'text.usetex': True, # use LaTeX for all text 'axes.linewidth': 0.5, # set axes linewidths to 0.5
injdata = np.copy(Mfi.model(pdict)) if opts.oinj: if oinj != None: oinj = oinj + injdata else: oinj = np.copy(injdata) flarelc.clc = flarelc.clc + injdata # output different noise estimates noiseest = opts.noisemethod tmpcurve = copy(flarelc) tmpcurve.detrend(method='savitzkygolay', nbins=bglen, order=bgorder) if noiseest == 'powerspectrum': sig = bf.estimate_noise_ps(tmpcurve, estfrac=opts.psest)[0] elif noiseest == 'tailveto': sig = bf.estimate_noise_tv(tmpcurve.clc, sigma=opts.tvsigma)[0] else: print "Error... noise estimation method %s not recognised." % noiseest sys.exit(0) print "Noise estimate with '%s' method = %f" % (noiseest, sig) if not opts.lconly: # get the odds ratio Or = bf.OddsRatioDetector( flarelc, bglen=bglen, bgorder=bgorder, nsinusoids=nsinusoids, noiseestmethod=noiseest,
segodds = [] # odds ratios for all above threshold segments segtimes = [] # times of all above threshold segments segidxs = [] # indices of all above threshold segments for (starts, ends) in flarelist: sidxs = np.arange(starts, ends) segidxs.append(sidxs.tolist()) segtimes.append(ts[sidxs].tolist()) segodds.append(np.copy(lnO)[sidxs].tolist()) # get the noise estimate tmpcurve = copy(flarelc) tmpcurve.detrend(method='savitzkygolay', nbins=odds.bglen, order=odds.bgorder) if odds.noiseestmethod == 'powerspectrum': sk = bf.estimate_noise_ps(tmpcurve, estfrac=odds.psestfrac)[0] elif odds.noiseestmethod == 'tailveto': sk = bf.estimate_noise_tv(tmpcurve.clc, sigma=odds.tvsigma)[0] else: print "Error... Noise estimation method must be 'powerspectrum' or 'tailveto'" sys.exit(0) datadict = { "Kepler ID": kids[i]["kepid"], "No. flares": Nflares, "Teff": kids[i]["teff"], "log(g)": kids[i]["logg"], "Max. odds ratios": maxL, "Max. indices": maxIdx, "Max. times": maxT, "Segment odds ratios": segodds,
maxT.append(ts[maxidx]) # time of maximum segodds = [] # odds ratios for all above threshold segments segtimes = [] # times of all above threshold segments segidxs = [] # indices of all above threshold segments for (starts, ends) in flarelist: sidxs = np.arange(starts, ends) segidxs.append(sidxs.tolist()) segtimes.append(ts[sidxs].tolist()) segodds.append(np.copy(lnO)[sidxs].tolist()) # get the noise estimate tmpcurve = copy(flarelc) tmpcurve.detrend(method='savitzkygolay', odds.bglen, odds.bgorder) if odds.noiseestmethod == 'powerspectrum': sk = bf.estimate_noise_ps(tmpcurve, estfrac=odds.psestfrac)[0] elif odds.noiseestmethod == 'tailveto': sk = bf.estimate_noise_tv(tmpcurve.clc, sigma=odds.tvsigma)[0] else: print "Error... Noise estimation method must be 'powerspectrum' or 'tailveto'" sys.exit(0) datadict = { "Kepler ID": kids[i]["kepid"], "No. flares": Nflares, "Teff": kids[i]["teff"], "log(g)": kids[i]["logg"], "Max. odds ratios": maxL, "Max. indices": maxIdx, "Max. times": maxT, "Segment odds ratios": segodds,