当前位置: 首页>>代码示例>>Python>>正文


Python realtime.RtTrace类代码示例

本文整理汇总了Python中obspy.realtime.RtTrace的典型用法代码示例。如果您正苦于以下问题:Python RtTrace类的具体用法?Python RtTrace怎么用?Python RtTrace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RtTrace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_appendSanityChecks

 def test_appendSanityChecks(self):
     """
     Testing sanity checks of append method.
     """
     rtr = RtTrace()
     ftr = Trace(data=np.array([0, 1]))
     # sanity checks need something already appended
     rtr.append(ftr)
     # 1 - differing ID
     tr = Trace(header={'network': 'xyz'})
     self.assertRaises(TypeError, rtr.append, tr)
     tr = Trace(header={'station': 'xyz'})
     self.assertRaises(TypeError, rtr.append, tr)
     tr = Trace(header={'location': 'xy'})
     self.assertRaises(TypeError, rtr.append, tr)
     tr = Trace(header={'channel': 'xyz'})
     self.assertRaises(TypeError, rtr.append, tr)
     # 2 - sample rate
     tr = Trace(header={'sampling_rate': 100.0})
     self.assertRaises(TypeError, rtr.append, tr)
     tr = Trace(header={'delta': 0.25})
     self.assertRaises(TypeError, rtr.append, tr)
     # 3 - calibration factor
     tr = Trace(header={'calib': 100.0})
     self.assertRaises(TypeError, rtr.append, tr)
     # 4 - data type
     tr = Trace(data=np.array([0.0, 1.1]))
     self.assertRaises(TypeError, rtr.append, tr)
     # 5 - only Trace objects are allowed
     self.assertRaises(TypeError, rtr.append, 1)
     self.assertRaises(TypeError, rtr.append, "2323")
开发者ID:,项目名称:,代码行数:31,代码来源:

示例2: test_appendNotFloat32

 def test_appendNotFloat32(self):
     """
     Test for not using float32.
     """
     tr = read()[0]
     tr.data = np.require(tr.data, dtype=native_str('>f4'))
     traces = tr / 3
     rtr = RtTrace()
     for trace in traces:
         rtr.append(trace)
开发者ID:,项目名称:,代码行数:10,代码来源:

示例3: test_ne

 def test_ne(self):
     """
     Testing __ne__ method.
     """
     tr = Trace()
     tr2 = RtTrace()
     tr3 = RtTrace()
     # RtTrace should never be equal with Trace objects
     self.assertTrue(tr2 != tr)
     self.assertTrue(tr2.__ne__(tr))
     self.assertFalse(tr2 != tr3)
     self.assertFalse(tr2.__ne__(tr3))
开发者ID:,项目名称:,代码行数:12,代码来源:

示例4: test_appendOverlap

 def test_appendOverlap(self):
     """
     Appending overlapping traces should raise a UserWarning/TypeError
     """
     rtr = RtTrace()
     tr = Trace(data=np.array([0, 1]))
     rtr.append(tr)
     # this raises UserWarning
     with warnings.catch_warnings(record=True):
         warnings.simplefilter('error', UserWarning)
         self.assertRaises(UserWarning, rtr.append, tr)
     # append with gap_overlap_check=True will raise a TypeError
     self.assertRaises(TypeError, rtr.append, tr, gap_overlap_check=True)
开发者ID:,项目名称:,代码行数:13,代码来源:

示例5: test_rt_offset

    def test_rt_offset(self):

        offset=500

        rt_trace=RtTrace()
        rt_trace.registerRtProcess('offset',offset=offset)

        for tr in self.traces:
            rt_trace.append(tr, gap_overlap_check = True)


        diff=self.data_trace.copy()
        diff.data=rt_trace.data-self.data_trace.data
        self.assertAlmostEquals(np.mean(np.abs(diff)),offset)
开发者ID:amaggi,项目名称:rt-waveloc,代码行数:14,代码来源:test_processing.py

