hpmoc.atlas package

Work with manifolds.

class hpmoc.atlas.Atlas(faces, x_limits, y_limits, connectors)

Bases: object

connectors: List[Tuple[Callable[[nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray], Tuple[nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray]], Callable[[nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray], Tuple[nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray]], Callable[[nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray], Tuple[nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray]], Callable[[nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray], Tuple[nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray]]]]
corners: List[nptyping.types._ndarray.NDArray]
current_faces: nptyping.types._ndarray.NDArray
current_sides: nptyping.types._ndarray.NDArray
faces: nptyping.types._ndarray.NDArray
ortho_translate(x: nptyping.types._ndarray.NDArray, y: nptyping.types._ndarray.NDArray, chart: nptyping.types._ndarray.NDArray, direction: Union[nptyping.types._ndarray.NDArray, int], distance: Union[nptyping.types._ndarray.NDArray, int], in_place: Optional[bool] = False) Tuple[nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray, nptyping.types._ndarray.NDArray]

Translate coordinates in a given direction within this Atlas. All inputs are expected to have the same shape. This translation can only be directly along coordinate axes (since these are well-defined for connected sides); use translate for diagonal movements.

        1 ◄── DIRECTION
        ▲
  y     │
  ▲ ┌───┬───┐
  │ │0,Y│X,Y│
0◄──├───┼───┤──►2
  │ │0,0│X,0│
  │ └───┴───┘
  0─────│───►x ◄── COORD AXIS
        ▼
        3
Parameters
  • x (NDArray[Int]) – x-coordinate of each point in its chart.

  • y (NDArray[Int]) – y-coordinate of each point in its chart.

  • chart (NDArray[Int]) – Chart number of each point.

  • direction (NDArray[Int]) – Direction in which to move from each starting point (see diagram above).

  • distance (NDArray[Int]) – Number of steps in coordinate grid by which to move.

  • in_place (bool, optional) – If true, write results to input buffers (default: false).

Returns

  • mask (NDArray[Bool]) – A boolean mask with the same shape as the inputs indicating which coordinates were successfully translated.

  • x_out, y_out, chart_out (NDArray[Int]) – The translated coordinates (flattened). Use mask as an index to recover original shape.

See also

Atlas.translate

Perform diagonal translations and extract distance information on results.

sides: nptyping.types._ndarray.NDArray
translate()
valid_idx(x: nptyping.types._ndarray.NDArray, y: nptyping.types._ndarray.NDArray, chart: Union[nptyping.types._ndarray.NDArray, int]) nptyping.types._ndarray.NDArray

Check whether each index is valid.

Parameters
  • x (NDArray[Int]) – x, y coordinates of each point.

  • y (NDArray[Int]) – x, y coordinates of each point.

  • chart (int or NDArray[Int]) – The chart to check (if scalar) or the chart corresponding to each x, y point to check.

Returns

mask – Whether each point is contained within its chart.

Return type

NDArray[Bool]

x_limits: List[nptyping.types._ndarray.NDArray[(2, Ellipsis), nptyping.types._number.Int[int, numpy.signedinteger]]]
y_limits: List[nptyping.types._ndarray.NDArray[(2, Ellipsis), nptyping.types._number.Int[int, numpy.signedinteger]]]
hpmoc.atlas.atlas_dual(faces)
hpmoc.atlas.close_loops(faces, loops)
hpmoc.atlas.dispatch(selector: Union[nptyping.types._ndarray.NDArray, int], func_getter: Callable[[int], Callable], empty: Callable, *args: Any) Any

Dispatch a func based on some selector.

Parameters
  • selector (Union[NDArray[Int], int]) – Indices uniquely specifying the function to be dispatched. Can be a scalar if a single dispatched function is intended to be broadcast.

  • func_getter (Callable) – A scalar getter function which selects, using a scalar int from selector, a vector function taking *args as its arguments.

  • empty (Callable) – A function returning a type-correct default value in case empty arguments are passed.

  • *args (Any) – Arguments to the return value of func_getter.

Returns

result – The results of calling the selected versions of func on the input args. Has the same return type as func.

Return type

Any

hpmoc.atlas.healpix_atlas(nside)
hpmoc.atlas.healpix_base_atlas()
hpmoc.atlas.healpix_grid_limits(nside)

Get the chart grid limits for a HEALPix base pixel of size nside.

Parameters

nside (int) – HEALPix nside.

hpmoc.atlas.healpix_side_subpixel_luts()

Get look-up-tables (LUTs) mapping from HEALPix sub-pixels (as given by the HEALPix NEST convention) to corners’ next-sides (as stored in the HEALPix dual-atlas given by atlas_dual(healpix_base_atlas)).

Viewed from earth (inside the HEALPix sphere, XY axes swapped):

1    2◄───3
│┌───┬───┐
▼│1,0│1,1│
3├───┼───┤1
 │0,0│0,1│▲
 └───┴───┘│
0───►0    2
Returns

  • subpixel2side (array) – Pass NEST subpixel index in to get corner next-side (see arrows in diagram above).

  • side2subpixel (array) – Pass corner next-side index in to get NEST subpixel (opposite direction from arrows in diagram above).

See also

healpix_base_atlas

Get the HEALPix atlas.

atlas_dual

Calculate the dual of an atlas (corner nodes vs. face nodes) whose planar form is specified in the same manner as in healpix_base_atlas.

hpmoc.atlas.idx_in_chart(x: nptyping.types._ndarray.NDArray, y: nptyping.types._ndarray.NDArray, x_limits: nptyping.types._ndarray.NDArray[(2, Ellipsis), nptyping.types._number.Int[int, numpy.signedinteger]], y_limits: nptyping.types._ndarray.NDArray[(2, Ellipsis), nptyping.types._number.Int[int, numpy.signedinteger]]) nptyping.types._ndarray.NDArray

See which indices are contained in a chart. This notion can be used to keep charts in an atlas evenly aligned at the borders to minimize overlap.

Parameters
  • x (array) – x indices to check for membership.

  • y (array) – y indices to check for membership.

  • x_limits (array) – Min/max x values within the base y-values band (left/right walls)

  • y_limits (array) – Min/max y values within the base x-values band (top/bottom walls)

Returns

inside – Whether each pixel in x, y is in the boundaries, broadcast along the 3rd…Nth dimensions of x_limits and y_limits (in case multiple grids with the same x/y bands are being tested at once).

Return type

NDArray[Bool]

Raises

ValueError – If the input limits don’t intersect the x/y band corners or if input array shapes do not match.

hpmoc.atlas.next_side(faces)
hpmoc.atlas.square_matrix_connectors() nptyping.types._ndarray.NDArray[(4, 4, 2, 3), nptyping.types._number.Int]

Matrices for connecting identically-sized square charts to each other.

Returns

connectors – Coordinate connection matrices. First 2 indices correspond to input side followed by output side (relative to output chart). Last 2 indices define augmented transformation matrices, with connectors[i, j, :, :2] defining the xy rotation matrix A and connectors[i, j, :, 2] defining the constant offset B⃗, so that the coordinate transformation leaving through side i and entering the next chart through side j is given by Ax⃗ + B⃗. Handedness of each chart is assumed to be the same. B⃗ is initially set to a factor which must be multiplied by the grid size.

Return type

NDArray[(4, 4, 2, 3), Int64]