nifty8.re.refine.chart module#

class CoordinateChart(min_shape: Iterable[int] | None = None, depth: int | None = None, *, shape0: Iterable[int] | None = None, _coarse_size: int = 5, _fine_size: int = 4, _fine_strategy: Literal['jump', 'extend'] = 'extend', rg2cart: Callable[[Iterable], Iterable] | None = None, cart2rg: Callable[[Iterable], Iterable] | None = None, regular_axes: Iterable[int] | Tuple | None = None, irregular_axes: Iterable[int] | Tuple | None = None, distances: Iterable[float] | float | None = None, distances0: Iterable[float] | float | None = None)[source]#

Bases: object

__init__(min_shape: Iterable[int] | None = None, depth: int | None = None, *, shape0: Iterable[int] | None = None, _coarse_size: int = 5, _fine_size: int = 4, _fine_strategy: Literal['jump', 'extend'] = 'extend', rg2cart: Callable[[Iterable], Iterable] | None = None, cart2rg: Callable[[Iterable], Iterable] | None = None, regular_axes: Iterable[int] | Tuple | None = None, irregular_axes: Iterable[int] | Tuple | None = None, distances: Iterable[float] | float | None = None, distances0: Iterable[float] | float | None = None)[source]#

Initialize a refinement chart.

Parameters:
  • min_shape – Minimal extent in pixels along each axes at the final refinement level.

  • depth – Number of refinement iterations.

  • shape0 – Alternative to min_shape and specifies the extent in pixels along each axes at the zeroth refinement level.

  • _coarse_size – Number of coarse pixels which to refine to _fine_size fine pixels.

  • _fine_size – Number of fine pixels which to refine from _coarse_size coarse pixels.

  • _fine_strategy – Whether to space fine pixels solely within the centermost coarse pixel (“jump”), or whether to always space them out s.t. each fine pixels takes up half the Euclidean volume of a coarse pixel (“extend”).

  • rg2cart – Function to translate Euclidean points on a regular coordinate system to the Cartesian coordinate system of the modeled points.

  • cart2rg – Inverse of rg2cart.

  • regular_axes – Informs the coordinate chart on symmetries within the Cartesian coordinate system of the modeled points. If specified, refinement matrices are broadcasted as need instead of recomputed.

  • irregular_axes – Negative of regular_axes. Specifying either is sufficient.

  • distances – Special case of a coordinate chart in which the regular grid points are merely stretched or compressed. distances are used to set the distance between points along every axes at the final refinement level.

  • distances0 – Same as distances except that distances0 refers to the distances along every axes at the zeroth refinement level.

Note

The functions rg2cart and cart2rg are always w.r.t. the grid at zero depth. In other words, it is straight forward to increase the resolution of an existing chart by simply increasing its depth. However, extending a grid spatially is more cumbersome and is best done via shape0.

cart2ind(positions, lvl, discretize=True)[source]#

Computes the indices of a pixel given the Cartesian coordinates of it.

Parameters:
  • positions – Positions on the Cartesian (in general) irregular coordinate system of the modeled points of shape (n_dim, n_indices) at refinement level lvl which to convert to indices in a NDArray at the refinement level lvl.

  • lvl – Level of the refinement.

  • discretize – Whether to round indices to the next closest integer.

Returns:

Indices into the NDArray at refinement level lvl.

Return type:

indices

cart2rg(positions)[source]#

Translates positions from the (in general) irregular Cartesian coordinate system to the regular Euclidean coordinate system.

Parameters:

positions – Positions on an (in general) irregular Cartesian coordinate system.

Returns:

Positions on a regular Euclidean coordinate system.

Return type:

positions

Note

This method is independent of the refinement level!

property coarse_size#
property depth#
property fine_size#
property fine_strategy#
ind2cart(indices: Iterable[float | int], lvl: int)[source]#

Computes the Cartesian coordinates of a pixel given the indices of it.

Parameters:
  • indices – Indices of shape (n_dim, n_indices) into the NDArray at refinement level lvl which to convert to locations in our (in general) irregular coordinate system of the modeled points.

  • lvl – Level of the refinement.

Returns:

Positions in the (in general) irregular coordinate system of the modeled points of shape (n_dim, n_indices).

Return type:

positions

ind2rg(indices: Iterable[float | int], lvl: int) Tuple[float][source]#

Converts pixel indices to a continuous regular Euclidean grid coordinates.

