本文整理汇总了Python中scipy.ndimage.convolve1d方法的典型用法代码示例。如果您正苦于以下问题:Python ndimage.convolve1d方法的具体用法?Python ndimage.convolve1d怎么用?Python ndimage.convolve1d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.ndimage
的用法示例。
在下文中一共展示了ndimage.convolve1d方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filter_waveforms
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_filter_waveforms():
"""Test that filter_records gives the same output
as a simple convolution applied to the original pulse
(before splitting into records)
"""
wv = np.random.randn(300)
ir = np.random.randn(41)
ir[10] += 10 # Because it crashes for max at edges
origin = np.argmax(ir) - (len(ir)//2)
wv_after = convolve1d(wv, ir,
mode='constant',
origin=origin)
wvs = wv.reshape(3, 100)
wvs = strax.filter_waveforms(
wvs, ir,
prev_r=np.array([strax.NO_RECORD_LINK, 0, 1]),
next_r=np.array([1, 2, strax.NO_RECORD_LINK]))
wv_after_2 = np.reshape(wvs, -1)
assert np.abs(wv_after - wv_after_2).sum() < 1e-9
示例2: test_correlate01
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate01(self):
array = numpy.array([1, 2])
weights = numpy.array([2])
expected = [2, 4]
output = ndimage.correlate(array, weights)
assert_array_almost_equal(output, expected)
output = ndimage.convolve(array, weights)
assert_array_almost_equal(output, expected)
output = ndimage.correlate1d(array, weights)
assert_array_almost_equal(output, expected)
output = ndimage.convolve1d(array, weights)
assert_array_almost_equal(output, expected)
示例3: test_correlate03
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate03(self):
array = numpy.array([1])
weights = numpy.array([1, 1])
expected = [2]
output = ndimage.correlate(array, weights)
assert_array_almost_equal(output, expected)
output = ndimage.convolve(array, weights)
assert_array_almost_equal(output, expected)
output = ndimage.correlate1d(array, weights)
assert_array_almost_equal(output, expected)
output = ndimage.convolve1d(array, weights)
assert_array_almost_equal(output, expected)
示例4: test_correlate02
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate02(self):
array = numpy.array([1, 2, 3])
kernel = numpy.array([1])
output = ndimage.correlate(array, kernel)
assert_array_almost_equal(array, output)
output = ndimage.convolve(array, kernel)
assert_array_almost_equal(array, output)
output = ndimage.correlate1d(array, kernel)
assert_array_almost_equal(array, output)
output = ndimage.convolve1d(array, kernel)
assert_array_almost_equal(array, output)
示例5: test_correlate04
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate04(self):
array = numpy.array([1, 2])
tcor = [2, 3]
tcov = [3, 4]
weights = numpy.array([1, 1])
output = ndimage.correlate(array, weights)
assert_array_almost_equal(output, tcor)
output = ndimage.convolve(array, weights)
assert_array_almost_equal(output, tcov)
output = ndimage.correlate1d(array, weights)
assert_array_almost_equal(output, tcor)
output = ndimage.convolve1d(array, weights)
assert_array_almost_equal(output, tcov)
示例6: test_correlate05
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate05(self):
array = numpy.array([1, 2, 3])
tcor = [2, 3, 5]
tcov = [3, 5, 6]
kernel = numpy.array([1, 1])
output = ndimage.correlate(array, kernel)
assert_array_almost_equal(tcor, output)
output = ndimage.convolve(array, kernel)
assert_array_almost_equal(tcov, output)
output = ndimage.correlate1d(array, kernel)
assert_array_almost_equal(tcor, output)
output = ndimage.convolve1d(array, kernel)
assert_array_almost_equal(tcov, output)
示例7: test_correlate07
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate07(self):
array = numpy.array([1, 2, 3])
expected = [5, 8, 11]
weights = numpy.array([1, 2, 1])
output = ndimage.correlate(array, weights)
assert_array_almost_equal(output, expected)
output = ndimage.convolve(array, weights)
assert_array_almost_equal(output, expected)
output = ndimage.correlate1d(array, weights)
assert_array_almost_equal(output, expected)
output = ndimage.convolve1d(array, weights)
assert_array_almost_equal(output, expected)
示例8: test_correlate08
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate08(self):
array = numpy.array([1, 2, 3])
tcor = [1, 2, 5]
tcov = [3, 6, 7]
weights = numpy.array([1, 2, -1])
output = ndimage.correlate(array, weights)
assert_array_almost_equal(output, tcor)
output = ndimage.convolve(array, weights)
assert_array_almost_equal(output, tcov)
output = ndimage.correlate1d(array, weights)
assert_array_almost_equal(output, tcor)
output = ndimage.convolve1d(array, weights)
assert_array_almost_equal(output, tcov)
示例9: test_correlate09
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate09(self):
array = []
kernel = numpy.array([1, 1])
output = ndimage.correlate(array, kernel)
assert_array_almost_equal(array, output)
output = ndimage.convolve(array, kernel)
assert_array_almost_equal(array, output)
output = ndimage.correlate1d(array, kernel)
assert_array_almost_equal(array, output)
output = ndimage.convolve1d(array, kernel)
assert_array_almost_equal(array, output)
示例10: test_correlate17
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate17(self):
array = numpy.array([1, 2, 3])
tcor = [3, 5, 6]
tcov = [2, 3, 5]
kernel = numpy.array([1, 1])
output = ndimage.correlate(array, kernel, origin=-1)
assert_array_almost_equal(tcor, output)
output = ndimage.convolve(array, kernel, origin=-1)
assert_array_almost_equal(tcov, output)
output = ndimage.correlate1d(array, kernel, origin=-1)
assert_array_almost_equal(tcor, output)
output = ndimage.convolve1d(array, kernel, origin=-1)
assert_array_almost_equal(tcov, output)
示例11: test_correlate20
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate20(self):
weights = numpy.array([1, 2, 1])
expected = [[5, 10, 15], [7, 14, 21]]
for type1 in self.types:
array = numpy.array([[1, 2, 3],
[2, 4, 6]], type1)
for type2 in self.types:
output = numpy.zeros((2, 3), type2)
ndimage.correlate1d(array, weights, axis=0,
output=output)
assert_array_almost_equal(output, expected)
ndimage.convolve1d(array, weights, axis=0,
output=output)
assert_array_almost_equal(output, expected)
示例12: test_correlate22
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate22(self):
weights = numpy.array([1, 2, 1])
expected = [[6, 12, 18], [6, 12, 18]]
for type1 in self.types:
array = numpy.array([[1, 2, 3],
[2, 4, 6]], type1)
for type2 in self.types:
output = numpy.zeros((2, 3), type2)
ndimage.correlate1d(array, weights, axis=0,
mode='wrap', output=output)
assert_array_almost_equal(output, expected)
ndimage.convolve1d(array, weights, axis=0,
mode='wrap', output=output)
assert_array_almost_equal(output, expected)
示例13: test_correlate23
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate23(self):
weights = numpy.array([1, 2, 1])
expected = [[5, 10, 15], [7, 14, 21]]
for type1 in self.types:
array = numpy.array([[1, 2, 3],
[2, 4, 6]], type1)
for type2 in self.types:
output = numpy.zeros((2, 3), type2)
ndimage.correlate1d(array, weights, axis=0,
mode='nearest', output=output)
assert_array_almost_equal(output, expected)
ndimage.convolve1d(array, weights, axis=0,
mode='nearest', output=output)
assert_array_almost_equal(output, expected)
示例14: test_correlate24
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate24(self):
weights = numpy.array([1, 2, 1])
tcor = [[7, 14, 21], [8, 16, 24]]
tcov = [[4, 8, 12], [5, 10, 15]]
for type1 in self.types:
array = numpy.array([[1, 2, 3],
[2, 4, 6]], type1)
for type2 in self.types:
output = numpy.zeros((2, 3), type2)
ndimage.correlate1d(array, weights, axis=0,
mode='nearest', output=output, origin=-1)
assert_array_almost_equal(output, tcor)
ndimage.convolve1d(array, weights, axis=0,
mode='nearest', output=output, origin=-1)
assert_array_almost_equal(output, tcov)
示例15: test_correlate25
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import convolve1d [as 别名]
def test_correlate25(self):
weights = numpy.array([1, 2, 1])
tcor = [[4, 8, 12], [5, 10, 15]]
tcov = [[7, 14, 21], [8, 16, 24]]
for type1 in self.types:
array = numpy.array([[1, 2, 3],
[2, 4, 6]], type1)
for type2 in self.types:
output = numpy.zeros((2, 3), type2)
ndimage.correlate1d(array, weights, axis=0,
mode='nearest', output=output, origin=1)
assert_array_almost_equal(output, tcor)
ndimage.convolve1d(array, weights, axis=0,
mode='nearest', output=output, origin=1)
assert_array_almost_equal(output, tcov)