Example #1
0
            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
      'axes.grid': True, # add a grid
      'grid.linewidth': 0.5,
Example #2
0
            flarelc.cts = np.copy(ts)
            flarelc.cle = np.zeros(len(ts))
            flarelc.cadence = 'long'

            if dosinusoids:  # add sinusoid
                flarelc.clc = flarelc.clc + amps[i] * np.sin(
                    2. * np.pi * freqs[i] * ts + phase[i])

        #pl.plot(flarelc.cts, flarelc.clc)
        #pl.show()

        # get noise standard deviation from a detrended lightcurve
        tmpcurve = copy(flarelc)
        tmpcurve.detrend(bglen, bgorder)
        #sk = bf.estimate_noise_ps(tmpcurve, estfrac=0.5)[0] # noise standard deviation
        sk = bf.estimate_noise_tv(tmpcurve.clc, sigma=1.0)[0]
        del tmpcurve

        # set central time of the injection randomly (but not within bglen/2 of data edges)
        idxt0 = np.random.randint(int(bglen / 2), len(ts) - int(bglen / 2) - 1)
        t0 = flarelc.cts[idxt0]

        if outd:
            fparams = open(paramout,
                           'a')  # open output parameter file for appending

        # create injections
        if opts.injtransit:  # create a transit
            Mti = bf.Transit(flarelc.cts, amp=1)
            injdata = np.copy(
                Mti.model(1., sigmags[i], taufs[i], t0, flarelc.cts))