Ejemplo n.º 1
0
    def run(self, tce, lightcurve, plot=False):

        time, flux, time_offset_str = lightkurve_utils.unpack_lk_version(
            lightcurve, self.lc_name)  # noqa: E50

        period_days = tce["period"].to_value(u.day)
        time_offset_q = getattr(exo_const, time_offset_str)
        epoch = tce.get_epoch(time_offset_q).to_value(u.day)
        duration_days = tce["duration"].to_value(u.day)
        depth = tce['depth']

        n_has_data = viz_transits.plot_all_transits(
            time,
            flux,
            period_days,
            epoch,
            duration_days,
            depth,
            max_transits=self.max_transits,
            transit_only=self.transit_only,
            plot=plot,
            units="d")

        viz_transits.plot_fold_transit(time,
                                       flux,
                                       period_days,
                                       epoch,
                                       depth,
                                       duration_days,
                                       smooth=self.smooth,
                                       transit_only=self.transit_only,
                                       plot=plot,
                                       units="d")

        return {'num_transits': n_has_data}
Ejemplo n.º 2
0
    def run(self, tce, lc, plot=False):
        """Run the vetter on the specified Threshold Crossing Event (TCE)
        and lightcurve to obtain metric.

        Parameters
        ----------
        tce : `~exovetter.tce.Tce`
            TCE.

        lc : obj
            ``lightkurve`` object that contains the detrended lightcurve's
            time and flux arrays to use for vetting.
        """
        time, flux, time_offset_str = lightkurve_utils.unpack_lk_version(
            lc, self.lc_name)  # noqa: E50

        p_day = tce["period"].to_value(u.day)
        dur_hour = tce["duration"].to_value(u.hour)

        time_offset_q = getattr(exo_const, time_offset_str)
        epoch = tce.get_epoch(time_offset_q).to_value(u.day)

        tp_cover, self.hist, self.bins = transit_coverage.calc_coverage(
            time, p_day, epoch, dur_hour, ndur=self.ndur, nbins=self.nbins)

        if plot:
            transit_coverage.plot_coverage(self.hist, self.bins)

        return {'transit_phase_coverage': tp_cover}
Ejemplo n.º 3
0
    def run(self, tce, lightcurve, plot=False):
        """
        Runs modshift.compute_modeshift_metrics to populate the vetter object.

        Parameters
        -----------
        tce : tce object
            tce object is a dictionary that contains information about the tce
            to vet, like period, epoch, duration, depth

        lc : lightkurve object
            lightkurve object with the time and flux to use for vetting.

        Returns
        ------------
        modshift : dict
            modshift result dictionary containing the following:
                pri : primary signal
                sec : secondary signal
                ter : tertiary signal
                pos : largest positive event
                false_alarm_threshold : threshold for the 1 sigma false alarm
                Fred : red noise level, std(convolution) divided by std(lightcurve)
        """

        self.time, self.flux, time_offset_str = \
            lightkurve_utils.unpack_lk_version(lightcurve, self.lc_name)

        time_offset_q = const.string_to_offset[time_offset_str]

        self.flux = utils.set_median_flux_to_zero(self.flux)

        self.period_days = tce["period"].to_value(u.day)
        self.epoch_days = tce.get_epoch(time_offset_q).to_value(u.day)
        self.duration_hrs = tce["duration"].to_value(u.hour)

        self.box = model.create_box_model_for_tce(tce, self.time * u.day,
                                                  time_offset_q)
        metrics, conv = modshift.compute_modshift_metrics(
            self.time,
            self.flux,
            self.box,
            self.period_days,
            self.epoch_days,
            self.duration_hrs,
            show_plot=plot,
        )

        self.modshift = metrics

        return self.modshift
