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


Python Signal.split方法代码示例

本文整理汇总了Python中hyperspy.signal.Signal.split方法的典型用法代码示例。如果您正苦于以下问题:Python Signal.split方法的具体用法?Python Signal.split怎么用?Python Signal.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hyperspy.signal.Signal的用法示例。


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

示例1: setUp

# 需要导入模块: from hyperspy.signal import Signal [as 别名]
# 或者: from hyperspy.signal.Signal import split [as 别名]
class Test2D:
    def setUp(self):
        self.signal = Signal(np.arange(5*10).reshape(5,10))
        self.signal.axes_manager[0].name = "x"
        self.signal.axes_manager[1].name = "E"
        self.signal.axes_manager[0].scale = 0.5
        self.signal.mapped_parameters.set_item('splitting.axis', 0)
        self.signal.mapped_parameters.set_item(
                                        'splitting.step_sizes',[2,2])
        self.data = self.signal.data.copy()

        
    def test_axis_by_str(self):
        s1 = self.signal.deepcopy()
        s2 = self.signal.deepcopy()
        s1.crop(0, 2,4)
        s2.crop("x", 2, 4)
        assert_true((s1.data==s2.data).all())
        
    def test_crop_int(self):
        s = self.signal
        d = self.data
        s.crop(0, 2,4)
        assert_true((s.data==d[2:4,:]).all())
        
    def test_crop_float(self):
        s = self.signal
        d = self.data
        s.crop(0, 2, 2.)
        assert_true((s.data==d[2:4,:]).all())
        
    def test_split_axis0(self):
        result = self.signal.split(0,2)
        assert_true(len(result) == 2)
        assert_true((result[0].data == self.data[:2,:]).all())
        assert_true((result[1].data == self.data[2:4,:]).all())
    
    def test_split_axis1(self):
        result = self.signal.split(1,2)
        assert_true(len(result) == 2)
        assert_true((result[0].data == self.data[:,:5]).all())
        assert_true((result[1].data == self.data[:,5:]).all())
        
    def test_split_axisE(self):
        result = self.signal.split("E",2)
        assert_true(len(result) == 2)
        assert_true((result[0].data == self.data[:,:5]).all())
        assert_true((result[1].data == self.data[:,5:]).all())
        
    def test_split_default(self):
        result = self.signal.split()
        assert_true(len(result) == 2)
        assert_true((result[0].data == self.data[:2,:]).all())
        assert_true((result[1].data == self.data[2:4,:]).all())
    
    def test_histogram(self):
        result = self.signal.get_histogram(3)
        assert_true(isinstance(result,signals.Spectrum))
        assert_true((result.data==np.array([17, 16, 17])).all())
开发者ID:Emilieringe,项目名称:hyperspy,代码行数:61,代码来源:test_tools.py

示例2: setUp

# 需要导入模块: from hyperspy.signal import Signal [as 别名]
# 或者: from hyperspy.signal.Signal import split [as 别名]
class Test2D:

    def setUp(self):
        self.signal = Signal(np.arange(5 * 10).reshape(5, 10))
        self.signal.axes_manager[0].name = "x"
        self.signal.axes_manager[1].name = "E"
        self.signal.axes_manager[0].scale = 0.5
        self.data = self.signal.data.copy()

    def test_axis_by_str(self):
        s1 = self.signal.deepcopy()
        s2 = self.signal.deepcopy()
        s1.crop(0, 2, 4)
        s2.crop("x", 2, 4)
        assert_true((s1.data == s2.data).all())

    def test_crop_int(self):
        s = self.signal
        d = self.data
        s.crop(0, 2, 4)
        assert_true((s.data == d[2:4, :]).all())

    def test_crop_float(self):
        s = self.signal
        d = self.data
        s.crop(0, 2, 2.)
        assert_true((s.data == d[2:4, :]).all())

    def test_split_axis0(self):
        result = self.signal.split(0, 2)
        assert_true(len(result) == 2)
        assert_true((result[0].data == self.data[:2, :]).all())
        assert_true((result[1].data == self.data[2:4, :]).all())

    def test_split_axis1(self):
        result = self.signal.split(1, 2)
        assert_true(len(result) == 2)
        assert_true((result[0].data == self.data[:, :5]).all())
        assert_true((result[1].data == self.data[:, 5:]).all())

    def test_split_axisE(self):
        result = self.signal.split("E", 2)
        assert_true(len(result) == 2)
        assert_true((result[0].data == self.data[:, :5]).all())
        assert_true((result[1].data == self.data[:, 5:]).all())

    def test_split_default(self):
        result = self.signal.split()
        assert_true(len(result) == 5)
        assert_true((result[0].data == self.data[0]).all())

    def test_histogram(self):
        result = self.signal.get_histogram(3)
        assert_true(isinstance(result, signals.Spectrum))
        assert_true((result.data == np.array([17, 16, 17])).all())

    def test_estimate_poissonian_noise_copy_data(self):
        self.signal.estimate_poissonian_noise_variance()
        assert_true(self.signal.metadata.Signal.Noise_properties.variance.data
                    is not self.signal.data)

    def test_estimate_poissonian_noise_noarg(self):
        self.signal.estimate_poissonian_noise_variance()
        assert_true(
            (self.signal.metadata.Signal.Noise_properties.variance.data ==
             self.signal.data).all())

    def test_estimate_poissonian_noise_with_args(self):
        self.signal.estimate_poissonian_noise_variance(
            expected_value=self.signal,
            gain_factor=2,
            gain_offset=1,
            correlation_factor=0.5)
        assert_true(
            (self.signal.metadata.Signal.Noise_properties.variance.data ==
             (self.signal.data * 2 + 1) * 0.5).all())
