本文整理汇总了Python中mayavi.sources.array_source.ArraySource.get_output_dataset方法的典型用法代码示例。如果您正苦于以下问题:Python ArraySource.get_output_dataset方法的具体用法?Python ArraySource.get_output_dataset怎么用?Python ArraySource.get_output_dataset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mayavi.sources.array_source.ArraySource
的用法示例。
在下文中一共展示了ArraySource.get_output_dataset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset
# 需要导入模块: from mayavi.sources.array_source import ArraySource [as 别名]
# 或者: from mayavi.sources.array_source.ArraySource import get_output_dataset [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)
x, y, mask = self.x, self.y, self.mask
scalars = self.scalars
# We may have used this without specifying x and y at all in
# which case we set them from the shape of scalars.
nx, ny = scalars.shape
#Build X and Y from shape of Scalars if they are none
if x is None and y is None:
x, y = np.mgrid[-nx / 2.:nx / 2, -ny / 2.:ny / 2]
if mask is not None and len(mask) > 0:
scalars[mask.astype('bool')] = np.nan
# The NaN trick only works with floats.
scalars = scalars.astype('float')
self.set(scalars=scalars, trait_change_notify=False)
z = np.array([0])
self.set(x=x, y=y, z=z, trait_change_notify=False)
# Do some magic to extract the first row/column, independently of
# the shape of x and y
x = np.atleast_2d(x.squeeze().T)[0, :].squeeze()
y = np.atleast_2d(y.squeeze())[0, :].squeeze()
if x.ndim == 0:
dx = 1
else:
dx = x[1] - x[0]
if y.ndim == 0:
dy = 1
else:
dy = y[1] - y[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(origin=[x.min(), y.min(), 0],
spacing=[dx, dy, 1],
scalar_data=scalars)
if old_scalar is scalars:
ds._scalar_data_changed(scalars)
self.dataset = ds.get_output_dataset()
self.m_data = ds