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:
objectRepresent a rectilinear 3D grid.
Note
For Euler angles: https://www.meccanismocomplesso.org/en/3d-rotations-and-euler-angles-in-python/
- __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
- 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.