# Crate cdshealpix

source ·## Expand description

Implementation of the HEALPix framework.

See papers:

- Gorsky2005: “HEALPix: A Framework for High-Resolution Discretization and Fast Analysis of Data Distributed on the Sphere”, Górski, K. M. et al., 2005; 2005ApJ…622..759G.
- Calabretta2004: “Mapping on the HEALPix grid”, Calabretta, M. R., 2004; 2004astro.ph.12607C
- Calabretta2007: “Mapping on the HEALPix grid”, Calabretta, M. R. et Roukema, B. F., 2007; 2007MNRAS.381..865C
- Reinecke2015: “Efficient data structures for masks on 2D grids”, Reinecke, M. et Hivon, E., 2015; 2015A&A…580A.132R

## Modules§

- Module defining the commodity enums Cardinal (points) and MainWind (points).
- Module simply defining a the structure storing the external edges of an HEALPix cell and provided accesses according to the main wind directions. This strcut is common to nested and ring scheme.
- Module containing NESTED scheme methods
- Module containing RING scheme methods
- Module containing spherical geometry structures and methods like 3D vectors, polygon or cone on the unit sphere…

## Constants§

- Constant = 29, i.e. the largest possible depth we can store on a signed positive long (4 bits for base cells + 2 bits per depth + 2 remaining bits (1 use in the unique notation).
- Equals !F64_SIGN_BIT_MASK (the inverse of the f64 sign mask)
- Mask to keep only the f64 sign
- Constant = 4 / pi.
- Constant = nside(29), i.e. the largest possible nside available when we store HEALPix hash on a u64.
- Inverse of the limit on |z|=|sin(lat)| between the equatorial region and the polar caps. Equals 1/(2/3) = 1.5, see Eq. (1) in Gorsky2005.
- Constant = pi / 4.
- Constant = sqrt(6).
- Limit on the latitude (in radians) between the equatorial region and the polar caps. Equals asin(2/3) = 0.7297276562269663 radians ~= 41,81 degrees. Written $\theta_X$ in Calabretta2007.
- Limit on |z|=|sin(lat)| between the equatorial region and the polar caps. Equals 2/3, see Eq. (1) in Gorsky2005.
- Constant = 2 * pi.

## Statics§

- Latitude, in the equatorial region, for which the distance from the cell center to its four vertices is almost equal on the sky (i.e. the shape of the cell on the sky is close to a square). The larger the depth, the better the approximation (based on differential calculus).

## Traits§

- Simple trait used to implements
`pow2`

,`twice`

and`half`

on f64.

## Functions§

- Returns the hash of the base cell given the coordinates of a points in the Euclidean projection plane. The purpose so far is just to test and compare both speed and precision with the 45deg rotation solution.
- Returns the the smallest depth (in
`[0, 29]`

) at which a shape having the given largest distance from its center to a border overlaps a maximum of 9 cells (the cell containing the center of the shape plus the 8 neighbouring cells).

Info: internally, unrolled binary search loop on 30 pre-computed values (one by depth). @return -1 if the given distance is very large (> ~48deg), else returns the smallest depth (in [0, 29]) at which a shape having the given largest distance from its center to a border overlaps a maximum of 9 cells (the cell containing the center of the shape plus the 8 neighbouring cells). - Returns, for the given
`nside`

, the number of subdivision of a base-resolution cell (i.e. the depth). For the NESTED scheme only. - Same as depth except that this version does not check the argument, and thus does not panics if the argument is illegal.
- Returns the direction of the given base cell from its neighbour base cell located in the given direction.
- Returns the direction of a cell on the inner edge of the given base cell from its neighbour located at the given direction in a different base cell.
- Returns
`true`

if the function best_starting_depth is valid for the given argument`d_max_rad`

. So if`d_max_rad < ~48 deg`

.`d_max_rad`

is given in radians. - Returns
`true`

if the given argument is a valid depth, i.e. if it is <= DEPTH_MAX. - Returns
`true`

if the point of given (absolute value of) latitude is in the equatorial region, and`false`

if it is located in one of the two polar caps - Returns
`true`

if the point of given (absolute value of) y coordinate in the projected plane is in the equatorial region, and`false`

if it is located in one of the two polar caps - Returns
`true`

if the given argument is a valid`nside`

for the NESTED scheme, i.e. if it is a power of 2, is != 0 and is <= NSIDE_MAX. - Returns an upper limit on the distance between a cell center around the given position and its furthest vertex.
- Returns an upper limit on the distance between a cell center and it furthest vertex, for all the cells in the region covered by a cone of given center and radius.

It is an extension of largest_center_to_vertex_distance - Same as largest_center_to_vertex_distance_with_radius but making the computation for several depths at the same time.
- Returns the number of distinct hash value (the number of cells or pixel the unit sphere is devided in) at the given
`depth`

. - Same as n_hash except that this version does not panic if the given
`depth`

is out of range. - Compute the base cell value which is the neighbour of the given base cell, in the given direction.

There is no neighbour: - Returns, for the given depth, the number of cells along both axis of a base-resolution cell.
- Returns, for the given difference of depth, the number of cells small cells the large cell contains. If the small cell level is 0, the result is the sqaured nside.
- Same as nside_square except that this version does not check the argument, and thus does not panics if the argument is illegal.
- Same as nside except that this version does not check the argument, and thus does not panics if the argument is illegal.
- Performs the HEALPix projection:
`(x, y) = proj(lon, lat)`

.

The chosen scale is such that: base cell vertices and center coordinates are integers; the distance from a cell center to its vertices equals one.

This projection is multi-purpose in the sense that if`lon`

is in`[-pi, pi]`

, then`x`

is in`[-4, 4]`

and if`lon`

is in`[0, 2pi]`

, then`x`

is in`[0, 8]`

.

It means that a same position on the sphere can lead to different positions in the projected Euclidean plane. - Unproject the given HEALPix projected points.

This unprojection is multi-purpose in the sense that: