get information about dataset labels

This commit is contained in:
Martin Diehl 2022-02-22 08:08:41 +01:00
parent e8a4f06634
commit f6de182eb6
2 changed files with 15 additions and 2 deletions

View File

@ -259,7 +259,7 @@ class Table:
Table data from file.
"""
f = open(fname) if isinstance(fname, (str, Path)) else fname
f = open(Path(fname).expanduser()) if isinstance(fname, (str, Path)) else fname
f.seek(0)
comments = []

View File

@ -60,12 +60,25 @@ class VTK:
"""Number of points in vtkdata."""
return self.vtk_data.GetNumberOfPoints()
@property
def N_cells(self) -> int:
"""Number of cells in vtkdata."""
return self.vtk_data.GetNumberOfCells()
@property
def labels(self):
"""Labels of datasets."""
labels = {}
cell_data = self.vtk_data.GetCellData()
if c := [cell_data.GetArrayName(a) for a in range(cell_data.GetNumberOfArrays())]:
labels['Cell Data'] = c
point_data = self.vtk_data.GetPointData()
if p := [point_data.GetArrayName(a) for a in range(point_data.GetNumberOfArrays())]:
labels['Point Data'] = p
return labels
@staticmethod
def from_image_data(cells: IntSequence,