本文整理汇总了Python中obspy.core.Trace.decimate方法的典型用法代码示例。如果您正苦于以下问题:Python Trace.decimate方法的具体用法?Python Trace.decimate怎么用?Python Trace.decimate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.Trace
的用法示例。
在下文中一共展示了Trace.decimate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_decimate
# 需要导入模块: from obspy.core import Trace [as 别名]
# 或者: from obspy.core.Trace import decimate [as 别名]
def test_decimate(self):
"""
Tests the decimate method of the Trace object.
"""
# create test Trace
tr = Trace(data=np.arange(20))
tr_bkp = deepcopy(tr)
# some test that should fail and leave the original trace alone
self.assertRaises(ValueError, tr.decimate, 7, strict_length=True)
self.assertRaises(ValueError, tr.decimate, 9, strict_length=True)
self.assertRaises(ArithmeticError, tr.decimate, 18)
# some tests in place
tr.decimate(4, no_filter=True)
np.testing.assert_array_equal(tr.data, np.arange(0, 20, 4))
self.assertEqual(tr.stats.npts, 5)
self.assertEqual(tr.stats.sampling_rate, 0.25)
self.assertEqual(tr.stats.processing,
["downsample:integerDecimation:4"])
tr = tr_bkp.copy()
tr.decimate(10, no_filter=True)
np.testing.assert_array_equal(tr.data, np.arange(0, 20, 10))
self.assertEqual(tr.stats.npts, 2)
self.assertEqual(tr.stats.sampling_rate, 0.1)
self.assertEqual(tr.stats.processing,
["downsample:integerDecimation:10"])
# some tests with automatic prefiltering
tr = tr_bkp.copy()
tr2 = tr_bkp.copy()
tr.decimate(4)
df = tr2.stats.sampling_rate
tr2.data, fp = lowpassCheby2(data=tr2.data, freq=df * 0.5 / 4.0,
df=df, maxorder=12, ba=False,
freq_passband=True)
# check that iteratively determined pass band frequency is correct
self.assertAlmostEquals(0.0811378285461, fp, places=7)
tr2.decimate(4, no_filter=True)
np.testing.assert_array_equal(tr.data, tr2.data)