vtkmodules.util.data_model#

This module provides classes that allow numpy style access to VTK datasets. See examples at bottom.

模組目次#

類別#

FieldDataBase

Python-friendly interface for vtkFieldData and its subclasses.

FieldData

DataSetAttributesBase

DataSetAttributes

PointData

CellData

CompositeDataSetAttributesIterator

CompositeDataSetAttributes

This is a python friendly wrapper for vtkDataSetAttributes for composite datasets. Since composite datasets themselves don’t have attribute data, but the attribute data is associated with the leaf nodes in the composite dataset, this class simulates a DataSetAttributes interface by taking a union of DataSetAttributes associated with all leaf nodes.

DataSet

Python-friendly interface for VTK dataset types.

PointSet

DataSet subclass that adds a points property.

UnstructuredGrid

Python-friendly vtkUnstructuredGrid with numpy access.

ImageData

Python-friendly vtkImageData with numpy access.

PolyData

Python-friendly vtkPolyData with numpy access.

RectilinearGrid

Python-friendly vtkRectilinearGrid with numpy access.

CompositeDataIterator

Wrapper for a vtkCompositeDataIterator class to satisfy the python iterator protocol. This iterator iterates over non-empty leaf nodes. To iterate over empty or non-leaf nodes, use the vtkCompositeDataIterator directly.

CompositeDataSetBase

Python-friendly interface for composite VTK datasets.

PartitionedDataSet

PartitionedDataSetCollection

OverlappingAMR

MultiBlockDataSet

StructuredGrid

Python-friendly vtkStructuredGrid with numpy access.

Data#

API#

vtkmodules.util.data_model.NUMPY_AVAILABLE#

False

class vtkmodules.util.data_model.FieldDataBase(*args)#

基底類別:object

Python-friendly interface for vtkFieldData and its subclasses.

Provides dict-like access to arrays by name or index, with automatic metadata (dataset, association) propagation. Arrays retrieved via [] or get_array() are returned with their owning dataset and association already set.

This class is the base for FieldData, DataSetAttributes, PointData, and CellData overrides.

初始化

__getitem__(idx)#

Implements the [] operator. Accepts an array name or index.

__setitem__(name, value)#

Implements the [] operator. Accepts an array name or index.

get_array(idx)#

Given an index or name, returns a VTK array with metadata set.

__contains__(aname)#

Returns true if the container contains arrays with the given name, false otherwise

keys()#

Returns the names of the arrays as a list.

values()#

Returns the arrays as a tuple.

items()#

Returns a tuple of pairs (name, array)

set_array(name, narray)#

Appends a new array to the dataset attributes.

__eq__(other: object) bool#

Test dict-like equivalency.

__iter__()#
__len__()#
to_pandas()#

Convert to a :class:pandas.DataFrame.

Single-component arrays become columns directly. Multi-component arrays are split into columns named name_0, name_1, etc.

from_pandas(df)#

Populate from a :class:pandas.DataFrame.

Each column becomes a single-component array. Existing arrays are removed first.

to_xarray()#

Convert to an :class:xarray.Dataset.

Single-component arrays get dimension ("index",). Multi-component arrays get dimensions ("index", "component").

from_xarray(ds)#

Populate from an :class:xarray.Dataset.

Each variable becomes an array. Existing arrays are removed first.

class vtkmodules.util.data_model.FieldData(*args)#

基底類別:vtkmodules.util.data_model.FieldDataBase, vtkmodules.vtkCommonDataModel.vtkFieldData

class vtkmodules.util.data_model.DataSetAttributesBase(*args)#

基底類別:vtkmodules.util.data_model.FieldDataBase

class vtkmodules.util.data_model.DataSetAttributes(*args)#

基底類別:vtkmodules.util.data_model.DataSetAttributesBase, vtkmodules.vtkCommonDataModel.vtkDataSetAttributes

__eq__(other: object) bool#

Test dict-like equivalency.

class vtkmodules.util.data_model.PointData(*args)#

基底類別:vtkmodules.util.data_model.DataSetAttributesBase, vtkmodules.vtkCommonDataModel.vtkPointData

class vtkmodules.util.data_model.CellData(*args)#

基底類別:vtkmodules.util.data_model.DataSetAttributesBase, vtkmodules.vtkCommonDataModel.vtkCellData

class vtkmodules.util.data_model.CompositeDataSetAttributesIterator(cdsa)#

基底類別:object

初始化

__iter__()#
__next__()#
next()#
class vtkmodules.util.data_model.CompositeDataSetAttributes(dataset, association)#

基底類別:object

This is a python friendly wrapper for vtkDataSetAttributes for composite datasets. Since composite datasets themselves don’t have attribute data, but the attribute data is associated with the leaf nodes in the composite dataset, this class simulates a DataSetAttributes interface by taking a union of DataSetAttributes associated with all leaf nodes.

初始化

__determine_arraynames()#
modified()#

Rescans the contained dataset to update the internal list of arrays.

__contains__(aname)#

Returns true if the container contains arrays with the given name, false otherwise

keys()#

Returns the names of the arrays as a tuple.

values()#

Returns all the arrays as a tuple.

items()#

Returns (name, array) pairs as a tuple.

__getitem__(idx)#

Implements the [] operator. Accepts an array name.

__setitem__(name, narray)#

Implements the [] operator. Accepts an array name.

set_array(name, narray)#

Appends a new array to the composite dataset attributes.

get_array(idx)#

Given a name, returns a VTKPartitionedArray.

__iter__()#

Iterators on keys

__len__()#
class vtkmodules.util.data_model.DataSet(*args, **kwargs)#

基底類別:object

Python-friendly interface for VTK dataset types.

Adds point_data, cell_data, and field_data properties that return DataSetAttributes instances with dict-like access to arrays. Arrays retrieved from these properties carry metadata (dataset, association) automatically.

