本文整理汇总了Python中hyperspy.signal.Signal.rebin方法的典型用法代码示例。如果您正苦于以下问题:Python Signal.rebin方法的具体用法?Python Signal.rebin怎么用?Python Signal.rebin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hyperspy.signal.Signal
的用法示例。
在下文中一共展示了Signal.rebin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from hyperspy.signal import Signal [as 别名]
# 或者: from hyperspy.signal.Signal import rebin [as 别名]
class Test3D:
def setUp(self):
self.signal = Signal(np.arange(2 * 4 * 6).reshape(2, 4, 6))
self.signal.axes_manager[0].name = "x"
self.signal.axes_manager[1].name = "y"
self.signal.axes_manager[2].name = "E"
self.signal.axes_manager[0].scale = 0.5
self.data = self.signal.data.copy()
def test_rebin(self):
assert_true(self.signal.rebin((2, 1, 6)).data.shape == (1, 2, 6))
def test_swap_axes(self):
s = self.signal
assert_equal(s.swap_axes(0, 1).data.shape, (4, 2, 6))
assert_true(s.swap_axes(0, 2).data.flags['C_CONTIGUOUS'])
示例2: setUp
# 需要导入模块: from hyperspy.signal import Signal [as 别名]
# 或者: from hyperspy.signal.Signal import rebin [as 别名]
class Test3D:
def setUp(self):
self.signal = Signal(np.arange(2*4*6).reshape(2,4,6))
self.signal.axes_manager[0].name = "x"
self.signal.axes_manager[1].name = "y"
self.signal.axes_manager[2].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_rebin(self):
assert_true(self.signal.rebin((2,1,6)).data.shape == (1,2,6))
def test_swap_axes(self):
s = self.signal
assert_equal(s.swap_axes(0,1).data.shape, (4,2,6))
assert_true(s.swap_axes(0,2).data.flags['C_CONTIGUOUS'])
示例3: setUp
# 需要导入模块: from hyperspy.signal import Signal [as 别名]
# 或者: from hyperspy.signal.Signal import rebin [as 别名]
class Test3D:
def setUp(self):
self.signal = Signal(np.arange(2 * 4 * 6).reshape(2, 4, 6))
self.signal.axes_manager[0].name = "x"
self.signal.axes_manager[1].name = "y"
self.signal.axes_manager[2].name = "E"
self.signal.axes_manager[0].scale = 0.5
self.data = self.signal.data.copy()
def test_indexmax(self):
s = self.signal.indexmax('E')
ar = self.data.argmax(2)
np.testing.assert_array_equal(ar, s.data)
nt.assert_equal(s.data.ndim, 2)
nt.assert_equal(s.axes_manager.signal_dimension, 0)
nt.assert_equal(s.axes_manager.navigation_dimension, 2)
def test_valuemax(self):
s = self.signal.valuemax('x')
ar = self.signal.axes_manager['x'].index2value(self.data.argmax(1))
np.testing.assert_array_equal(ar, s.data)
nt.assert_equal(s.data.ndim, 2)
nt.assert_equal(s.axes_manager.signal_dimension, 1)
nt.assert_equal(s.axes_manager.navigation_dimension, 1)
def test_default_navigation_sum(self):
_test_default_navigation_signal_operations_over_many_axes(self, 'sum')
def test_default_navigation_max(self):
_test_default_navigation_signal_operations_over_many_axes(self, 'max')
def test_default_navigation_min(self):
_test_default_navigation_signal_operations_over_many_axes(self, 'min')
def test_default_navigation_mean(self):
_test_default_navigation_signal_operations_over_many_axes(self, 'mean')
def test_default_navigation_std(self):
_test_default_navigation_signal_operations_over_many_axes(self, 'std')
def test_default_navigation_var(self):
_test_default_navigation_signal_operations_over_many_axes(self, 'var')
def test_rebin(self):
self.signal.estimate_poissonian_noise_variance()
new_s = self.signal.rebin((2, 1, 6))
var = new_s.metadata.Signal.Noise_properties.variance
nt.assert_true(new_s.data.shape == (1, 2, 6))
nt.assert_true(var.data.shape == (1, 2, 6))
from hyperspy.misc.array_tools import rebin
nt.assert_true(np.all(rebin(self.signal.data, (1, 2, 6)) == var.data))
nt.assert_true(
np.all(
rebin(
self.signal.data, (1, 2, 6)) == new_s.data))
@nt.raises(AttributeError)
def test_rebin_no_variance(self):
new_s = self.signal.rebin((2, 1, 6))
_ = new_s.metadata.Signal.Noise_properties
def test_rebin_const_variance(self):
self.signal.metadata.set_item('Signal.Noise_properties.variance', 0.3)
new_s = self.signal.rebin((2, 1, 6))
nt.assert_true(new_s.metadata.Signal.Noise_properties.variance == 0.3)
def test_swap_axes(self):
s = self.signal
nt.assert_equal(s.swap_axes(0, 1).data.shape, (4, 2, 6))
nt.assert_true(s.swap_axes(0, 2).data.flags['C_CONTIGUOUS'])
def test_get_navigation_signal_nav_dim0(self):
s = self.signal
s.axes_manager.set_signal_dimension(3)
ns = s._get_navigation_signal()
nt.assert_equal(ns.axes_manager.signal_dimension, 1)
nt.assert_equal(ns.axes_manager.signal_size, 1)
nt.assert_equal(ns.axes_manager.navigation_dimension, 0)
def test_get_navigation_signal_nav_dim1(self):
s = self.signal
s.axes_manager.set_signal_dimension(2)
ns = s._get_navigation_signal()
nt.assert_equal(ns.axes_manager.signal_shape,
s.axes_manager.navigation_shape)
nt.assert_equal(ns.axes_manager.navigation_dimension, 0)
def test_get_navigation_signal_nav_dim2(self):
s = self.signal
s.axes_manager.set_signal_dimension(1)
ns = s._get_navigation_signal()
nt.assert_equal(ns.axes_manager.signal_shape,
s.axes_manager.navigation_shape)
nt.assert_equal(ns.axes_manager.navigation_dimension, 0)
def test_get_navigation_signal_nav_dim3(self):
s = self.signal
s.axes_manager.set_signal_dimension(0)
ns = s._get_navigation_signal()
#.........这里部分代码省略.........