def plotTpfCadenceDiagnostic(index, fits, hdr): mp.clf() mp.subplot(221) cube = tpf.getTargetPixelArrayFromFits(fits, hdr, 'RAW_CNTS') #Missing values in raw counts are set to -1. #We want them set to NaN, like everything else idx = cube[index, :, :] < 0 cube[index, idx] = np.nan plotCadence(cube[index, :, :], hdr) mp.title('Raw Counts') mp.colorbar() mp.subplot(222) cube = tpf.getTargetPixelArrayFromFits(fits, hdr, 'FLUX') plotCadence(cube[index, :, :], hdr) mp.title('Flux (e/s)') mp.colorbar() mp.subplot(223) cube = tpf.getTargetPixelArrayFromFits(fits, hdr, 'COSMIC_RAYS') plotCadence(cube[index, :, :], hdr) mp.title('Cosmic Rays (e/s)') mp.colorbar() mp.subplot(224) cube = tpf.getTargetPixelArrayFromFits(fits, hdr, 'FLUX_BKG') plotCadence(cube[index, :, :], hdr) mp.title('Background (e/s)') mp.colorbar()
def plotTpfCadenceDiagnostic(index, fits, hdr): mp.clf() mp.subplot(221) cube = tpf.getTargetPixelArrayFromFits(fits, hdr, 'RAW_CNTS') #Missing values in raw counts are set to -1. #We want them set to NaN, like everything else idx = cube[index, :,:] < 0 cube[index, idx] = np.nan plotCadence(cube[index,:,:], hdr) mp.title('Raw Counts') mp.colorbar() mp.subplot(222) cube = tpf.getTargetPixelArrayFromFits(fits, hdr, 'FLUX') plotCadence(cube[index,:,:], hdr) mp.title('Flux (e/s)') mp.colorbar() mp.subplot(223) cube = tpf.getTargetPixelArrayFromFits(fits, hdr, 'COSMIC_RAYS') plotCadence(cube[index,:,:], hdr) mp.title('Cosmic Rays (e/s)') mp.colorbar() mp.subplot(224) cube = tpf.getTargetPixelArrayFromFits(fits, hdr, 'FLUX_BKG') plotCadence(cube[index,:,:], hdr) mp.title('Background (e/s)') mp.colorbar()
def example(): # ticid = 307210830 sector = 2 camera = 4 ccd = 3 path = '/home/fergal/data/tess/hlsp_tess-data-alerts_tess_phot_00307210830-s02_tess_v1_tp.fits' fits, hdr = pyfits.getdata(path, header=True) cube = dtpf.getTargetPixelArrayFromFits(fits, hdr) img = cube[100] idx = np.isfinite(img) img[~idx] = 0 prfObj = prf.TessPrf("/home/fergal/data/tess/prf/v2") bbox = getBoundingBoxForImage(img, hdr) res = fitPrfCentroidForImage(img, ccd, camera, sector, bbox, prfObj) #The fit fails terribly, so adjusting reported col/row position #to make the result look better cosmetically. res.x[0] += .5 res.x[1] += 1.0 plotCentroidFitDiagnostic(img, hdr, ccd, camera, sector, res, prfObj) return res
def main(tic, sector, period_days, epoch_btjd, duration_days, outpattern): path = '/Users/vkostov/Desktop/Ideas_etc/DAVE_test/data/hlsp_tess-data-alerts_tess_phot_%011i-s%02i_tess_v1_tp.fits' path = path % (tic, sector) fits, hdr = pyfits.getdata(path, header=True) cube = ktpf.getTargetPixelArrayFromFits(fits, hdr) cube = cube[:, 3:9, 2:8] time = fits['TIME'] isnan = np.isnan(time) time = time[~isnan] cube = cube[~isnan] transits = getIngressEgressCadences(time, period_days, epoch_btjd, duration_days) with open('%s.cent.txt' % (outpattern), 'w') as fp: for i in range(len(transits)): print("Transit %i" % (i)) cin = transits[i] res = measureCentroidShift(cube, cin, True) plt.suptitle('%s-trans%02i' % (outpattern, i)) plt.savefig('%s-trans%02i.png' % (outpattern, i)) pattern = "%.6f " * len(res) pattern = pattern + "\n" fp.write(pattern % tuple(res))
def exampleFitting(): kepid = 8554498 quarter = 16 ar = mastio.KeplerArchive() fits, hdr = ar.getLongTpf(kepid, quarter, header=True) hdr0 = ar.getLongTpf(kepid, quarter, ext=0) cube = tpf.getTargetPixelArrayFromFits(fits, hdr) module = hdr0['MODULE'] output = hdr0['OUTPUT'] img = cube[100] idx = np.isfinite(img) img[~idx] = 0 prfObj = prf.KeplerPrf("/home/fergal/data/keplerprf") bbox = getBoundingBoxForImage(img, hdr) res = fitPrfCentroidForImage(img, module, output, bbox, prfObj) plotCentroidFitDiagnostic(img, hdr, module, output, res, prfObj) return res
def loadMultipleDetrendings(epic, campaign, dataStorePath, detrendTypes): #Definition of the different kinds of detrendings and how to #parse the output of their archive class dTypeDict = dict() dTypeDict['PDC'] = (mastio.K2Archive(), pdcParser, "PDC") dTypeDict['AGP'] = (mastio.K2SCArchive(), agpParser, "K2SC") dTypeDict['EVEREST'] = (mastio.EverestArchive(), everestParser, "Everest") dTypeDict['SFF'] = (mastio.VanderburgArchive(), sffParser, "Vanderburg SFF") out = dpc.Clipboard() #Load the TPF data cube ar = mastio.K2Archive(dataStorePath) fits, hdr = ar.getLongTpf(epic, campaign, header=True, mmap=False) hdr0 = ar.getLongTpf(epic, campaign, ext=0, mmap=False) cube = tpf.getTargetPixelArrayFromFits(fits, hdr) out['time'] = fits['TIME'] out['cube'] = cube out['tpfHeader'] = hdr out['tpfHeader0'] = hdr0 #Load PA data fits = ar.getLongCadence(epic, campaign) out['rawFlux'] = fits['SAP_FLUX'] #Load lightcurves from a specific detrending, and replace #the pdc time series with the new detrending nDetrend = 0 for i, dType in enumerate(detrendTypes): key = dType.upper() if key not in dTypeDict: raise IOError("Unrecognised detrended %s" %(key)) ar, parser, label = dTypeDict[key] data = ar.getLongCadence(epic, campaign) flux = parser(out['time'], data) typeName = "type%i" %(i+1) out[typeName] = key fluxName = "flux%i" %(i+1) out[fluxName] = flux labelName = "label%i" %(i+1) out[labelName] = label nDetrend += 1 out['numDetrendings'] = nDetrend #Enforce contract out['flux1'] out['label1'] out['cube'] return out
def loadMultipleDetrendings(epic, campaign, dataStorePath, detrendTypes): #Definition of the different kinds of detrendings and how to #parse the output of their archive class dTypeDict = dict() dTypeDict['PDC'] = (mastio.K2Archive(), pdcParser, "PDC") dTypeDict['AGP'] = (mastio.K2SCArchive(), agpParser, "K2SC") dTypeDict['EVEREST'] = (mastio.EverestArchive(), everestParser, "Everest") dTypeDict['SFF'] = (mastio.VanderburgArchive(), sffParser, "Vanderburg SFF") out = dpc.Clipboard() #Load the TPF data cube ar = mastio.K2Archive(dataStorePath) fits, hdr = ar.getLongTpf(epic, campaign, header=True, mmap=False) hdr0 = ar.getLongTpf(epic, campaign, ext=0, mmap=False) cube = tpf.getTargetPixelArrayFromFits(fits, hdr) out['time'] = fits['TIME'] out['cube'] = cube out['tpfHeader'] = hdr out['tpfHeader0'] = hdr0 #Load PA data fits = ar.getLongCadence(epic, campaign) out['rawFlux'] = fits['SAP_FLUX'] #Load lightcurves from a specific detrending, and replace #the pdc time series with the new detrending nDetrend = 0 for i, dType in enumerate(detrendTypes): key = dType.upper() if key not in dTypeDict: raise IOError("Unrecognised detrended %s" % (key)) ar, parser, label = dTypeDict[key] data = ar.getLongCadence(epic, campaign) flux = parser(out['time'], data) typeName = "type%i" % (i + 1) out[typeName] = key fluxName = "flux%i" % (i + 1) out[fluxName] = flux labelName = "label%i" % (i + 1) out[labelName] = label nDetrend += 1 out['numDetrendings'] = nDetrend #Enforce contract out['flux1'] out['label1'] out['cube'] return out
def getData(epic, campaign): ar = mastio.K2Archive() fits, hdr = ar.getLongTpf(epic, campaign, header=True) cube = tpf.getTargetPixelArrayFromFits(fits, hdr) # get the thruster firing indeces q = fits['QUALITY'].astype(np.uint32) idx1 = q & kplrfits.SapQuality['DefiniteRollTweak'] idx2 = q & kplrfits.SapQuality['MomDump'] idx3 = idx1 + idx2 return cube, idx3
def getData(epic, campaign): ar = mastio.K2Archive() fits, hdr = ar.getLongTpf(epic, campaign, header=True) cube = tpf.getTargetPixelArrayFromFits(fits, hdr) # get the thruster firing indeces q = fits["QUALITY"].astype(np.uint32) idx1 = q & kplrfits.SapQuality["DefiniteRollTweak"] idx2 = q & kplrfits.SapQuality["MomDump"] idx3 = idx1 + idx2 return cube, idx3
def show(): path = '/Users/vkostov/Desktop/Ideas_etc/DAVE_test/data/hlsp_tess-data-alerts_tess_phot_00307210830-s02_tess_v1_tp.fits' fits, hdr = pyfits.getdata(path, header=True) cube = ktpf.getTargetPixelArrayFromFits(fits, hdr) for i in range(1000, 1002): plt.clf() mn = np.fabs(np.min(cube[i, :, :])) + 1 plt.imshow(np.log10(cube[i, :, :]), origin="bottom") # plt.imshow(cube[i,:,:], origin="bottom", cmap=plt.cm.bone) # plt.clim(-20, 100) plt.colorbar() plt.title(i) plt.pause(1)
def fitKepler(): """Fit some Kepler data as an example""" kepid = 8311864 quarter = 6 ar = kmastio.KeplerArchive() fits, hdr = ar.getLongTpf(kepid, quarter, header=True) cube = ktpf.getTargetPixelArrayFromFits(fits, hdr) out = [] for i in range(200, 201): print("Image %i" % (i)) img = cube[i, :, :] nr, nc = img.shape func = psffit.gaussianWithConstantSkyPsf guess = (3.0, 1.8, .41, 3e4, -2000) soln = psffit.fitPrf(img, func, guess) print(soln) out.append(soln.x) plt.clf() model = psffit.computeModel(nc, nr, func, soln.x) plt.subplot(131) plt.title("Data") plt.imshow(np.log10(img), origin='bottom') plt.colorbar() plt.subplot(132) plt.title("Model") plt.imshow(model, origin='bottom') plt.colorbar() plt.subplot(133) plt.title("Diff") plt.imshow(img - model, origin='bottom') plt.colorbar() plt.suptitle("%i Q%i RIN %i" % (kepid, quarter, i)) plt.savefig('k%i-Q%i-R%i.png' % (kepid, quarter, i)) plt.pause(.1) out = np.array(out)
def testSmoke(): import dave.fileio.pyfits as pyfits import dave.fileio.tpf as tpf tic = 307210830 sector = 2 period_days = 3.69061 epoch_btjd = 1356.2038 duration_days = 1.2676 / 24. path = '/home/fergal/data/tess/hlsp_tess-data-alerts_tess_phot_%011i-s%02i_tess_v1_tp.fits' path = path % (tic, sector) fits, hdr = pyfits.getdata(path, header=True) time = fits['TIME'] cube = tpf.getTargetPixelArrayFromFits(fits, hdr) cube = cube[:, 3:9, 2:8] measurePerTransitCentroids(time, cube, period_days, epoch_btjd, duration_days, "tmp")
def exampleDiffImgCentroiding(): k2id = 206103150 campaign = 3 ar = mastio.K2Archive() fits, hdr = ar.getLongTpf(k2id, campaign, header=True) hdr0 = ar.getLongTpf(k2id, campaign, ext=0) cube = tpf.getTargetPixelArrayFromFits(fits, hdr) idx = np.isfinite(cube) cube[~idx] = 0 #Remove Nans flags = fits['QUALITY'] ccdMod = hdr0['module'] ccdOut = hdr0['output'] #Compute roll phase llc = ar.getLongCadence(k2id, campaign) time= llc['TIME'] cent1 = llc['MOM_CENTR1'] cent2 = llc['MOM_CENTR2'] centColRow = np.vstack((cent1, cent2)).transpose() rot = arclen.computeArcLength(centColRow, flags>0) rollPhase = rot[:,0] rollPhase[flags>0] = -9999 #A bad value prfObj = prf.KeplerPrf("/home/fergal/data/keplerprf") bbox = getBoundingBoxForImage(cube[0], hdr) period = 4.1591409 epoch = fits['time'][491] dur = 3.0 out, log = measureDiffOffset(period, epoch, dur, time, prfObj, \ ccdMod, ccdOut, cube, bbox, rollPhase, flags) idx = out[:,1] > 0 mp.clf() mp.plot(out[:,3]-out[:,1], out[:,4]- out[:,2], 'ro') return out
def exampleDiffImgCentroiding(): k2id = 206103150 campaign = 3 ar = mastio.K2Archive() fits, hdr = ar.getLongTpf(k2id, campaign, header=True) hdr0 = ar.getLongTpf(k2id, campaign, ext=0) cube = tpf.getTargetPixelArrayFromFits(fits, hdr) idx = np.isfinite(cube) cube[~idx] = 0 #Remove Nans flags = fits['QUALITY'] ccdMod = hdr0['module'] ccdOut = hdr0['output'] #Compute roll phase llc = ar.getLongCadence(k2id, campaign) time = llc['TIME'] cent1 = llc['MOM_CENTR1'] cent2 = llc['MOM_CENTR2'] centColRow = np.vstack((cent1, cent2)).transpose() rot = arclen.computeArcLength(centColRow, flags > 0) rollPhase = rot[:, 0] rollPhase[flags > 0] = -9999 #A bad value prfObj = prf.KeplerPrf("/home/fergal/data/keplerprf") bbox = getBoundingBoxForImage(cube[0], hdr) period = 4.1591409 epoch = fits['time'][491] dur = 3.0 out, log = measureDiffOffset(period, epoch, dur, time, prfObj, \ ccdMod, ccdOut, cube, bbox, rollPhase, flags) idx = out[:, 1] > 0 mp.clf() mp.plot(out[:, 3] - out[:, 1], out[:, 4] - out[:, 2], 'ro') return out
def exampleFitting(): kepid = 8554498 quarter = 16 ar = mastio.KeplerArchive() fits, hdr = ar.getLongTpf(kepid, quarter, header=True) hdr0 = ar.getLongTpf(kepid, quarter, ext=0) cube = tpf.getTargetPixelArrayFromFits(fits, hdr) module = hdr0['MODULE'] output = hdr0['OUTPUT'] img = cube[100] idx = np.isfinite(img) img[~idx] = 0 prfObj = prf.KeplerPrf("/home/fergal/data/keplerprf") bbox = getBoundingBoxForImage(img, hdr) res = fitPrfCentroidForImage(img, module, output, bbox, prfObj) plotCentroidFitDiagnostic(img, hdr, module, output, res, prfObj) return res
def getData(epic, campaign): """Obtains the data for the star For a particular star, this obtains its pixel time series data cube as well as time points which may be bad due to thruster firings. Inputs: ---------- epic (int) The k2 epic number for the desired star campaign (int) The k2 campaign for the desired star Returns: ------------ cube (3d numpy array) The k2 pixel time series data for the star with dimensions (time, number of rows per cadence, number of columns per cadence) badIdx (1d boolean numpy array) Boolean array with true corresponding to a bad time point due to thruster firings """ ar = mastio.K2Archive() fits, hdr = ar.getLongTpf(epic, campaign, header=True) cube = tpf.getTargetPixelArrayFromFits(fits, hdr) # get the thruster firing indeces q = fits['QUALITY'].astype(np.uint32) rollTweakIdx = q & kplrfits.SapQuality['DefiniteRollTweak'] momDumpIdx = q & kplrfits.SapQuality['MomDump'] badIdx = rollTweakIdx | momDumpIdx badIdx = badIdx.astype(bool) return cube, badIdx
def getData(epic, campaign): """Obtains the data for the star For a particular star, this obtains its pixel time series data cube as well as time points which may be bad due to thruster firings. Inputs: ---------- epic (int) The k2 epic number for the desired star campaign (int) The k2 campaign for the desired star Returns: ------------ cube (3d numpy array) The k2 pixel time series data for the star with dimensions (time, number of rows per cadence, number of columns per cadence) badIdx (1d boolean numpy array) Boolean array with true corresponding to a bad time point due to thruster firings """ ar = mastio.K2Archive() fits, hdr = ar.getLongTpf(epic, campaign, header=True) cube = tpf.getTargetPixelArrayFromFits(fits, hdr) # get the thruster firing indeces q = fits['QUALITY'].astype(np.uint32) rollTweakIdx = q & kplrfits.SapQuality['DefiniteRollTweak'] momDumpIdx = q & kplrfits.SapQuality['MomDump'] badIdx = rollTweakIdx | momDumpIdx badIdx = badIdx.astype(bool) return cube, badIdx
def example(): ar = mastio.K2Archive() kepid = 206103150 #A wasp planet fits = ar.getLongCadence(kepid, 3) flags = fits['SAP_QUALITY'] cent1 = fits['MOM_CENTR1'] cent2 = fits['MOM_CENTR2'] fits, hdr = ar.getLongTpf(kepid, 3, header=True) cube = tpf.getTargetPixelArrayFromFits(fits, hdr) # cube *= gain #Compute roll phase centColRow = np.vstack((cent1, cent2)).transpose() rot = arclen.computeArcLength(centColRow, flags > 0) rollPhase = rot[:, 0] rollPhase[flags > 0] = -9999 #A bad value cadenceInTransit = 490 diff, oot = constructK2DifferenceImage(cube, cadenceInTransit, rollPhase, flags) return diff, oot
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
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
def serveTask(clip): source_ = clip['config.detrendType'] sector = clip['config.sector'] tic = clip['config.tic'] planNum = clip['config.planetNum'] localPath = clip['config.dvtLocalPath'] if source_ == "tess": dvt, hdr, tpf_, hdr_tpf = tessfunc.serve(sector, tic, planNum, localPath) cube = tpf.getTargetPixelArrayFromFits(tpf_, hdr_tpf) out = dict() out['time'] = dvt['TIME'] out['cube'] = cube out['tpfHeader'] = hdr_tpf out['detrendFlux'] = dvt['LC_DETREND'] out['flags'] = np.isnan(dvt['LC_DETREND']) out['modelFlux'] = dvt['MODEL_INIT'] par = dict() par['orbitalPeriod_days'] = clip['config.period']#hdr['TPERIOD'] par['epoch_btjd'] = clip['config.tepoch']#hdr['TEPOCH'] par['transitDepth_ppm'] = clip['config.tdepth']#hdr['TDEPTH'] par['transitDuration_hrs'] = clip['config.tdur']#hdr['TDUR'] clip['serve'] = out clip['serve.param'] = par #Enforce contract clip['serve.time'] clip['serve.cube'] clip['serve.detrendFlux'] clip['serve.flags'] clip['serve.modelFlux'] clip['serve.param.orbitalPeriod_days'] clip['serve.param.epoch_btjd'] clip['serve.param.transitDepth_ppm'] clip['serve.param.transitDuration_hrs'] out = dict() out['flux_frac'] = dvt['LC_DETREND'] out['flags'] = np.isnan(dvt['LC_DETREND']) clip['detrend'] = out clip['detrend.flux_frac'] clip['detrend.flags'] out = dict() out['period'] = clip['config.period']#hdr['TPERIOD'] out['epoch'] = clip['config.tepoch']#hdr['TEPOCH'] clip['bls'] = out clip['bls.period'] clip['bls.epoch'] out = dict() out['time'] = dvt['TIME'] out['rawLightcurve'] = dvt['LC_DETREND'] clip['extract'] = out clip['extract.time'] clip['extract.rawLightcurve'] elif source_ == "eleanor": prefix, suffix = "hlsp_eleanor_tess_ffi_tic", "_s01_tess_v0.1.8_lc.fits" fits_fn = "%s%i%s" %(prefix, int(tic), suffix) fits_fn = os.path.join(localPath, fits_fn) hdu = fits.open(fits_fn) # print(hdu[1].columns) # header_ = hdu[0].header#hdu[1].header out = dict() out['tpfHeader'] = hdu[0].header out['cube'] = hdu[1].data['TPF'] out['time'] = hdu[1].data['TIME']# - min(hdu[1].data['TIME']) out['detrendFlux'] = (hdu[1].data['PSF_FLUX']/np.nanmedian(hdu[1].data['PSF_FLUX'])) - 1. flags_ = np.isfinite(hdu[1].data['PSF_FLUX']) flags_[hdu[1].data['QUALITY'] == 0] = False out['flags'] = flags_ par = dict() par['orbitalPeriod_days'] = clip['config.period'] par['epoch_btjd'] = clip['config.tepoch'] par['transitDepth_ppm'] = clip['config.tdepth'] par['transitDuration_hrs'] = clip['config.tdur'] clip['serve'] = out clip['serve.param'] = par #Enforce contract clip['serve.time'] clip['serve.cube'] clip['serve.detrendFlux'] clip['serve.flags'] clip['serve.param.orbitalPeriod_days'] clip['serve.param.epoch_btjd'] clip['serve.param.transitDepth_ppm'] clip['serve.param.transitDuration_hrs'] out = dict() out['period'] = clip['config.period'] out['epoch'] = clip['config.tepoch'] clip['bls'] = out clip['bls.period'] clip['bls.epoch'] out = dict() out['time'] = hdu[1].data['TIME']# - min(hdu[1].data['TIME']) out['rawLightcurve'] = (hdu[1].data['RAW_FLUX']/np.nanmedian(hdu[1].data['RAW_FLUX'])) - 1. clip['extract'] = out clip['extract.time'] clip['extract.rawLightcurve'] return clip