def two_min_lc_download(target_ID, sector, plt_SAP = False, plt_PDCSAP = False): """ Downloads and returns SAP and PDCSAP 2-min lightcurves from MAST """ try: dec, tic = find_tic(target_ID, from_file = True) lcf = search_lightcurvefile(tic, sector = sector).download() except: table_data = Table.read('BANYAN_XI-III_combined_members.csv') i = list(table_data['main_id']).index(target_ID) ra = table_data['ra'][i] dec = table_data['dec'][i] object_coord = SkyCoord(ra, dec, unit="deg") lcf = search_lightcurvefile(object_coord, sector = sector).download() # Seperate lightcurves sap_lc = lcf.SAP_FLUX pdcsap_lc = lcf.PDCSAP_FLUX if plt_SAP == True: pdcsap_lc.scatter() plt.title('{} - 2min SAP lc'.format(target_ID)) plt.xlabel("Time - 2457000 (BTJD days)") plt.ylabel("Relative flux") plt.show() if plt_PDCSAP == True: pdcsap_lc.scatter() plt.title('{} - 2min PDCSAP lc'.format(target_ID)) plt.xlabel("Time - 2457000 (BTJD days)") plt.ylabel("Relative flux") plt.show() #lcf.close() return sap_lc, pdcsap_lc
def build(self, object_info): mission_id = object_info.mission_id() sherlock_id = object_info.sherlock_id() quarters = None sectors = None logging.info("Retrieving star catalog info...") mission, mission_prefix, id = super().parse_object_id(mission_id) if mission_prefix not in self.star_catalogs: raise ValueError("Wrong object id " + mission_id) star_info = starinfo.StarInfo( sherlock_id, *self.star_catalogs[mission_prefix].catalog_info(id)) logging.info("Downloading lightcurve files...") if mission == "TESS" and object_info.sectors != 'all': lcf = lk.search_lightcurvefile(str(mission_id), mission=mission, cadence="short", sector=object_info.sectors)\ .download_all() elif mission == "TESS": lcf = lk.search_lightcurvefile(str(mission_id), mission=mission, cadence="short").download_all() elif object_info.sectors != 'all': lcf = lk.search_lightcurvefile(str(mission_id), mission=mission, cadence="short", quarter=object_info.sectors)\ .download_all() else: lcf = lk.search_lightcurvefile(str(mission_id), mission=mission, cadence="short").download_all() if lcf is None: raise ObjectProcessingError( "Light curve not found for object id " + mission_id) lc = None matching_objects = [] for i in range(0, len(lcf.PDCSAP_FLUX)): if lcf.PDCSAP_FLUX[i].label == mission_id: if lc is None: lc = lcf.PDCSAP_FLUX[i] else: lc.append(lcf.PDCSAP_FLUX[i]) else: matching_objects.append(lcf.PDCSAP_FLUX[i].label) if len(matching_objects) > 0: logging.warning("================================================") logging.warning("TICS IN THE SAME PIXEL: " + str(matching_objects)) logging.warning("================================================") lc = lc.remove_nans() transits_min_count = 1 if len(lcf) == 0 else 2 if mission_prefix == self.MISSION_ID_KEPLER or mission_id == self.MISSION_ID_KEPLER_2: quarters = [lcfile.quarter for lcfile in lcf] elif mission_prefix == self.MISSION_ID_TESS: sectors = [file.sector for file in lcf] if mission_prefix == self.MISSION_ID_KEPLER_2: logging.info("Correcting K2 motion in light curve...") quarters = [lcfile.campaign for lcfile in lcf] lc = lc.to_corrector("sff").correct(windows=20) return lc, star_info, transits_min_count, np.unique( sectors), np.unique(quarters)
def _launch_query(id, download_dir, lkwargs): """ Search for target on MAST server. Get all the lightcurves available for a target id, using options in kwargs dictionary. The lightcurves are downloaded using the lightkurve API, and the target ID must therefore be parseable by lightkurve. Parameters ---------- id : string Target id, must be resolvable by Lightkurve. download_dir : str Directory to download the lightcurves into. lkwargs : dictionary containing keywords for the LightKurve search. For example cadence, quarter, campaign, sector, month. Returns ------- search_results : list List of fits files for the requested target """ print(f'Querying MAST for {id}') search_results = lk.search_lightcurvefile(target=id, **lkwargs) if len(search_results) == 0: warnings.warn('LightKurve did not return %s cadence data for %s' % (lkwargs['cadence'], id)) return [] else: return search_results.download_all(download_dir=download_dir)
def read_and_process_light_curve(kepid, kepler_data_dir, campaign, max_gap_width=0.75): """Reads a light curve, fits a B-spline and divides the curve by the spline. Args: kepid: Kepler id of the target star. kepler_data_dir: Base directory containing Kepler data. See kepler_io.kepler_filenames(). campaign: K2 campaign where data was taken. max_gap_width: Gap size (in days) above which the light curve is split for the fitting of B-splines. Returns: time: 1D NumPy array; the time values of the light curve. flux: 1D NumPy array; the normalized flux values of the light curve. Raises: IOError: If the light curve files for this Kepler ID cannot be found. ValueError: If the spline could not be fit. """ # Read the Kepler light curve. lcf = lk.search_lightcurvefile(kepid, campaign=campaign).download() lcf.SAP_FLUX #TODO: do some data cleaning/ data munging quality assurance here return lcf.SAP_FLUX.time, lcf.SAP_FLUX.flux
def get_lightcurve_from_kic(kic_nr, quarter): """Fetches the time, light curve and uncertainty of the star sepcified by the KIC number for the given quarter. """ kic_name = "KIC " + "%09i" % kic_nr download_dir = os.path.abspath('./.lightkurve_cache') if not os.path.isdir(download_dir): os.mkdir(download_dir) search_res = lk.search_lightcurvefile(kic_name, quarter=quarter, cadence="long") selector = 0 if len(search_res) == 0: return None try: lcf = search_res[selector].download(download_dir=download_dir) lc = lcf.PDCSAP_FLUX.normalize() except Exception as E: print("Trying to correct Error:", E) for o_id, pFn in zip(search_res.table["obs_id"], search_res.table["productFilename"]): cache_name = [ download_dir + "/mastDownload/Kepler/" + o_id + "/" + pFn ] os.system("rm -f %s" % (cache_name[selector])) lcf = search_res[selector].download(download_dir=download_dir) lc = lcf.PDCSAP_FLUX.normalize() return lc.to_pandas(["time", "flux", "flux_err"])
def two_min_lc_download(target_ID, sector, from_file=True): """ Downloads and returns SAP and PDCSAP 2-min lightcurves from MAST """ if from_file == True: # reads input table for targets table_data = Table.read("K2_2min_overlap_observed.csv", format='ascii.csv') # Obtains ra and dec for object from target_ID i = list(table_data['TICID']).index(target_ID) print(i) #camera = table_data['S{}'.format(sector)][i] # tic = table_data['MatchID'][i] tic = 'TIC ' + str(target_ID) # Find sector sector_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] for sector_num in sector_list: if table_data['S' + str(sector_num)][i] != 0: sector = sector_num else: tic = 'TIC ' + str(target_ID) lcf = search_lightcurvefile(tic, sector=sector).download() # lcf = search_lightcurvefile(tic).download() # sector = # Seperate lightcurves sap_lc = lcf.SAP_FLUX pdcsap_lc = lcf.PDCSAP_FLUX return sap_lc, pdcsap_lc, sector
def _from_mast_K2(targetid, mode, c, flux_type="PDCSAP_FLUX", cadence="long", aperture_mask="default", download_dir=None): if mode == "TPF": tpffilelist = search_targetpixelfile(targetid, mission="K2", campaign=c, cadence=cadence) tpf = tpffilelist.download(download_dir=download_dir) if aperture_mask == "default": aperture_mask = tpf.pipeline_mask lc = tpf.to_lightcurve(aperture_mask=aperture_mask) flc = _convert_TPF_to_FLC(tpf, lc) return flc elif mode == "LC": flcfilelist = search_lightcurvefile(targetid, mission="K2", campaign=c, cadence=cadence) flcfile = flcfilelist.download(download_dir=download_dir) lc = flcfile.get_lightcurve(flux_type) flc = _convert_LC_to_FLC(lc, origin="KLC") return flc
def __init__(self, name: str, dfile: Path = None, tic: int = None, zero_epoch: float = None, period: float = None, nsamples: int = 2, trdur: float = 0.125, bldur: float = 0.3, use_pdc=False, split_transits=True, separate_noise=False): if tic is not None: from lightkurve import search_lightcurvefile lcf = search_lightcurvefile(tic, mission='TESS') lc = lcf.download_all() if use_pdc: lc = lc.PDCSAP_FLUX.stitch().normalize() else: lc = lc.SAP_FLUX.stitch().normalize() time, flux = lc.time.astype('d'), lc.flux.astype('d') elif dfile is not None: tb = Table.read(dfile) self.zero_epoch = zero_epoch - self.bjdrefi df = tb.to_pandas().dropna( subset=['TIME', 'SAP_FLUX', 'PDCSAP_FLUX']) time, flux = df.TIME.values, df.PDCSAP_FLUX.values if use_pdc else df.SAP_FLUX.values time += self.bjdrefi if split_transits: self.zero_epoch = zero_epoch - self.bjdrefi self.period = period self.transit_duration = trdur self.baseline_duration = bldur self.lc = lc = KeplerLC(time, flux, zeros(time.size), zero_epoch, period, trdur, bldur) times, fluxes = lc.time_per_transit, lc.normalized_flux_per_transit pbids = lc.nt * [0] else: times, fluxes = [time], [flux] pbids = [0] self.zero_epoch = None self.period = None self.transit_duration = None self.baseline_duration = None wnids = arange(len(times)) if separate_noise else None BaseLPF.__init__(self, name, ['TESS'], times=times, fluxes=fluxes, pbids=pbids, nsamples=nsamples, exptimes=[0.00139], wnids=wnids)
def download_lkf(target, qstart=1, qend=17, qlist=None, cadence='long', download_dir=None, verbose=False): """ Download a series of KeplerLightCurveFiles from MAST using lightkurve Can either download a contiguous block over (qstart,qend) or a list of specified quarters Parameters ---------- target : string name of target lightkurve (see lightkurve documentation) qstart : int first quarter do download (default=1) qend : int last quarter to download (default=17) qlist : list specified quarters to download cadence : string 'short' or 'long' (default='long') download_dir : string directory to download files to (default=None --> cache) verbose : bool boolean flag; 'True' to print quarter number Returns ------- lkflist : list a list of lightkurve.KeplerLightCurveFile() objects """ lkflist = [] if qlist is not None: for q in qlist: lkflist.append(lk.search_lightcurvefile(target, mission='Kepler', quarter=q, \ cadence=cadence).download(download_dir=download_dir)) else: for q in range(qstart, qend + 1): if verbose: print(q) lkflist.append(lk.search_lightcurvefile(target, mission='Kepler', quarter=q, \ cadence=cadence).download(download_dir=download_dir)) return lkflist
def download_from_lightkurve(kic): """ Download a light curve from lightkurve """ lc = search_lightcurvefile( target=f"KIC {kic}", mission='Kepler').download_all().PDCSAP_FLUX.stitch() return lc
def k2_lc_download(target_ID, campaign, from_file=True): """ Downloads and returns SAP and PDCSAP 2-min lightcurves from K2 """ lcf = search_lightcurvefile(target_ID, campaign).download sap_lc = lcf.SAP_FLUX pdcsap_lc = lcf.PDCSAP_FLUX return sap_lc, pdcsap_lc
def from_archive(target, **kwargs): lc_collection = search_lightcurvefile(target).download_all() lc = lc_collection[0].PDCSAP_FLUX.normalize() for l in lc_collection[1:]: lc = lc.append(l.PDCSAP_FLUX.normalize()) lc = lc.remove_nans() magnitude = -2.5 * np.log10(lc.flux) magnitude = magnitude - np.average(magnitude) return TimeDelay(lc.time, magnitude, **kwargs)
def plot_lightcurve(message, star_id, mission=('Kepler', 'K2', 'TESS'), cadence=None): message.react('+1') if cadence is None: lc = lk.search_lightcurvefile( star_id, mission=mission).download_all().stitch().remove_nans() else: lc = lk.search_lightcurvefile( star_id, mission=mission, cadence=cadence).download_all().stitch().remove_nans() _, ax = plt.subplots(figsize=[10, 5], constrained_layout=True) lc.plot(ax=ax) with create_tmp_file() as tmp_file: plt.savefig(tmp_file + '.png', bbox_inches='tight') message.channel.upload_file(star_id, tmp_file + '.png')
def get_lightcurve(target, type='flux', **kwargs): lc_collection = search_lightcurvefile(target, **kwargs).download_all() lc = lc_collection[0].PDCSAP_FLUX.normalize() for l in lc_collection[1:]: lc = lc.append(l.PDCSAP_FLUX.normalize()) lc = lc.remove_nans() if type is 'flux': return lc magnitude = -2.5 * np.log10(lc.flux) magnitude = magnitude - np.average(magnitude) return lc.time, magnitude
def print_short_cadence_observation_count_for_stars(star_list): """Print the number of stars and observations with short cadence in the given star list.""" count_of_stars_with_short_cadence = 0 count_of_observations_with_short_cadence = 0 for kepler_input_catalog_number in star_list: short_cadence_observations = search_lightcurvefile( kepler_input_catalog_number, cadence='short') count_of_observations_with_short_cadence += len( short_cadence_observations) if len(short_cadence_observations) is not 0: count_of_stars_with_short_cadence += 1 print(f'Stars: {count_of_stars_with_short_cadence}') print(f'Observations: {count_of_observations_with_short_cadence}')
def _from_mast_TESS(targetid, c, flux_type="PDCSAP_FLUX", cadence="long", download_dir=None): flcfilelist = search_lightcurvefile(targetid, mission="TESS", sector=c, cadence=cadence) flcfile = flcfilelist.download(download_dir=download_dir) lc = flcfile.get_lightcurve(flux_type) flc = _convert_LC_to_FLC(lc, origin="TLC", sector=c) return flc
async def compute_lightkurve(self, mission, target, sector=None, campaign=None, quarter=None, radius=None, month=None, limit=None): result = None if mission == "TESS": result = search_lightcurvefile(mission=mission, target=target, sector=sector, radius=radius, month=month, limit=limit) elif mission == "Kepler": result = search_lightcurvefile(mission=mission, target=target, quarter=quarter, radius=radius, month=month, limit=limit) pass elif mission == "K2": result = search_lightcurvefile(mission=mission, target=target, campaign=campaign, radius=radius, month=month, limit=limit) pass else: raise ValueError("Unknown mission, must be TESS, Kepler, or K2") return result.download()
def test_run(): starname = "TIC 10863087" lcf = lk.search_lightcurvefile(starname).download() lc = lcf.PDCSAP_FLUX no_nan_lc = lc.remove_nans() clipped_lc = no_nan_lc.remove_outliers(sigma=3) clipped_lc.scatter(alpha=.5, s=.5) rotate = ss.RotationModel(clipped_lc.time, clipped_lc.flux, clipped_lc.flux_err) rotate.lc_plot() ls_period = rotate.ls_rotation() rotate.ls_plot() tess_cadence = 1. / 24. / 30. # This is a TESS 2 minute cadence star. acf_period = rotate.acf_rotation(tess_cadence) rotate.acf_plot() period_grid = np.linspace(.1, 2, 1000) pdm_period, period_err = rotate.pdm_rotation(period_grid, pdm_nbins=10) print(pdm_period, period_err) rotate.pdm_plot() # Lomb-Scargle periodogram period_array = 1. / rotate.freq power_array = rotate.power # Autocorrelation function ACF_array = rotate.acf lag_array = rotate.lags # Phase-dispersion minimization phi_array = rotate.phis # The 'dispersion' plotted in the lower panel above. period_grid = period_grid # We already defined this above. # Get peak positions and heights, in order of highest to lowest peak. peak_positions, peak_heights = rt.get_peak_statistics( 1. / rotate.freq, rotate.power) print(peak_positions[0]) # Get peak positions and heights, in order of highest to lowest peak. acf_peak_positions, acf_peak_heights = rt.get_peak_statistics( rotate.lags, rotate.acf, sort_by="height") print(acf_peak_positions[0]) # Get peak positions and heights, in order of lags. acf_peak_positions, acf_peak_heights = rt.get_peak_statistics( rotate.lags, rotate.acf, sort_by="position") print(acf_peak_positions[0])
def __init__(self, mission, xoi_id=-1.0, xic_id=-1.0, mask_planets=True, lctype="rotation", time=None, flux=None, flux_err=None): self.xic_id = xic_id self.xoi_id = xoi_id self.mission = mission if self.xic_id == -1.0: if self.xoi_id == -1.0: if self.mission == None: pass else: raise SyntaxError("You miss the input id of the star") else: self.xic_id = koi2kid(self.xoi_id) self.mask_planets = mask_planets self.lctype = lctype if self.lctype == "rotation": corrector_func = lambda x: x.normalize().flatten( window_length=401, return_trend=True)[1] elif self.lctype == "granulation": corrector_func = lambda x: x.normalize().flatten( window_length=401, return_trend=False) elif self.lctype == "hybrid": corrector_func = lambda x: x.normalize() if mission != None: start = 0 if mission == "Kepler": prefix = "KIC " if mission == "TESS": prefix = "TIC " lcfs = search_lightcurvefile(self.xic_id, mission=mission).download_all() stitched_lc = lcfs.PDCSAP_FLUX.stitch( corrector_func=corrector_func) self.lcf = stitched_lc else: lcfs = lk.LightCurve(time=time, flux=flux, flux_err=flux_err) normed_lc = lcfs self.lcf = normed_lc self._mask = None
def get_sectors(tic, ): """Queries for the number of sectors available for a given TIC """ # Query search_res = lk.search_lightcurvefile("TIC {}".format(tic), mission="TESS") # Grab table actually containing info sectors = list(search_res.table["observation"]) # Take just the sector numbers and sort sectors = [int(sector.split(" ")[-1]) for sector in sectors] sector_str = format_sectors(sectors) return sectors, sector_str
def joinLC(ID): """ Generates a normalized lightcurve for the entire duration of the Kepler mission (missing quarters are removed). """ lcfiles = lk.search_lightcurvefile(ID).download_all() stitched_lc = lcfiles[0].PDCSAP_FLUX.normalize().flatten(window_length=401) for i in range(1, len(lcfiles)): lc = lcfiles[i].PDCSAP_FLUX.normalize().flatten(window_length=401) stitched_lc = stitched_lc.append(lc) stitched_lc = stitched_lc.remove_outliers() stitched_lc = remove_anomalies(stitched_lc).remove_nans() return stitched_lc
def search_and_dump(ID, cadence, mission, search_cache, store_date): search = lk.search_lightcurvefile(ID, cadence=cadence, mission=mission) kplr = 'kplr' + '0' * (9 - len(ID.strip('KIC'))) + ID.strip('KIC') idx = np.zeros(len(search.table['obs_id']), dtype=bool) for i in range(len(idx)): if kplr in search.table['obs_id'][i]: idx[i] = 1 search.table = search.table[idx] fname = os.path.join(*[ search_cache, f"{ID}_{mission}_{cadence}_{store_date}.lksearchresult" ]) pickle.dump(search, open(fname, "wb")) return search
def getMASTidentifier(ID, lkwargs): """ return KIC/TIC/EPIC for given ID. If input ID is not a KIC/TIC/EPIC identifier then the target is looked up on MAST and the identifier is retried. If a mission is not specified the set of observations with the most quarters/sectors etc. will be used. Parameters ---------- ID : str Target ID lkwargs : dict Dictionary with arguments to be passed to lightkurve. In this case mission and cadence. Returns ------- ID : str The KIC/TIC/EPIC ID of the target. """ if not any([x in ID for x in ['KIC', 'TIC', 'EPIC']]): search = lk.search_lightcurvefile(ID, cadence=lkwargs['cadence'], mission=lkwargs['mission']) if len(search) == 0: raise ValueError(f'No results for {ID} found on MAST') maxFreqName = max(set(list(search.table['target_name'])), key=list(search.table['target_name']).count) maxFreqObsCol = max(set(list(search.table['obs_collection'])), key=list(search.table['obs_collection']).count) if maxFreqObsCol == 'TESS': prefix = 'TIC' else: prefix = '' temp_id = prefix + maxFreqName ID = format_name(temp_id).replace(' ', '') lkwargs['mission'] = maxFreqObsCol else: ID = ID.replace(' ', '') return ID
def test_freqextr_kepler(): lcfs = lk.search_lightcurvefile('KIC 1162345', mission='Kepler', cadence='long') # Pretty hacky way of making sure lightkurve only returned the target we want: lcfs.table = lcfs.table[lcfs.target_name == 'kplr001162345'] lcfs = lcfs.download_all() lc = lcfs.PDCSAP_FLUX.stitch() lc = lc.remove_nans().remove_outliers() lc = 1e6*(lc - 1) lc.flux_unit = cds.ppm tab = freqextr(lc, n_peaks=10, n_harmonics=2, snrlim=4) _summary(lc, tab) assert tab.meta['n_peaks'] == 10 assert tab.meta['n_harmonics'] == 2 assert tab.meta['snrlim'] == 4
def quicklook(message, star_id, mission=('Kepler', 'K2', 'TESS'), cadence='long'): message.react('+1') try: lc = lk.search_lightcurvefile( star_id, mission=mission, cadence=cadence).download_all().stitch().remove_nans() _, ax = plt.subplots(2, 1, figsize=[10, 10], constrained_layout=True) lc.plot(ax=ax[0]) lc.to_periodogram().plot(ax=ax[1]) with create_tmp_file() as tmp_file: plt.savefig(tmp_file + '.png', bbox_inches='tight') message.channel.upload_file(star_id, tmp_file + '.png') except: message.reply('I could not resolve your query. ')
def get_data(): ''' This function will read in a lightcurve Then it removes outliers and fills in any gaps Returns the frequencies and powers for a periodogram of the lightcurve ''' search = lk.search_lightcurvefile('KIC10963065', cadence='short', mission='Kepler') #print(search) files = search[1:10].download_all() lc = files.PDCSAP_FLUX.stitch() lc = lc.remove_nans().remove_outliers().fill_gaps() plt.figure(figsize=(15, 15)) plt.plot(lc.time, lc.flux) plt.xlabel("Time") plt.ylabel("Flux") plt.savefig("Lcurve.pdf") plt.close() lc = lc.to_periodogram(freq_unit=u.microHertz, maximum_frequency=3000, minimum_frequency=1500) frequency = lc.frequency power = lc.power plt.figure(figsize=(15, 15)) plt.plot(frequency, power) plt.xlabel("Frequency") plt.ylabel("PSD") plt.savefig("Periodogram.pdf") plt.close() return frequency, power
def search_and_dump(ID, lkwargs, search_cache): """ Get lightkurve search result online. Uses the lightkurve search_lightcurvefile to find the list of available data for a target ID. Stores the result in the ~/.lightkurve-cache/searchResult directory as a dictionary with the search result object and a timestamp. Parameters ---------- ID : str ID string of the target lkwargs : dict Dictionary to be passed to LightKurve search_cache : str Directory to store the search results in. Returns ------- resultDict : dict Dictionary with the search result object and timestamp. """ current_date = datetime.now().isoformat() store_date = current_date[:current_date.index('T')].replace('-', '') search = lk.search_lightcurvefile(ID, cadence=lkwargs['cadence'], mission=lkwargs['mission']) resultDict = {'result': search, 'timestamp': store_date} fname = os.path.join( *[search_cache, f"{ID}_{lkwargs['cadence']}.lksearchresult"]) pickle.dump(resultDict, open(fname, "wb")) return resultDict
def get_raw_data(star, miss): search_result = lk.search_lightcurvefile(star, mission=miss) print("found") files = search_result.download_all() print("downloaded") lc = files.PDCSAP_FLUX.stitch() lc = lc.remove_outliers().remove_nans() pg = lc.to_periodogram(method='lombscargle', normalization='psd') pg_nu_guess = lc.to_periodogram(method='lombscargle', normalization='psd', minimum_frequency=20, maximum_frequency=300) pg_smooth_2 = pg_nu_guess.smooth(method='boxkernel', filter_width=10) p = pg.power.value * 10**12 f = pg.frequency.value p2 = pg_smooth_2.power.value * 10**12 f2 = pg_smooth_2.frequency.value return f, p, f2, p2
def update_plot(): try: inds = [ s1.selected.indices[0] ] # plotting multiple light curves is not supported at this time except: inds = [0] # if no point is selected, default behavior lcs = list(s1.data['desc'][inds]) for i, ind in enumerate( inds ): # framework to plot multiple lightcurves, not yet implemented lc = lcs[i] # download Kepler lighcurve via Lightkurve lcf = search_lightcurvefile(lc, mission="Kepler", quarter=Quarter).download() # use the normalized PDCSAP flux nlc = lcf.PDCSAP_FLUX.normalize() t = nlc.time nf = nlc.flux s2.data = {'t': t, 'nf': nf} plc.line('t', 'nf', source=s2)
def test_one_lpp(): """"Use case is to get values for one TCE.""" period = 3.5224991 * u.day tzero = (54953.6193 + 2400000.5 - 2454833.0) * u.day duration = 3.1906 * u.hour depth = 0.009537 * const.frac_amp target_name = "Kepler-8" event_name = "Kepler-8 b" tce = Tce(period=period, epoch=tzero, duration=duration, target_name=target_name, depth=depth, event_name=event_name, epoch_offset=0 * u.day, snr=10) # Specify the lightcurve to vet mission = "Kepler" q = 4 # Generic function that runs lightkurve and returns a lightkurve object lcf = search_lightcurvefile(target_name, quarter=q, mission=mission).download() lc = lcf.SAP_FLUX.remove_nans().remove_outliers() flat = lc.flatten(window_length=81) flat.flux = flat.flux - 1.0 # Use default .mat file from SourceForge lpp = vetters.Lpp(lc_name="flux", map_filename=None) _ = lpp.run(tce, flat) # Accepted value if data doesn't change assert_allclose(lpp.norm_lpp, 0.17, atol=0.09)