finam.EsriGrid#
- class finam.EsriGrid(ncols, nrows, cellsize=1.0, xllcorner=0.0, yllcorner=0.0, order='C', axes_attributes=None, axes_names=None, crs=None)[source]#
Bases:
UniformGridEsri grid raster specification.
- Parameters:
ncols (int) – Number of grid columns, in cells.
nrows (int) – Number of grid rows, in cells.
cellsize (float, optional) – Cell size, by default 1.0
xllcorner (float, optional) – x value of lower left corner, by default 0.0
yllcorner (float, optional) – y value of lower left corner, by default 0.0
order (str, optional) – Point and cell ordering. Either Fortran-like (“F”) or C-like (“C”), by default “C”
axes_attributes (list of dict or None, optional) – Axes attributes following the CF convention (xyz order), by default None
axes_names (list of str or None, optional) – Axes names (in xyz order), by default [“x”, “y”, “z”]
crs (str or None, optional) – The coordinate reference system, by default None
- Attributes:
axeslist of np.ndarray: Grid points.
axes_attributeslist of dict: Axes attributes following the CF convention (xyz order).
axes_increaselist of bool: False to indicate a bottom up axis (xyz order).
axes_nameslist of str: Axes names (xyz order).
axes_reversedbool: Indicate reversed axes order for the associated data.
cell_axeslist of np.ndarray: Axes of the cell centers (xyz order, all increase).
cell_centersnp.ndarray: Grid cell centers in given order starting top left corner.
cell_countint: Number of grid cells.
cell_node_countsnp.ndarray: Node count for each cell.
cell_typesnp.ndarray: Cell types.
cellsnp.ndarray: Cell nodes in ESMF format.
cells_connectivitynp.ndarray: Cells connectivity in ESMF format (list of node IDs).
cells_definitionnp.ndarray: Cell definition in VTK format (list of number of nodes with node IDs).
cells_offsetnp.ndarray: The location of the start of each cell in cells_connectivity.
crsThe coordinate reference system.
data_axeslist of np.ndarray: Axes as used for the data matrix.
data_axes_nameslist of str: Axes names of the data matrix.
data_locationLocation of the associated data (either CELLS or POINTS).
data_pointsPoints of the associated data (either cell_centers or points).
data_shapetuple: Shape of the associated data.
data_sizeint: Size of the associated data.
dimint: Dimension of the grid.
dimstuple: Axes lengths (xyz order).
mesh_dimint: Maximal cell dimension.
nameGrid name.
orderstr: Point, cell and data order (C- or Fortran-like).
point_countint: Number of grid points.
pointsnp.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.
from_file(file[, axes_attributes, crs])Generate EsriGrid from given file.
get_transform_to(other)Get transformation for compatible grids.
to_canonical(data)Convert grid specific data to canonical form.
Cast grid to a rectilinear grid.
Cast grid to an uniform grid.
Cast grid to an unstructured grid.
- classmethod from_file(file, axes_attributes=None, crs=None)[source]#
Generate EsriGrid from given file.
- Parameters:
file (pathlike) – Path to the esri grid file
axes_attributes (list of dict or None, optional) – Axes attributes following the CF convention (xyz order), by default None
crs (str or None, optional) – The coordinate reference system, by default None
- Returns:
The grid specified in the file.
- Return type:
- property axes_attributes#
Axes attributes following the CF convention (xyz order).
- property cell_centers#
Grid cell centers in given order starting top left corner.
- Type:
np.ndarray
- property cell_node_counts#
Node count for each cell.
- Type:
np.ndarray
- property cell_types#
Cell types.
- Type:
np.ndarray
- property cells#
Cell nodes in ESMF format.
- 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
- compatible_with(other, check_location=True)#
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:
- 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:
- property crs#
The coordinate reference system.
- 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).
- export_vtk(path, data=None, cell_data=None, point_data=None, field_data=None, mesh_type='uniform')#
Export grid and data to a VTK file.
- Parameters:
path (pathlike) – File path. Suffix will be replaced according to mesh type (.vti, .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 (“uniform”/”structured”/”unstructured”), by default “structured”
- Raises:
ValueError – If mesh type is not supported.
- from_canonical(data)#
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.
- get_transform_to(other)#
Get transformation for compatible grids.
- Parameters:
other (instance of Grid) – Other grid to compatibility with.
- Returns:
data transformation
- Return type:
callable
- property name#
Grid name.
- property points#
Grid points in given order starting top left corner.
- Type:
np.ndarray
- to_canonical(data)#
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.
- to_rectilinear()#
Cast grid to a rectilinear grid.
- Returns:
Grid as rectilinear grid.
- Return type:
- to_unstructured()#
Cast grid to an unstructured grid.
- Returns:
Grid as unstructured grid.
- Return type: