get_array_association#

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

Get the association of an array.

Parameters:
namestr

Name of the array.

preferencestr, optional

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.FieldAssociation

Field association of the array.

Examples

Create a DataSet with a variety of arrays.

>>> import pyvista
>>> mesh = pyvista.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>