开发者ID:LewysJones,项目名称:hyperspy,代码行数:78,代码来源:test_tools.py

示例3: setUp

# 需要导入模块: from hyperspy.signal import Signal [as 别名]
# 或者: from hyperspy.signal.Signal import split [as 别名]
class Test2D:

    def setUp(self):
        self.signal = Signal(np.arange(5 * 10).reshape(5, 10))
        self.signal.axes_manager[0].name = "x"
        self.signal.axes_manager[1].name = "E"
        self.signal.axes_manager[0].scale = 0.5
        self.data = self.signal.data.copy()

    def test_sum_x(self):
        s = self.signal.sum("x")
        np.testing.assert_array_equal(self.signal.data.sum(0), s.data)
        nt.assert_equal(s.data.ndim, 1)
        nt.assert_equal(s.axes_manager.navigation_dimension, 0)

    def test_sum_x_E(self):
        s = self.signal.sum(("x", "E"))
        _verify_test_sum_x_E(self, s)
        s = self.signal.sum((0, "E"))
        _verify_test_sum_x_E(self, s)
        s = self.signal.sum((self.signal.axes_manager[0], "E"))
        _verify_test_sum_x_E(self, s)
        s = self.signal.sum("x").sum("E")
        _verify_test_sum_x_E(self, s)

    def test_axis_by_str(self):
        m = mock.Mock()
        s1 = self.signal.deepcopy()
        s1.events.data_changed.connect(m.data_changed)
        s2 = self.signal.deepcopy()
        s1.crop(0, 2, 4)
        nt.assert_true(m.data_changed.called)
        s2.crop("x", 2, 4)
        nt.assert_true((s1.data == s2.data).all())

    def test_crop_int(self):
        s = self.signal
        d = self.data
        s.crop(0, 2, 4)
        nt.assert_true((s.data == d[2:4, :]).all())

    def test_crop_float(self):
        s = self.signal
        d = self.data
        s.crop(0, 2, 2.)
        nt.assert_true((s.data == d[2:4, :]).all())

    def test_split_axis0(self):
        result = self.signal.split(0, 2)
        nt.assert_true(len(result) == 2)
        nt.assert_true((result[0].data == self.data[:2, :]).all())
        nt.assert_true((result[1].data == self.data[2:4, :]).all())

    def test_split_axis1(self):
        result = self.signal.split(1, 2)
        nt.assert_true(len(result) == 2)
        nt.assert_true((result[0].data == self.data[:, :5]).all())
        nt.assert_true((result[1].data == self.data[:, 5:]).all())

    def test_split_axisE(self):
        result = self.signal.split("E", 2)
        nt.assert_true(len(result) == 2)
        nt.assert_true((result[0].data == self.data[:, :5]).all())
        nt.assert_true((result[1].data == self.data[:, 5:]).all())

    def test_split_default(self):
        result = self.signal.split()
        nt.assert_true(len(result) == 5)
        nt.assert_true((result[0].data == self.data[0]).all())

    def test_histogram(self):
        result = self.signal.get_histogram(3)
        nt.assert_true(isinstance(result, signals.Spectrum))
        nt.assert_true((result.data == np.array([17, 16, 17])).all())
        nt.assert_true(result.metadata.Signal.binned)

    def test_estimate_poissonian_noise_copy_data(self):
        self.signal.estimate_poissonian_noise_variance()
        variance = self.signal.metadata.Signal.Noise_properties.variance
        nt.assert_true(
            variance.data is not self.signal.data)

    def test_estimate_poissonian_noise_noarg(self):
        self.signal.estimate_poissonian_noise_variance()
        variance = self.signal.metadata.Signal.Noise_properties.variance
        nt.assert_true((variance.data == self.signal.data).all())

    def test_estimate_poissonian_noise_with_args(self):
        self.signal.estimate_poissonian_noise_variance(
            expected_value=self.signal,
            gain_factor=2,
            gain_offset=1,
            correlation_factor=0.5)
        variance = self.signal.metadata.Signal.Noise_properties.variance
        nt.assert_true(
            (variance.data == (self.signal.data * 2 + 1) * 0.5).all())

    def test_unfold_image(self):
        s = self.signal
        s.axes_manager.set_signal_dimension(2)
#.........这里部分代码省略.........
开发者ID:temcode,项目名称:hyperspy,代码行数:103,代码来源:test_tools.py


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