Exemplo n.º 1
0
def loadClipAndCompFits(data, row):
    epic = data[row, 0]

    clip = dpc.loadClipboard("clips/c%09i-05.clip" % (epic))
    clip = pl.serveTask(clip)

    mp.figure(2)
    mp.clf()
    dpp.plotData(clip)
    mp.title('Epic %.0f' % (epic))

    mp.figure(3)
    mp.clf()
    compareFits(clip)
    mp.title('Epic %.0f' % (epic))

    mp.figure(1)

    print "**************"
    print row, epic
    print clip.bls
    flux = clip.detrend.flux_frac
    flags = clip.detrend.flags
    noi = noise.computeSgCdpp_ppm(flux[~flags]) * 1e-6
    print "BLS SNR= %.2f" % (clip.bls.depth / noi)
Exemplo n.º 2
0
def loadClipAndCompFits(data, row):
    epic = data[row, 0]

    clip = dpc.loadClipboard("clips/c%09i-05.clip" %(epic))
    clip = pl.serveTask(clip)


    mp.figure(2)
    mp.clf()
    dpp.plotData(clip)
    mp.title('Epic %.0f' %(epic))

    mp.figure(3)
    mp.clf()
    compareFits(clip)
    mp.title('Epic %.0f' %(epic))

    mp.figure(1)

    print "**************"
    print row, epic
    print clip.bls
    flux = clip.detrend.flux_frac
    flags = clip.detrend.flags
    noi = noise.computeSgCdpp_ppm(flux[~flags]) * 1e-6
    print "BLS SNR= %.2f" %(clip.bls.depth/noi)
Exemplo n.º 3
0
def loadTask(clip):
    epic = clip['value']
    debug = clip['config.debug']
    fn = "../clips/c%s-05.clip" % (epic)

    clip = dpc.loadClipboard(fn)
    clip['config.debug'] = debug
    return clip
Exemplo n.º 4
0
def display(pcList):
    for i, pc in enumerate(sorted(pcList)):
        print i, pc
        clip = dpc.loadClipboard(pc)
        clip = pl.serveTask(clip)
        displayOne(clip)

        mp.pause(1)
        raw_input("Press ENTER to continue")
Exemplo n.º 5
0
def display(pcList):
    for i, pc in enumerate(sorted(pcList)):
        print i, pc
        clip = dpc.loadClipboard(pc)
        clip = pl.serveTask(clip)
        displayOne(clip)

        mp.pause(1)
        raw_input("Press ENTER to continue")
Exemplo n.º 6
0
def getPcList():
    clipList = glob("clips/*.clip")

    pcList = []
    for filename in clipList:
        clip = dpc.loadClipboard(filename)
        try:
            isCand = clip['disposition.isCandidate']
            if isCand:
                pcList.append(filename)
        except KeyError:
            print filename, clip.exception
    return pcList
Exemplo n.º 7
0
def getPcList():
    clipList = glob("clips/*.clip")

    pcList = []
    for filename in clipList:
        clip = dpc.loadClipboard(filename)
        try:
            isCand = clip['disposition.isCandidate']
            if isCand:
                pcList.append(filename)
        except KeyError:
            print filename, clip.exception
    return pcList
Exemplo n.º 8
0
def examine():
    clipList = glob("clips/*.clip")

    for filename in clipList:
        clip = dpc.loadClipboard(filename)
        print filename,
        if 'exception' in clip.keys():
            print "Error: ", clip['exception']
        else:
            try:
                print clip['disposition.isCandidate'], \
                    clip['disposition.reasonForFail']
            except KeyError, e:
                print "Error: %s" %(e)
Exemplo n.º 9
0
def examine():
    clipList = glob("clips/*.clip")

    for filename in clipList:
        clip = dpc.loadClipboard(filename)
        print filename,
        if 'exception' in clip.keys():
            print "Error: ", clip['exception']
        else:
            try:
                print clip['disposition.isCandidate'], \
                    clip['disposition.reasonForFail']
            except KeyError, e:
                print "Error: %s" % (e)
