本文整理汇总了Python中mayavi.sources.array_source.ArraySource.spacing方法的典型用法代码示例。如果您正苦于以下问题:Python ArraySource.spacing方法的具体用法?Python ArraySource.spacing怎么用?Python ArraySource.spacing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mayavi.sources.array_source.ArraySource
的用法示例。
在下文中一共展示了ArraySource.spacing方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: view_data
# 需要导入模块: from mayavi.sources.array_source import ArraySource [as 别名]
# 或者: from mayavi.sources.array_source.ArraySource import spacing [as 别名]
def view_data(data):
"""Example showing how to view a 3D numpy array in mayavi2.
"""
def set_labelE(ind):
return '{0:.0f} eV'.format(source.energies[ind])
def move_view(obj, evt):
labelE.text = set_labelE(ipwX.ipw.slice_index)
pos = labelE.position
labelE.position = ipwX.ipw.slice_index * src.spacing[0] + 1,\
pos[1], pos[2]
labelE.vector_text.update()
def set_lut(ipw):
lutM = ipw.module_manager.scalar_lut_manager
# lutM.show_scalar_bar = True
# lutM.number_of_labels = 9
lutM.lut.scale = 'log10'
lutM.lut.range = [dataMax*vmin, dataMax]
lutM.lut_mode = 'hot'
@animate()
def anim(data, ipwX):
scene.scene.off_screen_rendering = True
scene.scene.anti_aliasing_frames = 0
for i in range(0, data.shape[0], 1):
ipwX.ipw.slice_index = i
move_view(None, None)
if saveName is not None:
scene.scene.save('{0}{1:04d}.png'.format(saveName, i))
yield
# 'mayavi' is always defined on the interpreter.
scene = mayavi.new_scene() # analysis:ignore
scene.scene.background = (0, 0, 0)
print(source.prefix_save_name())
src = ArraySource(transpose_input_array=True)
sh = data.shape
# print(sh)
if 'xrt' in source.prefix_save_name() or\
'srw' in source.prefix_save_name():
src.scalar_data = data[:, :sh[1]//2+1, :sh[2]//2+1].copy()
else:
src.scalar_data = data[:, ::-1, ::-1].copy()
# src.spacing = np.array([-0.05, 1, 1])
# src.spacing = np.array([-0.25, 1, 1])
src.spacing = np.array([-0.25, 0.25, 0.25])
mayavi.add_source(src) # analysis:ignore
# Visualize the data.
# o = Outline()
# mayavi.add_module(o)
ipwY = ImagePlaneWidget()
mayavi.add_module(ipwY) # analysis:ignore
ipwY.ipw.plane_orientation = 'y_axes' # our x-axis
ipwY.ipw.slice_index = int(data.shape[1] - 1)
# if 'xrt' in source.prefix_save_name():
# ipwY.ipw.slice_index /= int(2)
ipwY.ipw.left_button_action = 0
set_lut(ipwY)
if isZplane:
ipwZ = ImagePlaneWidget()
mayavi.add_module(ipwZ) # analysis:ignore
ipwZ.ipw.plane_orientation = 'z_axes' # our z-axis
ipwZ.ipw.slice_index = int(data.shape[2] - 1)
# if 'xrt' in source.prefix_save_name():
# ipwZ.ipw.slice_index /= int(2)
ipwZ.ipw.left_button_action = 0
if 'xrt' in source.prefix_save_name() or\
'srw' in source.prefix_save_name():
pass
else:
data = np.concatenate((data[:, :0:-1, :], data), axis=1)
data = np.concatenate((data[:, :, :0:-1], data), axis=2)
sh = data.shape
print(sh)
src = ArraySource(transpose_input_array=True)
src.scalar_data = data.copy()
# src.spacing = np.array([-0.05, 1, 1])
# src.spacing = np.array([-0.25, 1, 1])
src.spacing = np.array([-0.25, 0.25, 0.25])
mayavi.add_source(src) # analysis:ignore
ipwX = ImagePlaneWidget()
mayavi.add_module(ipwX) # analysis:ignore
ipwX.ipw.plane_orientation = 'x_axes' # energy
set_lut(ipwX)
ipwX.ipw.add_observer('WindowLevelEvent', move_view)
ipwX.ipw.add_observer('StartInteractionEvent', move_view)
ipwX.ipw.add_observer('EndInteractionEvent', move_view)
labelE = Text3D()
mayavi.add_module(labelE) # analysis:ignore
labelE.position = (1, data.shape[1]*0.73*src.spacing[1],
data.shape[2]*0.85*src.spacing[2])
labelE.orientation = 90, 0, 90
labelE.text = 'Energy'
#.........这里部分代码省略.........