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


Python ndimage.convolve1d方法代码示例

本文整理汇总了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 
开发者ID:AxFoundation,项目名称:strax,代码行数:23,代码来源:test_pulse_processing.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:17,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:14,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:13,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:16,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:16,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:16,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:17,代码来源:test_ndimage.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:17,代码来源:test_ndimage.py


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