This is the base class for PointSet, ImageData, RectilinearGrid, and their subclasses.

Examples

::

pd = vtk.vtkPolyData()
# ... populate pd ...
velocity = pd.point_data["velocity"]    # VTKAOSArray
pd.cell_data["pressure"] = numpy_array  # set from numpy

初始化

property point_data#
property cell_data#
property field_data#
__eq__(other: object) bool#

Test equivalency between data objects.

convert_to_unstructured_grid()#
class vtkmodules.util.data_model.PointSet(*args, **kwargs)#

基底類別:vtkmodules.util.data_model.DataSet

DataSet subclass that adds a points property.

The points property returns the point coordinates as a numpy-compatible VTK array (typically VTKAOSArray). Points can be set from a numpy array or a vtkPoints object.

初始化

property points#
class vtkmodules.util.data_model.UnstructuredGrid(*args, **kwargs)#

基底類別:vtkmodules.util.data_model.PointSet, vtkmodules.vtkCommonDataModel.vtkUnstructuredGrid

Python-friendly vtkUnstructuredGrid with numpy access.

Adds point_data, cell_data, points, and cells properties. The cells property returns a dict with connectivity, offsets, and cell_types arrays.

初始化

property cells#
class vtkmodules.util.data_model.ImageData(*args, **kwargs)#

基底類別:vtkmodules.util.data_model.DataSet, vtkmodules.vtkCommonDataModel.vtkImageData

Python-friendly vtkImageData with numpy access.

Adds point_data, cell_data, and field_data properties for dict-like array access. The points property returns a lazy VTKStructuredPointArray that avoids materializing the full coordinate array.

初始化

property points#

Returns the points as a VTKStructuredPointArray instance.

class vtkmodules.util.data_model.PolyData(*args, **kwargs)#

基底類別:vtkmodules.util.data_model.PointSet, vtkmodules.vtkCommonDataModel.vtkPolyData

Python-friendly vtkPolyData with numpy access.

Adds point_data, cell_data, points, and topology properties (verts_arrays, lines_arrays, strips_arrays, polys_arrays) returning connectivity and offset arrays.

初始化

property verts_arrays#
property lines_arrays#
property strips_arrays#
property polys_arrays#
class vtkmodules.util.data_model.RectilinearGrid(*args, **kwargs)#

基底類別:vtkmodules.util.data_model.DataSet, vtkmodules.vtkCommonDataModel.vtkRectilinearGrid

Python-friendly vtkRectilinearGrid with numpy access.

Adds x_coordinates, y_coordinates, z_coordinates, and points properties. The points property returns a lazy VTKStructuredPointArray that avoids materializing the full coordinate array.

初始化

property points#

Returns the points as a VTKStructuredPointArray instance.

property x_coordinates#
property y_coordinates#
property z_coordinates#
class vtkmodules.util.data_model.CompositeDataIterator(cds)#

基底類別:object

Wrapper for a vtkCompositeDataIterator class to satisfy the python iterator protocol. This iterator iterates over non-empty leaf nodes. To iterate over empty or non-leaf nodes, use the vtkCompositeDataIterator directly.

初始化

__iter__()#
__next__()#
next()#
__getattr__(name)#

Returns attributes from the vtkCompositeDataIterator.

class vtkmodules.util.data_model.CompositeDataSetBase(*args, **kwargs)#

基底類別:object

Python-friendly interface for composite VTK datasets.

Provides point_data, cell_data, field_data, and points properties that return CompositeDataSetAttributes or VTKPartitionedArray instances spanning all leaf datasets. Iteration yields the non-empty leaf vtkDataObject instances.

This is the base class for vtkMultiBlockDataSet, vtkPartitionedDataSet, vtkPartitionedDataSetCollection, and vtkOverlappingAMR overrides.

初始化

__iter__()#

Creates an iterator for the contained datasets.

get_attributes(type)#

Returns the attributes specified by the type as a CompositeDataSetAttributes instance.

property point_data#

Returns the point data as a DataSetAttributes instance.

property cell_data#

Returns the cell data as a DataSetAttributes instance.

property field_data#

Returns the field data as a DataSetAttributes instance.

property points#

Returns the points as a VTKPartitionedArray instance.

class vtkmodules.util.data_model.PartitionedDataSet(*args, **kwargs)#

基底類別:vtkmodules.util.data_model.CompositeDataSetBase, vtkmodules.vtkCommonDataModel.vtkPartitionedDataSet

append(dataset)#
class vtkmodules.util.data_model.PartitionedDataSetCollection(*args, **kwargs)#

基底類別:vtkmodules.util.data_model.CompositeDataSetBase, vtkmodules.vtkCommonDataModel.vtkPartitionedDataSetCollection

append(dataset)#
class vtkmodules.util.data_model.OverlappingAMR(*args, **kwargs)#

基底類別:vtkmodules.util.data_model.CompositeDataSetBase, vtkmodules.vtkCommonDataModel.vtkOverlappingAMR

class vtkmodules.util.data_model.MultiBlockDataSet(*args, **kwargs)#

基底類別:vtkmodules.util.data_model.CompositeDataSetBase, vtkmodules.vtkCommonDataModel.vtkMultiBlockDataSet

class vtkmodules.util.data_model.StructuredGrid(*args, **kwargs)#

基底類別:vtkmodules.util.data_model.PointSet, vtkmodules.vtkCommonDataModel.vtkStructuredGrid

Python-friendly vtkStructuredGrid with numpy access.

Adds x_coordinates, y_coordinates, and z_coordinates read-only properties that extract coordinate components from the point array and reshape them to the grid dimensions.

初始化

property x_coordinates#
property y_coordinates#
property z_coordinates#