Objects¶
The pyvista.DataObject
class is a set of common methods and attributes
for all PyVista types. These objects have no spatial reference, but simply
hold data.
Attributes
Return vtkFieldData as DataSetAttributes. |
|
Get address of the underlying C++ object in format ‘Addr=%p’. |
Methods
|
Add a field array. |
Remove all field arrays. |
|
|
Return a copy of the object. |
|
Copy pyvista meta data onto this object from another object. |
|
Overwrite this mesh with the given mesh as a deep copy. |
|
Get the non-NaN min and max of a named array. |
|
Return the header stats of this dataset. |
|
Save this vtk object to file. |
|
Shallow copy the given mesh to this mesh. |
-
class
pyvista.
DataObject
(*args, **kwargs)¶ Bases:
object
Methods common to all wrapped data objects.
-
add_field_array
(scalars, name, deep=True)¶ Add a field array.
-
clear_field_arrays
()¶ Remove all field arrays.
-
copy
(deep=True)¶ Return a copy of the object.
- Parameters
deep (bool, optional) – When True makes a full copy of the object.
- Returns
newobject – Deep or shallow copy of the input.
- Return type
same as input
-
copy_meta_from
(ido)¶ Copy pyvista meta data onto this object from another object.
-
deep_copy
(to_copy)¶ Overwrite this mesh with the given mesh as a deep copy.
-
property
field_arrays
¶ Return vtkFieldData as DataSetAttributes.
-
get_data_range
(arr=None, preference='field')¶ Get the non-NaN min and max of a named array.
- Parameters
arr (str, np.ndarray, optional) – The name of the array to get the range. If None, the active scalar is used
preference (str, optional) – When scalars is specified, this is the preferred array type to search for in the dataset. Must be either
'point'
,'cell'
, or'field'
.
-
head
(display=True, html=None)¶ Return the header stats of this dataset.
If in IPython, this will be formatted to HTML. Otherwise returns a console friendly string.
-
property
memory_address
¶ Get address of the underlying C++ object in format ‘Addr=%p’.
-
save
(filename, binary=True)¶ Save this vtk object to file.
- Parameters
filename (str, pathlib.Path) – Filename of output file. Writer type is inferred from the extension of the filename.
binary (bool, optional) – If True, write as binary, else ASCII.
Notes
Binary files write much faster than ASCII and have a smaller file size.
-
shallow_copy
(to_copy)¶ Shallow copy the given mesh to this mesh.
-
Table¶
The table class is a non-spatially referenced data object that can be used on VTK pipelines and holds arrays of data.
Attributes
Return the number of columns. |
|
Return the number of columns. |
|
Return the number of rows. |
|
Return the all row arrays. |
Methods
|
Get an array by its name. |
|
Get the non-NaN min and max of a named array. |
|
Return the table items. |
|
Return the table keys. |
|
Pops off an array by the specified name. |
|
Save the table. |
Create a Pandas DataFrame from this Table. |
|
|
Set the table data. |
|
Return the table values. |
-
class
pyvista.
Table
(*args, **kwargs)¶ Bases:
vtkCommonDataModelPython.vtkTable
,pyvista.core.common.DataObject
Wrapper for the
vtkTable
class.Create by passing a 2D NumPy array of shape (
n_rows
byn_columns
) or from a dictionary containing NumPy arrays.Example
>>> import pyvista as pv >>> import numpy as np >>> arrays = np.random.rand(100, 3) >>> table = pv.Table(arrays)
-
get
(index)¶ Get an array by its name.
-
get_data_range
(arr=None, preference='row')¶ Get the non-NaN min and max of a named array.
- Parameters
arr (str, np.ndarray, optional) – The name of the array to get the range. If None, the active scalar is used
preference (str, optional) – When scalars is specified, this is the preferred array type to search for in the dataset. Must be either
'row'
or'field'
.
-
items
()¶ Return the table items.
-
keys
()¶ Return the table keys.
-
property
n_arrays
¶ Return the number of columns.
Alias for:
n_columns
.
-
property
n_columns
¶ Return the number of columns.
-
property
n_rows
¶ Return the number of rows.
-
pop
(name)¶ Pops off an array by the specified name.
-
property
row_arrays
¶ Return the all row arrays.
-
save
(*args, **kwargs)¶ Save the table.
-
to_pandas
()¶ Create a Pandas DataFrame from this Table.
-
update
(data)¶ Set the table data.
-
values
()¶ Return the table values.
-