How to use the lightkurve.LightCurve function in lightkurve

To help you get started, we’ve selected a few lightkurve examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keatonb / Pyriod / Pyriod / Pyriod.py View on Github external
self.lcfig.canvas.mpl_connect("key_press_event", self._mask_selected_pts)
        
        #Apply time shift to get phases to be well behaved
        self._calc_tshift()
        
        #I think this function nearly computes all the periodograms and timeshift and everything...
        #self._mask_changed()
        
        
        #Also plot the model over the time series
        time_samples = np.arange(np.min(self.lc_orig.time),
                                 np.max(self.lc_orig.time)+self.dt/oversample_factor,self.dt/oversample_factor)
        initmodel = np.zeros(len(time_samples))+np.mean(self.lc_orig.flux)
        self.lc_model_sampled = lk.LightCurve(time=time_samples,flux=initmodel)
        initmodel = np.zeros(len(self.lc_orig.time))+np.mean(self.lc_orig.flux[self.include])
        self.lc_model_observed = lk.LightCurve(time=self.lc_orig.time,flux=initmodel)
        
        self.lcplot_model, = self.lcax.plot(self.lc_model_sampled.time,
                                            self.lc_model_sampled.flux,c='r',lw=1)
        
        #And keep track of residuals time series
        self.lc_resid = self.lc_orig - self.lc_model_observed
        
        
        ### PERIODOGRAM ###
        # Four types for display
        # Original (orig), Residuals (resid), Model (model), and Spectral Window (sw)
        # Each is stored as, e.g., "per_orig", samples at self.freqs
        # Has associated plot _perplot_orig
        # Display toggle widget _perplot_orig_display
        # TODO: Add color picker _perplot_orig_color
github afeinstein20 / eleanor / eleanor / visualize.py View on Github external
plt.colorbar(c, cax=cax, orientation='vertical')

        ## PLOTS PIXEL LIGHT CURVES ##
        for ind in range( int(nrows * ncols) ):
            ax = plt.Subplot(figure, inner[ind])

            flux = self.flux[:,i,j]
            time = self.obj.time
            corr_flux = self.obj.corrected_flux(flux=flux)

            if data_type.lower() == 'corrected':
                y = corr_flux[q]/np.nanmedian(corr_flux[q])
                x = time[q]

            elif data_type.lower() == 'amplitude':
                lc = lk.LightCurve(time=time, flux=corr_flux)
                pg = lc.normalize().to_periodogram()
                x = pg.frequency.value
                y = pg.power.value

            elif data_type.lower() == 'raw':
                y = flux[q]/np.nanmedian(flux[q])
                x = time[q]

            elif data_type.lower() == 'periodogram':
                freq, power = LombScargle(time, corr_flux).autopower(minimum_frequency=freq_range[0],
                                                                     maximum_frequency=freq_range[1],
                                                                     method='fast')
                y = power
                x = 1/freq

            if color_by_pixel is False:
github keatonb / Pyriod / Pyriod / Pyriod.py View on Github external
### TIME SERIES ###
        # Four to keep track of (called lc_nickname)
        # Original (orig), Residuals (resid), 
        # Model (oversampled: model_sampled; and observed: model_observed)
        # Each is lightkurve object
        
        #Store light curve as LightKurve object
        if lc is None and time is None and flux is None:
            raise ValueError('lc or time and flux are required')
        if lc is not None:
            if lk.lightcurve.LightCurve not in type(lc).__mro__:
                raise ValueError('lc must be lightkurve object')
            else:
                self.lc_orig = lc
        else:
            self.lc_orig = lk.LightCurve(time=time, flux=flux)
        
        #Maintain a mask of points to exclude from analysis
        self.mask = np.ones(len(self.lc_orig)) # 1 = include
        self.include = np.where(self.mask)
        
        #Establish frequency sampling
        self.dt = np.median(np.diff(self.lc_orig.time))
        self.set_frequency_sampling(oversample_factor=oversample_factor,nyquist_factor=nyquist_factor)
        
        #Initialize time series widgets and plots
        self._init_timeseries_widgets()
        self.lcfig,self.lcax = plt.subplots(figsize=(7,2),num='Time Series ({:d})'.format(self.id))
        self.lcax.set_xlabel("time")
        self.lcax.set_ylabel("rel. variation")
        self.lcax.set_position([0.13,0.22,0.85,0.76])
        self._lc_colors = {0:"bisque",1:"C0"}
github KeplerGO / lightkurve / lightkurve / prf / tpfmodel.py View on Github external
def _parse_lightcurve(self, star_idx):
        # Create a lightcurve
        from .. import LightCurve
        flux = []
        for cadence in range(len(self.results)):
            flux.append(self.results[cadence].stars[star_idx].flux)
        return LightCurve(flux=flux, targetid=self.model.star_priors[star_idx].targetid)
github KeplerGO / lightkurve / lightkurve / prf / tpfmodel.py View on Github external
def _parse_background(self):
        # Create a lightcurve
        from .. import LightCurve
        bgflux = []
        for cadence in range(len(self.results)):
            bgflux.append(self.results[cadence].background.flux)
        return LightCurve(flux=bgflux)
github keatonb / Pyriod / Pyriod / Pyriod.py View on Github external
#Define selector for masking points
        self.selector = lasso_selector(self.lcax, self.lcplot_data)
        self.lcfig.canvas.mpl_connect("key_press_event", self._mask_selected_pts)
        
        #Apply time shift to get phases to be well behaved
        self._calc_tshift()
        
        #I think this function nearly computes all the periodograms and timeshift and everything...
        #self._mask_changed()
        
        
        #Also plot the model over the time series
        time_samples = np.arange(np.min(self.lc_orig.time),
                                 np.max(self.lc_orig.time)+self.dt/oversample_factor,self.dt/oversample_factor)
        initmodel = np.zeros(len(time_samples))+np.mean(self.lc_orig.flux)
        self.lc_model_sampled = lk.LightCurve(time=time_samples,flux=initmodel)
        initmodel = np.zeros(len(self.lc_orig.time))+np.mean(self.lc_orig.flux[self.include])
        self.lc_model_observed = lk.LightCurve(time=self.lc_orig.time,flux=initmodel)
        
        self.lcplot_model, = self.lcax.plot(self.lc_model_sampled.time,
                                            self.lc_model_sampled.flux,c='r',lw=1)
        
        #And keep track of residuals time series
        self.lc_resid = self.lc_orig - self.lc_model_observed
        
        
        ### PERIODOGRAM ###
        # Four types for display
        # Original (orig), Residuals (resid), Model (model), and Spectral Window (sw)
        # Each is stored as, e.g., "per_orig", samples at self.freqs
        # Has associated plot _perplot_orig
        # Display toggle widget _perplot_orig_display