示例6: test_rt_neg_to_zero

    def test_rt_neg_to_zero(self):

        data_trace=self.data_trace.copy()
        max_val=np.max(data_trace.data)
        
        rt_trace=RtTrace()
        rt_trace.registerRtProcess('neg_to_zero')

        for tr in self.traces:
            rt_trace.append(tr, gap_overlap_check = True)

        max_val_test=np.max(rt_trace.data)
        min_val_test=np.min(rt_trace.data)
        self.assertEqual(max_val, max_val_test)
        self.assertEqual(0.0, min_val_test)
开发者ID:amaggi,项目名称:rt-waveloc,代码行数:15,代码来源:test_processing.py

示例7: test_appendGap

 def test_appendGap(self):
     """
     Appending a traces with a time gap should raise a UserWarning/TypeError
     """
     rtr = RtTrace()
     tr = Trace(data=np.array([0, 1]))
     tr2 = Trace(data=np.array([5, 6]))
     tr2.stats.starttime = tr.stats.starttime + 10
     rtr.append(tr)
     # this raises UserWarning
     with warnings.catch_warnings(record=True):
         warnings.simplefilter('error', UserWarning)
         self.assertRaises(UserWarning, rtr.append, tr2)
     # append with gap_overlap_check=True will raise a TypeError
     self.assertRaises(TypeError, rtr.append, tr2, gap_overlap_check=True)
开发者ID:,项目名称:,代码行数:15,代码来源:

示例8: test_rt_variance

    def test_rt_variance(self):


        win=10

        data_trace=self.data_trace.copy()

        rt_single=RtTrace()
        rt_trace=RtTrace()
        rt_trace.registerRtProcess('variance',win=win)
        rt_single.registerRtProcess('variance',win=win)

        for tr in self.traces:
            rt_trace.append(tr, gap_overlap_check = True)
        rt_single.append(data_trace, gap_overlap_check = True)

        assert_array_almost_equal(rt_single, rt_trace)
开发者ID:amaggi,项目名称:rt-waveloc,代码行数:17,代码来源:test_processing.py

示例9: test_rt_scale

    def test_rt_scale(self):

        data_trace = self.data_trace.copy()

        fact=1/np.std(data_trace.data)

        data_trace.data *= fact

        rt_trace=RtTrace()
        rt_trace.registerRtProcess('scale',factor=fact)

        for tr in self.traces:
            rt_trace.append(tr, gap_overlap_check = True)

        diff=self.data_trace.copy()
        diff.data=rt_trace.data-data_trace.data
        self.assertAlmostEquals(np.mean(np.abs(diff)),0.0)
开发者ID:amaggi,项目名称:rt-waveloc,代码行数:17,代码来源:test_processing.py

示例10: test_sw_kurtosis

    def test_sw_kurtosis(self):
        win=3.0

        data_trace = self.data_trace.copy()

        rt_trace=RtTrace()
        rt_single=RtTrace()

        rt_trace.registerRtProcess('sw_kurtosis',win=win)
        rt_single.registerRtProcess('sw_kurtosis',win=win)

        for tr in self.traces:
            rt_trace.append(tr, gap_overlap_check = True)
        rt_single.append(data_trace)
   
        diff=self.data_trace.copy()
        diff.data=rt_trace.data-rt_single.data
        self.assertAlmostEquals(np.mean(np.abs(diff)),0.0)
开发者ID:amaggi,项目名称:rt-waveloc,代码行数:18,代码来源:test_processing.py

示例11: test_rt_mean

    def test_rt_mean(self):

        win=0.05

        data_trace=self.data_trace.copy()

        rt_single=RtTrace()
        rt_trace=RtTrace()
        rt_trace.registerRtProcess('mean',win=win)
        rt_single.registerRtProcess('mean',win=win)

        for tr in self.traces:
            rt_trace.append(tr, gap_overlap_check = True)
        rt_single.append(data_trace, gap_overlap_check = True)

        newtr=self.data_trace.copy()
        newtr.data=newtr.data-rt_trace.data
        assert_array_almost_equal(rt_single, rt_trace)
        self.assertAlmostEqual(np.mean(newtr.data),0.0,0)
