Exemple #1
0
def measureDiffImgCentroidsTask(clip):

    #Measuring centroids requires a lot of input params
    period_days = clip['trapFit.period_days']
    epoch_bkjd = clip['trapFit.epoch_bkjd']  #Check this what BLS returns
    duration_hrs = clip['trapFit.duration_hrs']

    cube = clip['serve.cube']
    cube[~np.isfinite(cube)] = 0
    tpfHeader0 = clip['serve.tpfHeader0']
    tpfHeader = clip['serve.tpfHeader']
    ccdMod = tpfHeader0['MODULE']
    ccdOut = tpfHeader0['OUTPUT']
    bbox = cent.getBoundingBoxForImage(cube[0], tpfHeader)
    rollPhase = clip['rollPhase.rollPhase']
    prfPath = clip['config.prfPath']
    prfObj = prf.KeplerPrf(prfPath)

    time_days = clip['serve.time']
    flags = clip['flags']

    #    import pdb; pdb.set_trace()
    out,log = cent.measureDiffOffset(period_days, epoch_bkjd, duration_hrs, \
        time_days, prfObj, ccdMod, ccdOut, cube, bbox, rollPhase, flags)

    #Set column names
    out = nca.Nca(out)
    out.setLookup(1, "rin intr_col intr_row diff_col diff_row".split())

    clip['diffImg'] = {'centroid_timeseries': out, 'log': log}

    clip['diffImg.centroid_timeseries']
    return clip
def createStellarNca(stellarFile):
    """
    Read in the stellar file and return a dictionary
    """
    epics=np.loadtxt(stellarFile,dtype=str,delimiter='|',usecols=[0])
    
    data=np.loadtxt(stellarFile,dtype=float,delimiter='|',usecols=np.arange(1,25))
    col='Teff|sTeff+|sTeff-|logg|slogg+|slogg-|FeH|sFeH+|sFeH-|Rad|sRad+|sRad-|Mass|sMass+|sMass-|rho|srho+|srho-|dis|dis+|dis-|ebv|ebv+|ebv-'.split('|');
    
    nameDict=dict()
    nameDict[0]=list(epics)
    nameDict[1]=col
    
    d=nca.Nca(data,nameDict)
    
    return d
Exemple #3
0
def loadTpfAndLc(k2id, campaign, ar, detrendType):
    #    ar = mastio.K2Archive(storeDir)  #Removed by SEM to generalize this function

    out = dict()
    fits, hdr = ar.getLongTpf(k2id, campaign, header=True, mmap=False)
    hdr0 = ar.getLongTpf(k2id, campaign, ext=0, mmap=False)
    cube = tpf.getTargetPixelArrayFromFits(fits, hdr)

    out['cube'] = cube
    out['tpfHeader'] = hdr
    out['tpfHeader0'] = hdr0

    fits, hdr2 = ar.getLongCadence(k2id, campaign, header=True)
    data = kplrfits.getNumpyArrayFromFitsRec(fits)
    lookup = """ TIME TIMECORR CADENCENO
                 SAP_FLUX SAP_FLUX_ERR SAP_BKG SAP_BKG_ERR
                 PDCSAP_FLUX PDCSAP_FLUX_ERR SAP_QUALITY
                 PSF_CENTR1 PSF_CENTR1_ERR PSF_CENTR2 PSF_CENTR2_ERR
                 MOM_CENTR1 MOM_CENTR1_ERR MOM_CENTR2 MOM_CENTR2_ERR
                 POS_CORR1 POS_CORR2""".split()
    data = nca.Nca(data)
    data.setLookup(1, lookup)

    #Load lightcurves from a specific detrending, and replace
    #the pdc time series with the new detrending
    key = detrendType.upper()
    if key == "PDC":
        pass

    elif key == "EVEREST":
        detrendAr = mastio.EverestArchive()
        fits2 = detrendAr.getLongCadence(k2id, campaign)
        flux = fits2['FLUX']
        assert len(flux) == len(data)
        data[:, 'PDCSAP_FLUX'] = flux

    elif key == "SFF":
        detrendAr = mastio.VanderburgArchive()
        lightcurve = detrendAr.getLongCadence(k2id, campaign)
        sffTime = lightcurve[:, 0]
        flux = lightcurve[:, 1]

        idx = mapTime2ToIndexOfTime1(data[:, 'TIME'], sffTime)
        data[idx, 'PDCSAP_FLUX'] = flux
        data[~idx, 'PDCSAP_FLUX'] = np.nan

    elif key == "AGP":
        detrendAr = mastio.K2SCArchive()
        agpFits = detrendAr.getLongCadence(k2id, campaign)
        agpTime = agpFits['time']
        agpFlux = agpFits['flux']

        idx = mapTime2ToIndexOfTime1(data[:, 'TIME'], agpTime)
        data[idx, 'PDCSAP_FLUX'] = agpFlux
        data[~idx, 'PDCSAP_FLUX'] = np.nan
    else:
        raise ValueError("Unrecognised detrending type %s" % (detrendType))

    out['time'] = fits['TIME'].copy()
    out['flags'] = fits['SAP_QUALITY'].copy()
    out['socData'] = data
    return out