本文整理汇总了Python中mayavi.sources.array_source.ArraySource.set方法的典型用法代码示例。如果您正苦于以下问题:Python ArraySource.set方法的具体用法?Python ArraySource.set怎么用?Python ArraySource.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mayavi.sources.array_source.ArraySource
的用法示例。
在下文中一共展示了ArraySource.set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset
# 需要导入模块: from mayavi.sources.array_source import ArraySource [as 别名]
# 或者: from mayavi.sources.array_source.ArraySource import set [as 别名]
def reset(self, **traits):
"""Creates the dataset afresh or resets existing data source."""
# First set the attributes without really doing anything since
# the notification handlers are not called.
self.set(trait_change_notify=False, **traits)
vectors = self.vectors
scalars = self.scalars
x, y, z = [np.atleast_3d(a) for a in self.x, self.y, self.z]
u, v, w = self.u, self.v, self.w
if 'vectors' in traits:
u = vectors[:, 0].ravel()
v = vectors[:, 1].ravel()
w = vectors[:, 2].ravel()
self.set(u=u, v=v, w=w, trait_change_notify=False)
else:
if u is not None and len(u) > 0:
#vectors = np.concatenate([u[..., np.newaxis],
# v[..., np.newaxis],
# w[..., np.newaxis] ],
# axis=3)
vectors = np.c_[u.ravel(), v.ravel(),
w.ravel()].ravel()
vectors.shape = (u.shape[0], u.shape[1], w.shape[2], 3)
self.set(vectors=vectors, trait_change_notify=False)
if vectors is not None and len(vectors) > 0 and scalars is not None:
assert len(scalars) == len(vectors)
if x.shape[0] <= 1:
dx = 1
else:
dx = x[1, 0, 0] - x[0, 0, 0]
if y.shape[1] <= 1:
dy = 1
else:
dy = y[0, 1, 0] - y[0, 0, 0]
if z.shape[2] <= 1:
dz = 1
else:
dz = z[0, 0, 1] - z[0, 0, 0]
if self.m_data is None:
ds = ArraySource(transpose_input_array=True)
else:
ds = self.m_data
old_scalar = ds.scalar_data
ds.set(vector_data=vectors,
origin=[x.min(), y.min(), z.min()],
spacing=[dx, dy, dz],
scalar_data=scalars)
if scalars is old_scalar:
ds._scalar_data_changed(scalars)
self.dataset = ds.image_data
self.m_data = ds