pyvista.DataSet.get_array_association#

DataSet.get_array_association(name: str, preference: Literal['cell', 'point', 'field'] = 'cell') FieldAssociation[source]#

Get the association of an array.

Parameters:
namestr

Name of the array.

preferencestr, default: “cell”

When name is specified, this is the preferred array association to search for in the dataset. Must be either 'point', 'cell', or 'field'.

Returns:
pyvista.core.utilities.arrays.FieldAssociation

Field association of the array.

Examples

Create a DataSet with a variety of arrays.

>>> import pyvista as pv
>>> mesh = pv.Cube()
>>> mesh.clear_data()
>>> mesh.point_data['point-data'] = range(mesh.n_points)
>>> mesh.cell_data['cell-data'] = range(mesh.n_cells)
>>> mesh.field_data['field-data'] = ['a', 'b', 'c']
>>> mesh.array_names
['point-data', 'field-data', 'cell-data']

Get the point data array association.

>>> mesh.get_array_association('point-data')
<FieldAssociation.POINT: 0>

Get the cell data array association.

>>> mesh.get_array_association('cell-data')
<FieldAssociation.CELL: 1>

Get the field data array association.

>>> mesh.get_array_association('field-data')
<FieldAssociation.NONE: 2>