DTFE¶
DTFE related functions for computing the Delaunay tesselation and interpolation densities and field values. MPI related classes take specific care to only consider points within complete tesselations and distribute border points to adjacent slabs to complete DTFE computations accurately without approximations.
DTFE Objects¶
- class fiesta.dtfe.Delaunay2D¶
-
- estimate(x: float | ndarray, y: float | ndarray, allow_border: bool = False) float | ndarray¶
Estimates a field from the Delaunay tesselation.
- Parameters:
x (array) – X-coordinate for the field estimation.
y (array) – Y-coordinate for the field estimation.
allow_border (bool, optional) – Allow border interpolation for non-density related interpolation.
- Returns:
f_est – Estimates of the field
- Return type:
array
- find_simplex(x: float | ndarray, y: float | ndarray) ndarray¶
Find the simplex the coordinates lie within.
- get_angle(px0: float | ndarray, py0: float | ndarray, x1: float | ndarray, y1: float | ndarray, x2: float | ndarray, y2: float | ndarray) ndarray¶
Computes the angle subtended from a point p and two points 1 and 2.
- Parameters:
px0 (float or array) – X value for point we want to compute the angle from.
py0 (float or array) – Y value for point we want to compute the angle from.
x1 (float or array) – Point 1’s x value.
y1 (float or array) – Point 1’s y value.
x2 (float or array) – Point 2’s x value.
y2 (float or array) – Point 2’s y value.
- Returns:
angle – Angle subtended from a point p and two points 1 and 2
- Return type:
array
- get_border() dict¶
Returns border points and simplices.
- Returns:
border – Dictionary object contained border points and simplices from previously computed Delaunay tesselation.
- Return type:
- set_field(f: ndarray) None¶
Sets the field values of the input points.
- Parameters:
f (array) – Field values.
- setup(x: ndarray, y: ndarray, boundary: List[float], mass: ndarray | None = None) None¶
Assign particles and field values.
- Parameters:
x (array) – X-axis positions for points.
y (array) – Y-axis positions for points.
boundary (list) – List of boundary values given as [xmin, xmax, ymin, ymax].
mass (array, optional) – Mass weights.
- class fiesta.dtfe.DelaunayMerger2D¶
- add_border(border: dict) None¶
Add border points and simplices from an already computed Delaunay tesselation.
- Parameters:
border (dict) – Dictionary object contained border points and simplices from previously computed Delaunay tesselation.
- estimate(x: float | ndarray, y: float | ndarray) float | ndarray¶
Estimates the field from input coordinates, if coordinate is not in simplex or the simplex is of type != 1 then a Nan is returned.
- class fiesta.dtfe.Delaunay3D¶
-
- estimate(x: float | ndarray, y: float | ndarray, z: float | ndarray, allow_border: bool = False) float | ndarray¶
Estimates a field from the Delaunay tesselation.
- Parameters:
x (array) – X-coordinate for the field estimation.
y (array) – Y-coordinate for the field estimation.
z (array) – Z-coordinate for the field estimation.
allow_border (bool, optional) – Allow border interpolation for non-density related interpolation.
- Returns:
f_est – Estimates of the field
- Return type:
array
- find_simplex(x: float | ndarray, y: float | ndarray, z: float | ndarray) ndarray¶
Find the simplex the coordinates lie within.
- Parameters:
x (array) – X-coordinate for the field estimation.
y (array) – Y-coordinate for the field estimation.
z (array) – Z-coordinate for the field estimation.
- Returns:
simplices – Simplex ID that the point lies in, -1 if point lies outside of all simplices.
- Return type:
array
- get_border() dict¶
Returns border points and simplices.
- Returns:
border – Dictionary object contained border points and simplices from previously computed Delaunay tesselation.
- Return type:
- get_solid_angle(px0: float | ndarray, py0: float | ndarray, pz0: float | ndarray, x1: float | ndarray, y1: float | ndarray, z1: float | ndarray, x2: float | ndarray, y2: float | ndarray, z2: float | ndarray, x3: float | ndarray, y3: float | ndarray, z3: float | ndarray) ndarray¶
Computes the solid angle subtended from a point p and three points 1, 2 and 3.
- Parameters:
px0 (float or array) – X value for point we want to compute the angle from.
py0 (float or array) – Y value for point we want to compute the angle from.
pz0 (float or array) – Z value for point we want to compute the angle from.
x1 (float or array) – Point 1’s x value.
y1 (float or array) – Point 1’s y value.
z1 (float or array) – Point 1’s z value.
x2 (float or array) – Point 2’s x value.
y2 (float or array) – Point 2’s y value.
z2 (float or array) – Point 2’s z value.
x3 (float or array) – Point 3’s x value.
y3 (float or array) – Point 3’s y value.
z3 (float or array) – Point 3’s z value.
- Returns:
solid_angle – Solid angle subtended from a point p and two points 1, 2 and 3.
- Return type:
array
- get_solid_angle_total() None¶
Determines the total solid angle subtended by simplices attached to each points.
- set_field(f: ndarray) None¶
Sets the field values of the input points.
- Parameters:
f (array) – Field values.
- setup(x: ndarray, y: ndarray, z: ndarray, boundary: List[float], mass: ndarray | None = None) None¶
Assign particles and field values.
- Parameters:
x (array) – X-axis positions for points.
y (array) – Y-axis positions for points.
z (array) – Z-axis positions for points.
boundary (list) – List of boundary values given as [xmin, xmax, ymin, ymax, zmin, zmax].
mass (array, optional) – Mass weights.
- class fiesta.dtfe.DelaunayMerger3D¶
- add_border(border: dict) None¶
Add border points and simplices from an already computed Delaunay tesselation.
- Parameters:
border (dict) – Dictionary object contained border points and simplices from previously computed Delaunay tesselation.
- estimate(x: float | ndarray, y: float | ndarray, z: float | ndarray) float | ndarray¶
Estimates the field from input coordinates, if coordinate is not in simplex or the simplex is of type != 1 then a Nan is returned.
DTFE to Grid¶
- fiesta.dtfe.delaunay_density4grid2D(x: ndarray, y: ndarray, boxsize: float | List[float], ngrid: int | List[int], origin: float | List[float] = 0.0, mass: ndarray | None = None, partition: int = 1, periodic: bool | List[bool] = True, fbuffer: float = 0.2, subsampling: int = 1, outputgrid: bool = False, outputexterior: bool = False, normalise: bool = True, flatten: bool = False) ndarray | Tuple[ndarray, ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray, ndarray, ndarray, ndarray]¶
Returns the Delaunay tesselation density on a grid.
- Parameters:
x (array) – Coordinates of particles.
y (array) – Coordinates of particles.
ngrid (int or int list) – Grid dimensions.
mass (array, optional) – Mass or mass weights for each the particles.
partition (int or list, optional) – The number of internal Delaunay tesselations used to compute the density grid.
periodic (bool or list, optional) – Determines whether periodic boundaries are applied.
fbuffer (float, optional) – Buffer factor length, used to trim exterior buffer region.
subsampling (int, optional) – The pixel subsampling rate. Each pixel is evaluated subsampling^2 points on a grid within each pixel. This is to ensure each pixel is assigned a mean pixel value and not the value at the center.
outputgrid (bool, optional) – Outputs coordinate grid.
outputexterior (bool, optional) – Output exterior information, including exterior border dtfe and current unassigned pixels.
normalise (bool, optional) – Whether to normalise the outputing density field.
flatten (bool, optional) – Flatten output density array.
- Returns:
dens (ndarray) – Density field values on a grid.
x2d, y2d (ndarray, optional) – Pixel coordinate points.
exterior_border (dict, optional) – If outputexterior = True, the exterior_border dictionary is outputted.
pixID (ndarray, optional) – If outputexterior = True, pixels that are currently undersampled.
count (ndarray, optional) – If outputexterior = True, the counts for each undersampled pixel.
- fiesta.dtfe.delaunay_field4grid2D(x: ndarray, y: ndarray, f: ndarray, boxsize: float | List[float], ngrid: int | List[int], origin: float | List[float] = 0.0, mass: ndarray | None = None, partition: int = 1, periodic: bool | List[bool] = True, fbuffer: float = 0.5, subsampling: int = 1, outputgrid: bool = False, outputexterior: bool = False, normalise: bool = True, flatten: bool = False) ndarray | Tuple[ndarray, ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray, ndarray, ndarray, ndarray]¶
Returns the Delaunay tesselation field on a grid.
- Parameters:
x (array) – Coordinates of particles.
y (array) – Coordinates of particles.
f (array) – Field values to be interpolated.
ngrid (int or int list) – Grid dimensions.
mass (array, optional) – Mass or mass weights for each the particles.
partition (int or list, optional) – The number of internal Delaunay tesselations used to compute the field grid.
periodic (bool or list, optional) – Determines whether periodic boundaries are applied.
fbuffer (float, optional) – Buffer factor length, used to trim exterior buffer region.
subsampling (int, optional) – The pixel subsampling rate. Each pixel is evaluated subsampling^2 points on a grid within each pixel. This is to ensure each pixel is assigned a mean pixel value and not the value at the center.
outputgrid (bool, optional) – Outputs coordinate grid.
outputexterior (bool, optional) – Ouput exterior information, including exterior border dtfe and current unassigned pixels.
normalise (bool, optional) – Whether to normalise the outputing field.
flatten (bool, optional) – Flatten output field array.
- Returns:
field (ndarray) – Field values on a grid.
x2d, y2d (ndarray, optional) – Pixel coordinate points.
- fiesta.dtfe.delaunay_density4grid3D(x: ndarray, y: ndarray, z: ndarray, boxsize: float | List[float], ngrid: int | List[int], origin: float | List[float] = 0.0, mass: ndarray | None = None, partition: int = 1, periodic: bool | List[bool] = True, fbuffer: float = 0.5, subsampling: int = 1, outputgrid: bool = False, outputexterior: bool = False, normalise: bool = True, flatten: bool = False) ndarray | Tuple[ndarray, ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray, ndarray, ndarray, ndarray]¶
Returns the Delaunay tesselation density on a grid.
- Parameters:
x (array) – Coordinates of particles.
y (array) – Coordinates of particles.
z (array) – Coordinates of particles.
ngrid (int or int list) – Grid dimensions.
mass (array, optional) – Mass or mass weights for each the particles.
partition (int or list, optional) – The number of internal Delaunay tesselations used to compute the density grid.
periodic (bool or list, optional) – Determines whether periodic boundaries are applied.
fbuffer (float, optional) – Buffer factor length, used to trim exterior buffer region.
subsampling (int, optional) – The pixel subsampling rate. Each pixel is evaluated subsampling^2 points on a grid within each pixel. This is to ensure each pixel is assigned a mean pixel value and not the value at the center.
outputgrid (bool, optional) – Outputs coordinate grid.
normalise (bool, optional) – Whether to normalise the outputing density field.
flatten (bool, optional) – Flatten output density array.
- Returns:
dens (ndarray) – Density field values on a grid.
x2d, y2d, z3d (ndarray, optional) – Pixel coordinate points.
- fiesta.dtfe.delaunay_field4grid3D(x: ndarray, y: ndarray, z: ndarray, f: ndarray, boxsize: float | List[float], ngrid: int | List[int], origin: float | List[float] = 0.0, mass: ndarray | None = None, partition: int = 1, periodic: bool | List[bool] = True, fbuffer: float = 0.2, subsampling: int = 1, outputgrid: bool = False, outputexterior: bool = False, normalise: bool = True, flatten: bool = False) ndarray | Tuple[ndarray, ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray, ndarray, ndarray, ndarray]¶
Returns the Delaunay tesselation field on a grid.
- Parameters:
x (array) – Coordinates of particles.
y (array) – Coordinates of particles.
z (array) – Coordinates of particles.
f (array) – Field values to be interpolated.
ngrid (int or int list) – Grid dimensions.
mass (array, optional) – Mass or mass weights for each the particles.
partition (int or list, optional) – The number of internal Delaunay tesselations used to compute the field grid.
periodic (bool or list, optional) – Determines whether periodic boundaries are applied.
fbuffer (float, optional) – Buffer factor length, used to trim exterior buffer region.
subsampling (int, optional) – The pixel subsampling rate. Each pixel is evaluated subsampling^2 points on a grid within each pixel. This is to ensure each pixel is assigned a mean pixel value and not the value at the center.
outputgrid (bool, optional) – Outputs coordinate grid.
normalise (bool, optional) – Whether to normalise the outputing field.
flatten (bool, optional) – Flatten output field array.
- Returns:
field (ndarray) – Field values on a grid.
x2d, y2d, z3d (ndarray, optional) – Pixel coordinate points.
MPI DTFE to Grid¶
- fiesta.dtfe.mpi_delaunay_density4grid2D(x: ndarray, y: ndarray, boxsize: float | List[float], ngrid: int | List[int], MPI: object, origin: float | List[float] = 0.0, mass: ndarray | None = None, partition: int = 1, periodic: bool | List[bool] = True, fbuffer: float = 0.5, subsampling: int = 1, outputgrid: bool = False) ndarray | Tuple[ndarray, ndarray, ndarray]¶
Returns the Delaunay tesselation density on a grid.
- Parameters:
x (array) – Coordinates of particles.
y (array) – Coordinates of particles.
ngrid (int or int list) – Grid dimensions.
MPI (class object) – shift.mpiutils MPI object.
mass (array, optional) – Mass or mass weights for each the particles.
partition (int or list, optional) – The number of internal Delaunay tesselations used to compute the density grid.
periodic (bool or list, optional) – Determines whether periodic boundaries are applied.
fbuffer (float, optional) – Buffer factor length, used to trim exterior buffer region.
subsampling (int, optional) – The pixel subsampling rate. Each pixel is evaluated subsampling^2 points on a grid within each pixel. This is to ensure each pixel is assigned a mean pixel value and not the value at the center.
outputgrid (bool, optional) – Outputs coordinate grid.
outputexterior (bool, optional) – Ouput exterior information, including exterior border dtfe and current unassigned pixels.
- Returns:
dens (ndarray) – Density field values on a grid.
x2d, y2d (ndarray, optional) – Pixel coordinate points.
- fiesta.dtfe.mpi_delaunay_field4grid2D(x: ndarray, y: ndarray, f: ndarray, boxsize: float | List[float], ngrid: int | List[int], MPI: object, origin: float | List[float] = 0.0, mass: ndarray | None = None, partition: int = 1, periodic: bool | List[bool] = True, fbuffer: float = 0.5, subsampling: int = 1, outputgrid: bool = False)¶
Returns the Delaunay tesselation field on a grid.
- Parameters:
x (array) – Coordinates of particles.
y (array) – Coordinates of particles.
f (array) – Field values to be interpolated.
ngrid (int or int list) – Grid dimensions.
MPI (class object) – shift.mpiutils MPI object.
mass (array, optional) – Mass or mass weights for each the particles.
partition (int or list, optional) – The number of internal Delaunay tesselations used to compute the field grid.
periodic (bool or list, optional) – Determines whether periodic boundaries are applied.
fbuffer (float, optional) – Buffer factor length, used to trim exterior buffer region.
subsampling (int, optional) – The pixel subsampling rate. Each pixel is evaluated subsampling^2 points on a grid within each pixel. This is to ensure each pixel is assigned a mean pixel value and not the value at the center.
outputgrid (bool, optional) – Outputs coordinate grid.
outputexterior (bool, optional) – Ouput exterior information, including exterior border dtfe and current unassigned pixels.
- Returns:
field (ndarray) – Density field values on a grid.
x2d, y2d (ndarray, optional) – Pixel coordinate points.
- fiesta.dtfe.mpi_delaunay_density4grid3D(x: ndarray, y: ndarray, z: ndarray, boxsize: float | List[float], ngrid: int | List[int], MPI: object, origin: float | List[float] = 0.0, mass: ndarray | None = None, partition: int = 1, periodic: bool | List[bool] = True, fbuffer: float = 0.5, subsampling: int = 1, outputgrid: bool = False) ndarray | Tuple[ndarray, ndarray, ndarray]¶
Returns the Delaunay tesselation density on a grid.
- Parameters:
x (array) – Coordinates of particles.
y (array) – Coordinates of particles.
z (array) – Coordinates of particles.
ngrid (int or int list) – Grid dimensions.
MPI (class object) – shift.mpiutils MPI object.
mass (array, optional) – Mass or mass weights for each the particles.
partition (int or list, optional) – The number of internal Delaunay tesselations used to compute the density grid.
periodic (bool or list, optional) – Determines whether periodic boundaries are applied.
fbuffer (float, optional) – Buffer factor length, used to trim exterior buffer region.
subsampling (int, optional) – The pixel subsampling rate. Each pixel is evaluated subsampling^2 points on a grid within each pixel. This is to ensure each pixel is assigned a mean pixel value and not the value at the center.
outputgrid (bool, optional) – Outputs coordinate grid.
outputexterior (bool, optional) – Ouput exterior information, including exterior border dtfe and current unassigned pixels.
- Returns:
dens (ndarray) – Density field values on a grid.
x3d, y3d, z3d (ndarray, optional) – Pixel coordinate points.
- fiesta.dtfe.mpi_delaunay_field4grid3D(x: ndarray, y: ndarray, z: ndarray, f: ndarray, boxsize: float | List[float], ngrid: int | List[int], MPI: object, origin: float | List[float] = 0.0, mass: ndarray | None = None, partition: int = 1, periodic: bool | List[bool] = True, fbuffer: float = 0.5, subsampling: int = 1, outputgrid: bool = False) ndarray | Tuple[ndarray, ndarray, ndarray]¶
Returns the Delaunay tesselation field a grid.
- Parameters:
x (array) – Coordinates of particles.
y (array) – Coordinates of particles.
z (array) – Coordinates of particles.
f (array) – Field values to be interpolated.
ngrid (int or int list) – Grid dimensions.
MPI (class object) – shift.mpiutils MPI object.
mass (array, optional) – Mass or mass weights for each the particles.
partition (int or list, optional) – The number of internal Delaunay tesselations used to compute the field grid.
periodic (bool or list, optional) – Determines whether periodic boundaries are applied.
fbuffer (float, optional) – Buffer factor length, used to trim exterior buffer region.
subsampling (int, optional) – The pixel subsampling rate. Each pixel is evaluated subsampling^2 points on a grid within each pixel. This is to ensure each pixel is assigned a mean pixel value and not the value at the center.
outputgrid (bool, optional) – Outputs coordinate grid.
outputexterior (bool, optional) – Ouput exterior information, including exterior border dtfe and current unassigned pixels.
- Returns:
field (ndarray) – Density field values on a grid.
x3d, y3d, z3d (ndarray, optional) – Pixel coordinate points.