Ejemplo n.º 1
0
    def simulate_times(self, lc, use_spline=False, bin_time=None):
        """
        Assign (simulate) photon arrival times to event list, using the
        acceptance-rejection method.

        Parameters
        ----------
        lc: `Lightcurve` object

        Other Parameters
        ----------------
        use_spline : bool
            Approximate the light curve with a spline to avoid binning effects
        bin_time : float
            The bin time of the light curve, if it needs to be specified for
            improved precision

        Return
        ------
        times : array-like
            Simulated photon arrival times
        """
        self.time = simulate_times(lc, use_spline=use_spline,
                                   bin_time=bin_time)
        self.gti = lc.gti
        self.ncounts = len(self.time)
Ejemplo n.º 2
0
    def simulate_times(self, lc, use_spline=False, bin_time=None):
        """Simulate times from an input light curve.

        Randomly simulate photon arrival times to an :class:`EventList` from a
        :class:`stingray.Lightcurve` object, using the inverse CDF method.

        Parameters
        ----------
        lc: :class:`stingray.Lightcurve` object

        Other Parameters
        ----------------
        use_spline : bool
            Approximate the light curve with a spline to avoid binning effects

        bin_time : float default None
            Ignored and deprecated, maintained for backwards compatibility.

        Returns
        -------
        times : array-like
            Simulated photon arrival times
        """
        from stingray.simulator.base import simulate_times
        if bin_time is not None:
            warnings.warn("Bin time will be ignored in simulate_times",
                          DeprecationWarning)

        self.time = simulate_times(lc, use_spline=use_spline)
        self.gti = lc.gti
        self.ncounts = len(self.time)
Ejemplo n.º 3
0
    def simulate_times(self, lc, use_spline=False, bin_time=None):
        """
        Randomly assign (simulate) photon arrival times to an :class:`EventList` from a
        :class:`stingray.Lightcurve` object, using the acceptance-rejection method.

        Parameters
        ----------
        lc: :class:`stingray.Lightcurve` object

        Other Parameters
        ----------------
        use_spline : bool
            Approximate the light curve with a spline to avoid binning effects

        bin_time : float
            The bin time of the light curve, if it needs to be specified for
            improved precision

        Returns
        -------
        times : array-like
            Simulated photon arrival times
        """
        self.time = simulate_times(lc,
                                   use_spline=use_spline,
                                   bin_time=bin_time)
        self.gti = lc.gti
        self.ncounts = len(self.time)
Ejemplo n.º 4
0
 def test_simulate_times_with_spline(self):
     """Simulate photon arrival times, with use_spline option
     enabled.
     """
     lc = Lightcurve(self.time, self.counts_flat, gti=self.gti)
     times = simulate_times(lc, use_spline=True)
     lc_sim = Lightcurve.make_lightcurve(times, gti=lc.gti, dt=lc.dt,
                                         tstart=lc.tstart, tseg=lc.tseg)
     assert np.all((lc - lc_sim).counts < 3 * np.sqrt(lc.counts))
Ejemplo n.º 5
0
 def test_simulate_times(self):
     """Simulate photon arrival times for an event list
     from light curve.
     """
     lc = Lightcurve(self.time, self.counts_flat, gti=self.gti)
     times = simulate_times(lc)
     lc_sim = Lightcurve.make_lightcurve(times, gti=lc.gti, dt=lc.dt,
                                         tstart=lc.tstart, tseg=lc.tseg)
     assert np.all((lc - lc_sim).counts < 3 * np.sqrt(lc.counts))
Ejemplo n.º 6
0
 def test_simulate_times_with_spline(self):
     """Simulate photon arrival times, with use_spline option
     enabled.
     """
     lc = Lightcurve(self.time, self.counts_flat, gti=self.gti)
     times = simulate_times(lc, use_spline=True)
     lc_sim = Lightcurve.make_lightcurve(times, gti=lc.gti, dt=lc.dt,
                                         tstart=lc.tstart, tseg=lc.tseg)
     assert np.all((lc - lc_sim).counts < 3 * np.sqrt(lc.counts))
Ejemplo n.º 7
0
 def test_simulate_times(self):
     """Simulate photon arrival times for an event list
     from light curve.
     """
     lc = Lightcurve(self.time, self.counts_flat, gti=self.gti)
     times = simulate_times(lc)
     lc_sim = Lightcurve.make_lightcurve(times, gti=lc.gti, dt=lc.dt,
                                         tstart=lc.tstart, tseg=lc.tseg)
     print((lc - lc_sim).counts)
     assert np.all(np.abs((lc - lc_sim).counts) < 3 * np.sqrt(lc.counts))