예제 #1
0
 def test_times(self):
     """
     Test if the correct times array is returned for normal traces and
     traces with gaps.
     """
     tr = Trace(data=np.ones(100))
     tr.stats.sampling_rate = 20
     start = UTCDateTime(2000, 1, 1, 0, 0, 0, 0)
     tr.stats.starttime = start
     tm = tr.times()
     self.assertAlmostEqual(tm[-1], tr.stats.endtime - tr.stats.starttime)
     tr.data = np.ma.ones(100)
     tr.data[30:40] = np.ma.masked
     tm = tr.times()
     self.assertTrue(np.alltrue(tr.data.mask == tm.mask))
예제 #2
0
 def test_times(self):
     """
     Test if the correct times array is returned for normal traces and
     traces with gaps.
     """
     tr = Trace(data=np.ones(100))
     tr.stats.sampling_rate = 20
     start = UTCDateTime(2000, 1, 1, 0, 0, 0, 0)
     tr.stats.starttime = start
     tm = tr.times()
     self.assertAlmostEquals(tm[-1], tr.stats.endtime - tr.stats.starttime)
     tr.data = np.ma.ones(100)
     tr.data[30:40] = np.ma.masked
     tm = tr.times()
     self.assertTrue(np.alltrue(tr.data.mask == tm.mask))
예제 #3
0
    def mw_times(self, sampling_rate):
        """
        Utility function to generate timestamps for the time period around the
        trigger time for which the 4-D coalescence function is calculated in
        :func:`~quakemigrate.signal.scan.QuakeScan._compute`.

        Returns
        -------
        times : `numpy.ndarray` of `obspy.UTCDateTime`, shape(nsamples)
            Timestamps for time range `trigger_time` +/- 2 * `marginal_window`.

        """

        # Utilise the .times() method of `obspy.Trace` objects
        tr = Trace(
            header={
                "npts": 4 * self.marginal_window * sampling_rate + 1,
                "sampling_rate": sampling_rate,
                "starttime": self.trigger_time - 2 * self.marginal_window
            })
        return tr.times(type="utcdatetime")