开发者ID:amaggi,项目名称:rt-waveloc,代码行数:19,代码来源:test_processing.py

示例12: test_rt_gaussian_filter

    def test_rt_gaussian_filter(self):
        from am_signal import gaussian_filter

        data_trace = self.data_trace.copy()
        gauss5,tshift = gaussian_filter(1.0, 5.0, 0.01)

        rt_trace=RtTrace()
        rt_single=RtTrace()
        for rtt in [rt_trace, rt_single]:
            rtt.registerRtProcess('convolve',conv_signal=gauss5)

        rt_single.append(data_trace, gap_overlap_check = True)

        for tr in self.traces:
            # pre-apply inversed time-shift before appending data
            tr.stats.starttime -= tshift
            rt_trace.append(tr, gap_overlap_check = True)

        # test the waveforms are the same
        diff=self.data_trace.copy()
        diff.data=rt_trace.data-rt_single.data
        self.assertAlmostEquals(np.mean(np.abs(diff)),0.0)
        # test the time-shifts
        starttime_diff=rt_single.stats.starttime-self.data_trace.stats.starttime
        self.assertAlmostEquals(starttime_diff,0.0)
开发者ID:amaggi,项目名称:rt-waveloc,代码行数:25,代码来源:test_processing.py

示例13: test_rt_kurt_grad

    def test_rt_kurt_grad(self):
        win=3.0 
        data_trace = self.data_trace.copy()

        sigma=float(np.std(data_trace.data))
        fact = 1/sigma

        rt_trace=RtTrace()
        rt_trace_single = RtTrace()

        for rtt in [rt_trace, rt_trace_single]:
            rtt.registerRtProcess('scale',factor=fact)
            rtt.registerRtProcess('kurtosis',win=win)
            rtt.registerRtProcess('boxcar',width=50)
            rtt.registerRtProcess('differentiate')
            rtt.registerRtProcess('neg_to_zero')

        rt_trace_single.append(data_trace)
        
        for tr in self.traces:
            rt_trace.append(tr, gap_overlap_check = True)

        diff=self.data_trace.copy()
        diff.data=rt_trace_single.data - rt_trace.data
        self.assertAlmostEquals(np.mean(np.abs(diff)), 0.0, 5)
开发者ID:amaggi,项目名称:rt-waveloc,代码行数:25,代码来源:test_processing.py

示例14: _runRtProcess

    def _runRtProcess(self, process_list, max_length=None):
        """
        Helper function to create a RtTrace, register all given process
        functions and run the real time processing.
        """
        # assemble real time trace
        self.rt_trace = RtTrace(max_length=max_length)

        for (process, options) in process_list:
            self.rt_trace.registerRtProcess(process, **options)

        # append packet data to RtTrace
        self.rt_appended_traces = []
        for trace in self.orig_trace_chunks:
            # process single trace
            result = self.rt_trace.append(trace, gap_overlap_check=True)
            # add to list of appended traces
            self.rt_appended_traces.append(result)
开发者ID:gthompson,项目名称:obspy,代码行数:18,代码来源:test_signal.py

示例15: test_rt_kurtosis

    def test_rt_kurtosis(self):
        win=3.0
        data_trace = self.data_trace.copy()

        sigma=float(np.std(data_trace.data))
        fact = 1/sigma

        dt=data_trace.stats.delta
        C1=dt/float(win)

        x=data_trace.data
        ktrace=data_trace.copy()
        ktrace.data=rec_kurtosis(x*fact,C1)

        rt_trace=RtTrace()
        rt_trace.registerRtProcess('scale',factor=fact)
        rt_trace.registerRtProcess('kurtosis',win=win)

        for tr in self.traces:
            rt_trace.append(tr, gap_overlap_check = True)
   
        diff=self.data_trace.copy()
        diff.data=rt_trace.data-ktrace.data
        self.assertAlmostEquals(np.mean(np.abs(diff)),0.0)
开发者ID:amaggi,项目名称:rt-waveloc,代码行数:24,代码来源:test_processing.py


注:本文中的obspy.realtime.RtTrace类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。