nifty.re.multi_grid.grid_impl module#

BrokenLogGrid(*, r_min: float, r_linthresh: float, r_max: float, distances=None, **kwargs) → OpenGrid[source]#

Create a broken logarithmic grid on top of SimpleOpenGrid spanning from r_min to r_max at the final depth. The grid is parametrised by three radii: r_min, r_linthresh, and r_max. Between r_min and r_linthresh pixels are spaced linearly (r). Between r_linthresh and r_max pixels are spaced logarithmically (exp(r)).

For available parameters see the SimpleOpenGrid docstring in addition the ones below.

Parameters:
  • r_min – Minimum coordinate value.

  • r_linthresh – Coordinate value at which the grid switches from linear to logarithmic spacing.

  • r_max – Maximum coordinate value.

Notes

For values below rmin, the (padded) pixels are spaced antilinearly (1/r). Above rmax they are spaced linearly (r).

class BrokenLogGridAtLevel(*args, alpha, beta, gamma, delta, epsilon, r_min, r_linthresh, r_max, rg_min, rg_linthresh, rg_max, **kwargs)[source]#

Bases: SimpleOpenGridAtLevel

__init__(*args, alpha, beta, gamma, delta, epsilon, r_min, r_linthresh, r_max, rg_min, rg_linthresh, rg_max, **kwargs)[source]#
coord2index(coord, **kwargs)[source]#
index2coord(index)[source]#
index2volume(index)[source]#
padding: NDArray[int64] | None#
parent_padding: NDArray[int64] | None#
parent_splits: npt.NDArray[np.int_] | None#
property r_max#
property r_min#
shape: npt.NDArray[np.int_]#
shifts: NDArray[int64] | None#
splits: npt.NDArray[np.int_] | None#
class HEALPixGrid(*, nside0: int | None = None, nside: int | None = None, depth: int | None = None, nest=True, shape0=None, splits=None)[source]#

Bases: Grid

__init__(*, nside0: int | None = None, nside: int | None = None, depth: int | None = None, nest=True, shape0=None, splits=None)[source]#

HEALPix pixelization grid.

The grid can be defined either via depth and exactly one of (nside0, nside, shape0) or via nside and one of (nside0, shape0).

amend(splits=None, *, added_depth: int | None = None)[source]#
atLevel: Callable#
shape0: NDArray[int64]#
splits: tuple[NDArray[int64]]#
class HEALPixGridAtLevel(shape=None, splits=None, parent_splits=None, *, nside: int = None, nest=True)[source]#

Bases: GridAtLevel

__init__(shape=None, splits=None, parent_splits=None, *, nside: int = None, nest=True)[source]#
coord2index(coord, dtype=<class 'numpy.uint64'>, **kwargs)[source]#
index2coord(index, **kwargs)[source]#
index2volume(index, **kwargs)[source]#
neighborhood(index, window_size: Iterable[int])[source]#
nest: bool#
nside: int#
HPBrokenLogRGrid(min_shape: ~typing.Tuple[int, int] | None = None, *, nside: int | None = None, r_min_shape: int | None = None, r_min, r_linthresh, r_max, r_window_size=3, nside0=16, atLevel=<class 'nifty.re.multi_grid.grid_impl.HPRadialGridAtLevel'>) → MGrid[source]#

Meshgrid of a HEALPix grid and a broken logarithmic grid.

See HEALPixGrid and BrokenLogGrid.

HPLogRGrid(min_shape: ~typing.Tuple[int, int] | None = None, *, nside: int | None = None, r_min_shape: int | None = None, r_min, r_max, r_window_size=3, nside0=16, atLevel=<class 'nifty.re.multi_grid.grid_impl.HPRadialGridAtLevel'>) → MGrid[source]#

Meshgrid of a HEALPix grid and a logarithmic grid.

See HEALPixGrid and LogGrid.

class HPRadialGridAtLevel(*grids)[source]#

Bases: MGridAtLevel

coord2index(coord, **kwargs)[source]#
grids: tuple[GridAtLevel]#
index2coord(index, **kwargs)[source]#
index2volume(index)[source]#
LogGrid(*, r_min: float, r_max: float, distances=None, **kwargs) → OpenGrid[source]#

Logarithmic grid on top of SimpleOpenGrid spanning from r_min to r_max at the final depth.

class LogGridAtLevel(*args, coord_offset, coord_scale, **kwargs)[source]#

Bases: SimpleOpenGridAtLevel

__init__(*args, coord_offset, coord_scale, **kwargs)[source]#
coord2index(coord, **kwargs)[source]#
index2coord(index)[source]#
index2volume(index)[source]#
padding: NDArray[int64] | None#
parent_padding: NDArray[int64] | None#
parent_splits: npt.NDArray[np.int_] | None#
property r_max#
property r_min#
shape: npt.NDArray[np.int_]#
shifts: NDArray[int64] | None#
splits: npt.NDArray[np.int_] | None#
SimpleOpenGrid(*, min_shape: ~typing.Tuple[int], window_size: int | ~typing.Tuple[int] = 3, splits: int | ~typing.Tuple[int] | ~typing.Tuple[~typing.Tuple[int]] = 2, distances: float | ~typing.Tuple[float] | None = None, depth: int | None = None, desired_size0: int = 128, atLevel: ~nifty.re.multi_grid.grid.GridAtLevel = <class 'nifty.re.multi_grid.grid_impl.SimpleOpenGridAtLevel'>) → OpenGrid[source]#

Create a regular Cartesian grid with a given minimum shape and a default volume of unity at the final depth.

The initialization automatically determines a suitable depth and padding (using the window_size).

Amending the grid will increase the resolution while keeping the previous grids including their pixel distances the same. Due to padding, the amended grids will live on a slightly smaller volume than the previous grids and won’t start exactly at zero.

Parameters:
  • min_shape – Minimum shape along each dimension. If the shape can be larger than requested at no additional costs, it will be automatically extended.

  • window_size – Size of the refinement window. The larger the window, the more accurate but more costly the refinement.

  • splits – Number of child pixels of a parent pixels.

  • distances – Distance between pixels if the grid is regular.

  • depth – Refinement depth.

  • desired_size0 – Approximate size of the initial coarse-most grid.

class SimpleOpenGridAtLevel(shape, splits=None, parent_splits=None, *, shifts0, distances0, all_splits, level=None, shifts=None, **kwargs)[source]#

Bases: OpenGridAtLevel

__init__(shape, splits=None, parent_splits=None, *, shifts0, distances0, all_splits, level=None, shifts=None, **kwargs)[source]#
coord2index(coord, **kwargs)[source]#
index2coord(index)[source]#
index2volume(index)[source]#
padding: NDArray[int64] | None#
parent_padding: NDArray[int64] | None#
parent_splits: npt.NDArray[np.int_] | None#
shape: npt.NDArray[np.int_]#
shifts: NDArray[int64] | None#
splits: npt.NDArray[np.int_] | None#