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)
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)
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")
def countThermFlags(clip): thermal=dict() #Create the light curves. clip['config']['dataStorePath']='/home/smullall/Science/datastore' clip=pipe.serveTask(clip) clip=pipe.trapezoidFitTask(clip) #Get just the interesting flags thruster=2**20; safemode=2**1; desat=2**5 isbad=np.bitwise_and(clip.serve.flags,thruster+safemode+desat) != 0 thermal['isBad'] = isbad time=clip.serve.time period=clip.trapFit.period_days epoch=clip.trapFit.epoch_bkjd #phi = np.fmod(time-epoch + .25*period, period) phiorig = (time-epoch + .25*period) % period phi = phiorig[np.isfinite(phiorig)] dur=clip.trapFit.duration_hrs/24; #Calculate the phase range of the folded transit model. phi1=0.25*period - 0.5*dur; phi2=0.25*period + 0.5*dur; thermal['phimin']=phi1; thermal['phimax']=phi2; thermal['inTransCadTot'] = len( phi[[phi>phi1] and [phi<phi2]] ) #How many isbads exist in that phase range. phiisbad=phiorig[isbad] countBad=0 for (i,v) in enumerate(phiisbad): if v > phi1 and v< phi2: countBad=countBad+1 thermal['inTransCadBad'] = countBad thermal['numTrans']=np.floor((time[-1]-time[0])/period) clip['thermal']=thermal return clip
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()
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
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