本文整理匯總了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)