Ejemplo n.º 4
0
    def run(self, tce, lc, nbins=10, ndur=2):

        time, flux, time_offset_str = \
            lightkurve_utils.unpack_lk_version(lc, self.lc_name)  # noqa: E50

        p_day = tce['period'].to_value(u.day)
        dur_hour = tce['duration'].to_value(u.hour)

        time_offset_q = getattr(exo_const, time_offset_str)
        epoch = tce.get_epoch(time_offset_q).to_value(u.day)

        self.tp_cover, self.hist, self.bins = \
            transit_coverage.calc_coverage(time, p_day, epoch, dur_hour,
                                           ndur=ndur, nbins=nbins)
Ejemplo n.º 5
0
    def run(self, tce, lightcurve, dur_frac=0.3):
        self.time, self.flux, time_offset_str = \
            lightkurve_utils.unpack_lk_version(lightcurve, self.lc_name)

        self.dur_frac = dur_frac

        time_offset_q = getattr(exo_const, time_offset_str)

        self.period = tce['period'].to_value(u.day)
        self.duration = tce['duration'].to_value(u.day)
        self.epoch = tce.get_epoch(time_offset_q).to_value(u.day)

        self.oe_sigma, self.odd_depth, self.even_depth = \
            odd_even.calc_odd_even(self.time, self.flux, self.period,
                                   self.epoch, self.duration, ingress=None,
                                   dur_frac=self.dur_frac)
Ejemplo n.º 6
0
    def run(self, tce, lightcurve, plot=False):
        self.tce = tce
        self.lc = lightcurve

        time, flux, time_offset_str = lightkurve_utils.unpack_lk_version(
            self.lc, self.lc_name)  # noqa: E50

        period_days = tce["period"].to_value(u.day)
        time_offset_q = getattr(exo_const, time_offset_str)
        epoch = tce.get_epoch(time_offset_q).to_value(u.day)
        duration_days = tce["duration"].to_value(u.day)

        result_dict = sweet.sweet(time,
                                  flux,
                                  period_days,
                                  epoch,
                                  duration_days,
                                  plot=plot)
        result_dict = sweet.construct_message(result_dict,
                                              self.sweet_threshold_sigma)
        return result_dict
Ejemplo n.º 7
0
    def run(self, tce, lightcurve):
        """
        Parameters
        ----------
        tce : `~exovetter.tce.Tce`
            TCE.

        lightcurve : obj
            ``lightkurve`` object that contains the detrended lightcurve's
            time and flux arrays.


        """
        self.time, self.flux, time_offset_str = lightkurve_utils.unpack_lk_version(  # noqa
            lightcurve, self.lc_name)

        time_offset_q = getattr(exo_const, time_offset_str)

        self.period = tce["period"].to_value(u.day)
        self.duration = tce["duration"].to_value(u.day)
        self.epoch = tce.get_epoch(time_offset_q).to_value(u.day)

        self.oe_sigma, self.odd_depth, self.even_depth = odd_even.calc_odd_even(  # noqa
            self.time,
            self.flux,
            self.period,
            self.epoch,
            self.duration,
            ingress=None,
            dur_frac=self.dur_frac,
        )

        return {
            'oe_sigma': self.oe_sigma,
            'odd_depth': self.odd_depth,
            'even_depth': self.even_depth
        }
Ejemplo n.º 8
0
    def __init__(self, tce, lc, lc_name="flux", default_snr=10.):
        # TODO: Needs a check lightcurve function

        self.check_tce(tce, default_snr)

        # FIXME: This looks more correct but fails the test.
        # from exovetter import const as exo_const
        # self.tzero = tce.get_epoch(
        #     getattr(exo_const, lc.time_format)).to_value(u.day)

        self.tzero = tce['epoch'].to_value(u.day)
        self.dur = tce['duration'].to_value(u.hr)
        self.period = tce['period'].to_value(u.day)

        self.mes = default_snr
        if 'snr' in tce.keys():
            self.mes = tce['snr']

        self.time, self.flux, _ = \
            lightkurve_utils.unpack_lk_version(lc, lc_name)

        # make sure flux is zero norm.
        if np.round(np.median(self.flux)) != 0:
            self.flux = self.flux - np.median(self.flux)