本文整理汇总了Python中hyperspy.signal.Signal.estimate_poissonian_noise_variance方法的典型用法代码示例。如果您正苦于以下问题:Python Signal.estimate_poissonian_noise_variance方法的具体用法?Python Signal.estimate_poissonian_noise_variance怎么用?Python Signal.estimate_poissonian_noise_variance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hyperspy.signal.Signal
的用法示例。
在下文中一共展示了Signal.estimate_poissonian_noise_variance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from hyperspy.signal import Signal [as 别名]
# 或者: from hyperspy.signal.Signal import estimate_poissonian_noise_variance [as 别名]
class TestSignalVarianceFolding:
def setUp(self):
self.s = Signal(np.empty((2, 3, 4, 5)))
self.s.axes_manager.set_signal_dimension(2)
self.s.estimate_poissonian_noise_variance()
def test_unfold_navigation(self):
s = self.s.deepcopy()
s.unfold_navigation_space()
meta_am = s.metadata.Signal.Noise_properties.variance.axes_manager
nose.tools.assert_equal(meta_am.navigation_shape, (self.s.axes_manager.navigation_size,))
def test_unfold_signal(self):
s = self.s.deepcopy()
s.unfold_signal_space()
meta_am = s.metadata.Signal.Noise_properties.variance.axes_manager
nose.tools.assert_equal(meta_am.signal_shape, (self.s.axes_manager.signal_size,))
示例2: setUp
# 需要导入模块: from hyperspy.signal import Signal [as 别名]
# 或者: from hyperspy.signal.Signal import estimate_poissonian_noise_variance [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())
示例3: setUp
# 需要导入模块: from hyperspy.signal import Signal [as 别名]
# 或者: from hyperspy.signal.Signal import estimate_poissonian_noise_variance [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)
#.........这里部分代码省略.........