Parameters:
  • indices – Indices of shape (n_dim, n_indices) into the NDArray at refinement level lvl which to convert to points in our regular Euclidean grid.

  • lvl – Level of the refinement.

Returns:

Regular Euclidean grid coordinates of shape (n_dim, n_indices).

Return type:

rg

property irregular_axes#
level_of(shape: Tuple[int])[source]#

Finds the refinement level at which the number of grid points equate.

property ndim#
property regular_axes#
rg2cart(positions)[source]#

Translates positions from the regular Euclidean coordinate system to the (in general) irregular Cartesian coordinate system.

Parameters:

positions – Positions on a regular Euclidean coordinate system.

Returns:

Positions on an (in general) irregular Cartesian coordinate system.

Return type:

positions

Note

This method is independent of the refinement level!

rg2ind(positions: Iterable[float | int], lvl: int, discretize: bool = True) Tuple[float] | Tuple[int][source]#

Converts continuous regular grid positions to pixel indices.

Parameters:
  • positions – Positions on the regular Euclidean coordinate system of shape (n_dim, n_indices) at refinement level lvl which to convert to indices in a NDArray at the refinement level lvl.

  • lvl – Level of the refinement.

  • discretize – Whether to round indices to the next closest integer.

Returns:

Indices into the NDArray at refinement level lvl.

Return type:

indices

rgoffset(lvl: int) Tuple[float][source]#

Calculate the offset on the regular Euclidean grid due to shrinking of the grid with increasing refinement level.

Parameters:

lvl – Level of the refinement.

Returns:

The offset on the regular Euclidean grid along each axes.

Return type:

offset

Note

Indices are assumed to denote the center of the pixels, i.e. the pixel with index 0 is assumed to be at (0., ) * ndim.

property shape#

Shape at the final refinement level

property shape0#

Shape at the zeroth refinement level

shape_at(lvl)[source]#

Retrieves the shape at a given refinement level lvl.

property size#
class HEALPixChart(*, min_shape: Iterable[int] | None, depth: int = -1, shape0: Iterable[int] | None = None, nonhp_rg2cart: Callable[[Iterable], Iterable] | None, nonhp_cart2rg: Callable[[Iterable], Iterable] | None, _coarse_size: int = 3, _fine_size: int = 2, _fine_strategy: Literal['jump', 'extend'] = 'extend', regular_axes: Iterable[int] | Tuple | None = None, irregular_axes: Iterable[int] | Tuple | None = None)[source]#

Bases: object

__init__(*, min_shape: Iterable[int] | None, depth: int = -1, shape0: Iterable[int] | None = None, nonhp_rg2cart: Callable[[Iterable], Iterable] | None, nonhp_cart2rg: Callable[[Iterable], Iterable] | None, _coarse_size: int = 3, _fine_size: int = 2, _fine_strategy: Literal['jump', 'extend'] = 'extend', regular_axes: Iterable[int] | Tuple | None = None, irregular_axes: Iterable[int] | Tuple | None = None)[source]#

Initialize a refinement chart with HEALPix pixelization on the first axis, see NIFTy’s CoordinateChart method.

property coarse_size#
property depth#
property fine_size#
property fine_strategy#
get_coarse_fine_pair(indices, lvl: int)[source]#
hp_neighbors_idx(lvl, idx)[source]#
property irregular_axes#
property ndim#
nonhp_ind2cart(indices: Iterable[int], lvl: int) Tuple[float][source]#

Computes the Cartesian coordinates of a pixel given the indices of it.

Parameters:
  • indices – Indices of shape (n_dim, n_indices) into the NDArray at refinement level lvl which to convert to locations in our (in general) irregular coordinate system of the modeled points.

  • lvl – Level of the refinement.

Returns:

Positions in the (in general) irregular coordinate system of the modeled points of shape (n_dim, n_indices).

Return type:

positions

property nside: int#
property nside0: int#
nside_at(lvl: int)[source]#
property regular_axes#
rgoffset(lvl: int) Tuple[float][source]#

Calculate the offset on the regular Euclidean grid due to shrinking of the grid with increasing refinement level.

Parameters:

lvl – Level of the refinement.

Returns:

The offset on the regular Euclidean grid along each axes.

Return type:

offset

Note

Indices are assumed to denote the center of the pixels, i.e. the pixel with index 0 is assumed to be at (0., ) * ndim.

property shape#

Shape at the final refinement level

property shape0#

Shape at the zeroth refinement level

shape_at(lvl)[source]#
property size#