Merge branch 'table-vtk-help' into 'development'

consistent interface and description

See merge request damask/DAMASK!584
This commit is contained in:
Philip Eisenlohr 2022-05-17 22:46:58 +00:00
commit 18d862cdb0
2 changed files with 9 additions and 3 deletions

View File

@ -370,9 +370,9 @@ class Table:
label : str
Column label.
data : numpy.ndarray
Column data.
Column data. First dimension needs to match number of rows.
info : str, optional
Human-readable information about the modified data.
Human-readable information about the data.
Returns
-------

View File

@ -404,10 +404,11 @@ class VTK:
def set(self,
label: str = None,
data: Union[np.ndarray, np.ma.MaskedArray] = None,
info: str = None,
*,
table: 'Table' = None):
"""
Add (or replace existing) point or cell data.
Add new or replace existing point or cell data.
Data can either be a numpy.array, which requires a corresponding label,
or a damask.Table.
@ -419,6 +420,8 @@ class VTK:
data : numpy.ndarray or numpy.ma.MaskedArray, optional
Data to add or replace. First array dimension needs to match either
number of cells or number of points.
info : str, optional
Human-readable information about the data.
table: damask.Table, optional
Data to add or replace. Each table label is individually considered.
Number of rows needs to match either number of cells or number of points.
@ -465,14 +468,17 @@ class VTK:
_add_array(dup.vtk_data,
label,
np.where(data.mask,data.fill_value,data) if isinstance(data,np.ma.MaskedArray) else data)
if info is not None: dup.comments += f'{label}: {info}'
else:
raise ValueError('no label defined for data')
elif isinstance(table,Table):
for l in table.labels:
_add_array(dup.vtk_data,l,table.get(l))
if info is not None: dup.comments += f'{l}: {info}'
else:
raise TypeError
return dup