pyrtid.utils.grid.RectilinearGrid#

class pyrtid.utils.grid.RectilinearGrid(x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, dx: float = 1.0, dy: float = 1.0, dz: float = 1.0, nx: int = 1, ny: int = 1, nz: int = 1, rot_center: Optional[Tuple[float, float, float]] = None, theta: float = 0.0, phi: float = 0.0, psi: float = 0.0)[source]#

Bases: object

Represent a rectilinear 3D grid.

__init__(x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, dx: float = 1.0, dy: float = 1.0, dz: float = 1.0, nx: int = 1, ny: int = 1, nz: int = 1, rot_center: Optional[Tuple[float, float, float]] = None, theta: float = 0.0, phi: float = 0.0, psi: float = 0.0) None[source]#

Initialize the instance.

Parameters
  • x0 (float) – Grid origin x coordinate (smalest value, not centroid) in meters.

  • y0 (float) – Grid origin y coordinate (smalest value, not centroid) in meters.

  • z0 (float) – Grid origin z coordinate (smalest value, not centroid) in meters.

  • dx (float) – Mesh size along the x axis in meters.

  • dy (float) – Mesh size along the y axis in meters.

  • dz (float) – Mesh size along the z axis in meters.

  • nx (int) – Number of meshes along the x axis.

  • ny (int) – Number of meshes along the y axis.

  • nz (int) – Number of meshes along the v axis.

  • rot_center – Coordinates (x, y, z) used as a reference point for the grid rotation. If None, (x0, y0, z0) is used. The default is None.

  • theta (float) – z-axis rotation angle in degrees with (x0, y0, z0) as origin.

  • phi (float) – y-axis-rotation angle in degrees with (x0, y0, z0) as origin.

  • psi (float) – x-axis-rotation angle in degrees with (x0, y0, z0) as origin.

Methods definition

_rotate_coords(non_rotated_coords: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]][source]#

Rotate the coordinates.

Parameters

non_rotated_coords (NDArrayFloat) – Expected shape (3, nx, ny, nz)

Note

The rotation with the matrices multiplication is done relatively to point (0.0, 0.0, 0.0), so we should remove the origin point (x0, y0, z0) before the rotation and add it afterward.

Returns

The rotated coordinates with shape (3, nx, ny, nz).

Return type

NDArrayFloat

gamma_ij(axis: int) float[source]#

Return the surface of the frontiers along the z axis in m2

property _non_rotated_origin_coords: ndarray[Any, dtype[float64]]#

Return the grid meshes origin coordinates with shape (3, nx, ny, nz).

Note

Rotation is not applied.

property _opposite_vertice_coords: ndarray[Any, dtype[float64]]#

Return the grid meshes opposite coordinates with shape (3, nx, ny, nz).

Note

The opposite vertice is the origin symmetric with respect to the cell center.

property bounding_box_vertices_coordinates: ndarray[Any, dtype[float64]]#

Return the coordinates of the 8 bounding box vertices.

property bounds: ndarray[Any, dtype[float64]]#

Return the bounds [[xmin, xmax], [ymin, ymax], [zmin, zmax]].

property center_coords: ndarray[Any, dtype[float64]]#

Return the grid meshes center coordinates with shape (3, nx, ny, nz).

property center_coords_2d: ndarray[Any, dtype[float64]]#

Return the coordinates of the voxel centers for an xy slice.

property gamma_ij_x: float#

Return the surface of the frontiers along the x axis in m2

property gamma_ij_y: float#

Return the surface of the frontiers along the y axis in m2

property gamma_ij_z: float#

Return the surface of the frontiers along the z axis in m2

property grid_cell_surface: float#

Return the surface of the grid cell in the x-y plan (m2).

property grid_cell_volume: float#

Return the volume of a voxel in m3.

property grid_cell_volume_m3: float#

Return the volume of one voxel in m3.

property indices: ndarray[Any, dtype[int64]]#

Return the grid indices with shape (3, nx, ny, nz).

property n_grid_cells: int#

Return the number of grid cells.

property nx: int#

Return the number of grid cells along the x axis.

property ny: int#

Return the number of grid cells along the y axis.

property nz: int#

Return the number of grid cells along the z axis.

property origin_coords: ndarray[Any, dtype[float64]]#

Return the grid meshes origin coordinates with shape (3, nx, ny, nz).

property shape: Tuple[int, int, int]#

Return the shape of the grid.

property total_volume_m3: float#

Return the total grid volume in m3.

property x_extent: float#

Return the x extent in meters.

property x_indices: ndarray[Any, dtype[int64]]#

Return the grid meshes x-indices as 1D array.

property xmax: float#

Return the maximum x of the grid.

property xmin: float#

Return the minimum x of the grid.

property y_extent: float#

Return the y extent in meters.

property y_indices: ndarray[Any, dtype[int64]]#

Return the grid meshes y-indices as 1D array.

property ymax: float#

Return the maximum y of the grid.

property ymin: float#

Return the minimum y of the grid.

property z_extent: float#

Return the z extent in meters.

property z_indices: ndarray[Any, dtype[int64]]#

Return the grid meshes z-indices as 1D array.

property zmax: float#

Return the maximum z of the grid.

property zmin: float#

Return the minimum z of the grid.