Exemplo n.º 10
0
def skyLinePlot(clipList):
    """A plot of which cadences contribute to the most transits

    Based on similar plot created by Jessie Christiansen for the
    SOC pipeline.

    Inputs:
    -----------
    clipList
        (list) list of filenames of clips to process

    """

    epic, vals = gather.gatherFunction(clipList, getPeriodEpochDuration)

    clip = dpc.loadClipboard(clipList[0])
    clip = pl.serveTask(clip)
    time = clip['serve.time']
    flags = clip['detrend.flags']

    period = np.array(map(lambda x: x[0], vals))
    epoch = np.array(map(lambda x: x[1], vals))
    duration_days = np.array(map(lambda x: x[2], vals)) / 24.
    isCand = np.array(map(lambda x: x[3], vals))

    skyLine = time * 0
    candSkyLine = time * 0
    for i in range(len(period)):
        idx = kplrfits.markTransitCadences(time, period[i], epoch[i], \
            duration_days[i], flags=flags)
        skyLine[idx] += 1

        if isCand[i]:
            candSkyLine[idx] += 1

    mp.clf()
    mp.step(time[~flags], skyLine[~flags], 'b-', lw=2, \
        label="All targets")
    mp.step(time[~flags], candSkyLine[~flags], 'r-', lw=2, \
        label="Candidates")

    mp.xlabel("Time (BKJD)")
    mp.ylabel("Number of Transits on Cadence")
    return mp.gcf()
Exemplo n.º 11
0
def getData(fn):
    clip = dpc.loadClipboard(fn)
    clip = pl.serveTask(clip)

    out = [clip['value']]
    for k in "period epoch depth duration_hrs".split():
        key1 = "bls.%s" %(k)
        out.extend( [clip[key1]])

    #Recompute SNR
    time = clip['serve.time']
    flux = clip['detrend.flux_frac']
    flag = clip['detrend.flags']

    per = clip['bls.period']
    epc = clip['bls.epoch']
    depth_frac = clip['bls.depth']
    dur_days = clip['bls.duration_hrs']/24.

    #Try mesauring SNR assuming there is a transit and a secondary
    #we want to cut out.
    try:
        idx = kplrfits.markTransitCadences(time, per/2., epc, \
            dur_days, flags=flag)
        idx = idx | flag
        snr = estSnrForK2(flux[~idx], depth_frac, dur_days)
    except ValueError:
        #If the above results in no data points, try just excising
        #the primary
        try:
            idx = kplrfits.markTransitCadences(time, per, epc, \
                dur_days, flags=flag)
            idx = idx | flag
            snr = estSnrForK2(flux[~idx], depth_frac, dur_days)
        except ValueError:
            #Give up
            snr = -1


    out.append(snr)
    print out[0], out[-1]
    return out
Exemplo n.º 12
0
def getData(fn):
    clip = dpc.loadClipboard(fn)
    clip = pl.serveTask(clip)

    out = [clip['value']]
    for k in "period epoch depth duration_hrs".split():
        key1 = "bls.%s" % (k)
        out.extend([clip[key1]])

    #Recompute SNR
    time = clip['serve.time']
    flux = clip['detrend.flux_frac']
    flag = clip['detrend.flags']

    per = clip['bls.period']
    epc = clip['bls.epoch']
    depth_frac = clip['bls.depth']
    dur_days = clip['bls.duration_hrs'] / 24.

    #Try mesauring SNR assuming there is a transit and a secondary
    #we want to cut out.
    try:
        idx = kplrfits.markTransitCadences(time, per/2., epc, \
            dur_days, flags=flag)
        idx = idx | flag
        snr = estSnrForK2(flux[~idx], depth_frac, dur_days)
    except ValueError:
        #If the above results in no data points, try just excising
        #the primary
        try:
            idx = kplrfits.markTransitCadences(time, per, epc, \
                dur_days, flags=flag)
            idx = idx | flag
            snr = estSnrForK2(flux[~idx], depth_frac, dur_days)
        except ValueError:
            #Give up
            snr = -1

    out.append(snr)
    print out[0], out[-1]
    return out
Exemplo n.º 13
0
def runFuncOnClip(clipFilename, func):
    """Load a clipboard and apply a function to it

    Inputs:
    ----------
    clipFilename
        (string) Name of clipboard to load
    func
        (function) Function to apply. func must take one argument, a clipboard

    Returns:
    ------------
    (value, result). Value is clip['value'], result = func(clip)
    result is set to None for some errors, other errors in func() raise
    an exception
    """

    try:
        clip = dpc.loadClipboard(clipFilename)
    except IOError, e:
        print e
        return 0, None
Exemplo n.º 14
0
def runFuncOnClip(clipFilename, func):
    """Load a clipboard and apply a function to it

    Inputs:
    ----------
    clipFilename
        (string) Name of clipboard to load
    func
        (function) Function to apply. func must take one argument, a clipboard

    Returns:
    ------------
    (value, result). Value is clip['value'], result = func(clip)
    result is set to None for some errors, other errors in func() raise
    an exception
    """

    try:
        clip = dpc.loadClipboard(clipFilename)
    except IOError, e:
        print e
        return 0, None
Exemplo n.º 15
0
def writeTable(pcList):
    for fn in pcList:
        clip = dpc.loadClipboard(fn)
        exporter.exporterTask(clip)
Exemplo n.º 16
0
        clip.bls['kepmag']=rundata[acti,2]
        clip=pipe.saveClip(clip)
        n=n+1;
    except AttributeError:
        pass

#np.save('/home/sthomp/DAVE/playK2/ch42-bls.npy', bls)    
#%%
#Code to gather up the bls spectra into a 2d array belongs here.
import dave.pipeline.clipboard as cb
listdir='/home/sthomp/daveOutput/bls/list.txt'
clipnames=np.loadtxt(listdir,dtype='string')
bls=np.zeros((len(clipnames),25000))
kepmag=np.zeros((len(clipnames),1))
for i,v in enumerate(clipnames):
    c=cb.loadClipboard(v)
    bls[i,:]=c.bls.ibls;
    kepmag[i]=c.bls.kepmag;
    
idx=np.argsort(kepmag,axis=0)

#%%
    
#X, Y = np.meshgrid(periods,np.linspace(0,499,500))
Z=bls[idx[:,0],:]/np.max(bls[idx[:,0],:],axis=1, keepdims=True)
plt.clf()
plt.set_cmap('gist_earth')
isf=np.isnan(Z)
Z[isf]=0
plt.imshow(Z,extent=(0.32,2.1,len(clipnames),0),aspect="auto",interpolation='nearest')
plt.title('Channel 42  BLS Spectra')
Exemplo n.º 17
0
def writeTable(pcList):
    for fn in pcList:
        clip = dpc.loadClipboard(fn)
        exporter.exporterTask(clip)
Exemplo n.º 18
0

def getFractionThermal(clip):
    clip = countThermFlags(clip)
    if clip.thermal.numTrans >= 2:
        frac = clip.thermal.inTransCadBad / clip.thermal.numTrans
    else:
        frac = 0
    return frac


#Code to test how many thruster firings land on the transits.
#
epic = '212275451'

clip = c.loadClipboard('/soc/nfs/so-nfs/dave/c6-v2/%s/c%s-06.clip' %
                       (epic, epic))

clip = countThermFlags(clip)
print clip.thermal

#%%
isbad = clip.thermal.isBad
time = clip.serve.time
period = clip.trapFit.period_days
epoch = clip.trapFit.epoch_bkjd
bestmodel = clip.trapFit.bestFitModel
phi = (time - epoch + .25 * period) % period
dur = clip.trapFit.duration_hrs / 24

plt.figure()
plt.plot(phi[isbad], isbad[isbad] * -1 * clip.trapFit.depth_frac, 'ro')
Exemplo n.º 19
0
    return clip


def getFractionThermal(clip):
    clip=countThermFlags(clip)
    if clip.thermal.numTrans >= 2:
        frac=clip.thermal.inTransCadBad/clip.thermal.numTrans
    else:
        frac=0;
    return frac;
    
#Code to test how many thruster firings land on the transits.
#
epic='212275451'

clip=c.loadClipboard('/soc/nfs/so-nfs/dave/c6-v2/%s/c%s-06.clip' % (epic,epic))

clip=countThermFlags(clip)
print clip.thermal

#%%
isbad=clip.thermal.isBad
time=clip.serve.time
period=clip.trapFit.period_days
epoch=clip.trapFit.epoch_bkjd
bestmodel=clip.trapFit.bestFitModel
phi = (time-epoch + .25*period) % period
dur=clip.trapFit.duration_hrs/24;

plt.figure()
plt.plot(phi[isbad],isbad[isbad]*-1*clip.trapFit.depth_frac,'ro')