finam.data.StructuredGrid#
- class finam.data.StructuredGrid[source]#
Bases:
Grid
Abstract structured grid specification.
- Attributes:
axes
list of np.ndarray: Axes of the structured grid (xyz order, all increase).
axes_attributes
list of dict: Axes attributes following the CF convention (xyz order).
axes_increase
list of bool: False to indicate a bottom up axis (xyz order).
axes_names
list of str: Axes names (xyz order).
axes_reversed
bool: Indicate reversed axes order for the associated data (zyx order).
cell_axes
list of np.ndarray: Axes of the cell centers (xyz order, all increase).
cell_centers
np.ndarray: Grid cell centers in given order starting top left corner.
cell_count
int: Number of grid cells.
cell_node_counts
np.ndarray: Node count for each cell.
cell_types
np.ndarray: Cell types.
cells
np.ndarray: Cell nodes in ESMF format.
cells_connectivity
np.ndarray: Cells connectivity in ESMF format (list of node IDs).
cells_definition
np.ndarray: Cell definition in VTK format (list of number of nodes with node IDs).
cells_offset
np.ndarray: The location of the start of each cell in cells_connectivity.
crs
The coordinate reference system.
data_axes
list of np.ndarray: Axes as used for the data matrix.
data_axes_names
list of str: Axes names of the data matrix.
data_location
Location of the associated data (either CELLS or POINTS).
data_points
Points of the associated data (either cell_centers or points).
data_shape
tuple: Shape of the associated data matrix.
data_size
int: Size of the associated data.
dim
int: Dimension of the grid or data.
dims
tuple: Axes lengths (xyz order).
mesh_dim
int: Maximal cell dimension.
name
Grid name.
order
str: Point, cell and data order (C- or Fortran-like).
point_count
int: Number of grid points.
points
np.ndarray: Grid points in given order starting top left corner.
Methods
compatible_with
(other[, check_location])Check for compatibility with other Grid.
copy
([deep])Copy of this grid.
export_vtk
(path[, data, cell_data, ...])Export grid and data to a VTK file.
from_canonical
(data)Convert canonical data to grid specific form.
get_transform_to
(other)Get transformation for compatible grids.
to_canonical
(data)Convert grid specific data to canonical form.
- abstract property axes#
Axes of the structured grid (xyz order, all increase).
- Type:
list of np.ndarray
- abstract property axes_reversed#
Indicate reversed axes order for the associated data (zyx order).
- Type:
- property points#
Grid points in given order starting top left corner.
- Type:
np.ndarray
- property cells#
Cell nodes in ESMF format.
- Type:
np.ndarray
- property cell_centers#
Grid cell centers in given order starting top left corner.
- Type:
np.ndarray
- property cell_types#
Cell types.
- Type:
np.ndarray
- compatible_with(other, check_location=True)[source]#
Check for compatibility with other Grid.
- Parameters:
other (instance of Grid) – Other grid to compatibility with.
check_location (bool, optional) – Whether to check location for equality, by default True
- Returns:
compatibility
- Return type:
- export_vtk(path, data=None, cell_data=None, point_data=None, field_data=None, mesh_type='structured')[source]#
Export grid and data to a VTK file.
- Parameters:
path (pathlike) – File path. Suffix will be replaced according to mesh type (.vtr, .vtu)
data (dict or None, optional) – Data in the corresponding shape given by name, by default None
cell_data (dict or None, optional) – Additional cell data, by default None
point_data (dict or None, optional) – Additional point data, by default None
field_data (dict or None, optional) – Additional field data, by default None
mesh_type (str, optional) – Mesh type (“structured”/”unstructured”), by default “structured”
- Raises:
ValueError – If mesh type is not supported.
- to_canonical(data)[source]#
Convert grid specific data to canonical form.
Canonical means, that data axis are in xyz order and following increasing axis values.
- Parameters:
data (arraylike) – Data to convert.
- Returns:
Canonical Data.
- Return type:
arraylike
- Raises:
ValueError – When data has wrong shape.
- abstract property axes_attributes#
Axes attributes following the CF convention (xyz order).
- property cell_node_counts#
Node count for each cell.
- Type:
np.ndarray
- property cells_connectivity#
Cells connectivity in ESMF format (list of node IDs).
- Type:
np.ndarray
- property cells_definition#
Cell definition in VTK format (list of number of nodes with node IDs).
- Type:
np.ndarray
- property cells_offset#
The location of the start of each cell in cells_connectivity.
- Type:
np.ndarray
- copy(deep=False)#
Copy of this grid.
- Parameters:
deep (bool, optional) – If false, only a shallow copy is returned to save memory, by default False
- Returns:
The grid copy.
- Return type:
- abstract property crs#
The coordinate reference system.
- abstract property data_location#
Location of the associated data (either CELLS or POINTS).
- property data_points#
Points of the associated data (either cell_centers or points).
- from_canonical(data)[source]#
Convert canonical data to grid specific form.
Canonical means, that data axis are in xyz order and following increasing axis values.
- Parameters:
data (arraylike) – Data to convert.
- Returns:
Grid specific Data.
- Return type:
arraylike
- Raises:
ValueError – When data has wrong shape.
- property name#
Grid name.