pyrho.pgrid
#
Python class for ND grid data volumetric data.
Module Contents#
Classes#
Class representing of _periodic_ grid data. |
- class pyrho.pgrid.PGrid(grid_data: numpy.typing.NDArray, lattice: numpy.typing.NDArray)[source]#
Bases:
monty.json.MSONable
Class representing of _periodic_ grid data.
Represents a periodic scalar field on a regular grid. The data is defined by the lattice vectors and the grid data. The grid points are implicitly defined by the lattice vectors and the grid shape.
- _transform_data(sc_mat: numpy.typing.ArrayLike, grid_out: numpy.typing.ArrayLike, origin: numpy.typing.ArrayLike | None = None, up_sample: int = 1) numpy.typing.NDArray [source]#
Apply a supercell transformation to the grid data.
This function assumes that the data is fixed in place and the transformation is applied to the lattice vectors.
- Parameters:
sc_mat – Matrix transformation applied to the lattice vectors
grid_out – The dimensions of the output grid
origin – Origin of the new lattice in fractional coordinates of the input cell
up_sample – The factor to scale up the sampling of the grid data using Fourier interpolation
- Returns:
The transformed data
- Return type:
NDArray
- __mul__(factor: float) PGrid [source]#
Multiply the grid data by a factor.
- Parameters:
factor – The factor to multiply the grid data by
- Returns:
The new PGrid object
- Return type:
- __truediv__(factor: float) PGrid [source]#
Divide the grid data by a factor.
- Parameters:
factor – The factor to divide the grid data by
- Returns:
The new PGrid object
- Return type:
- get_transformed(sc_mat: list[list[int]] | numpy.typing.NDArray, grid_out: list[int], origin: numpy.typing.NDArray | None = None, up_sample: int = 1) PGrid [source]#
Get a new PGrid object for the new transformed data.
- Parameters:
sc_mat – Matrix transformation applied to the lattice vectors
grid_out – The dimensions of the output grid
origin – Origin of the new lattice in fractional coordinates of the input cell
up_sample – The factor to scale up the sampling of the grid data using Fourier interpolation
- Returns:
The transformed PGrid object
- Return type:
- lossy_smooth_compression(grid_out: list, smear_std: float = 0.2) numpy.typing.NDArray [source]#
Perform Fourier interpolation then Gaussian smoothing.
The smoothing makes sure that simple operation like max and min filters still give the same results.
- Parameters:
grid_out – desired output grid of the compressed data.
smear_std – standard deviation of the Gaussian smoothing
- Returns:
Smoothed array
- Return type:
NDArray