Healpix

class cygrid.Healpix(uint64_t nside=1, uint32_t scheme=RING)

Bases: object

Helper class for HEALPix operations.

Implements conversion between HEALPix world and pixel coordinates (‘RING’ representation only). Also provides a query_disc method that returns a disc footprint for \(\varphi = 180^\circ\) for a given ring.

Parameters
nsideunsigned 64-bit int

The HEALPix nside parameter.

schemeenum

The HEALPix scheme. Currently, only ‘RING’ is supported.

Notes

A lot of the code in this class was adapted from the HEALPix C++ library. (Copyright (C) 2003-2012 Max-Planck-Society; author Martin Reinecke; see http://healpix.sourceforge.net)

Attributes Summary

ncap

property ncap : unsigned 64-bit int

npface

property nface : unsigned 64-bit int

npix

property npix : unsigned 64-bit int

nrings

property nrings : unsigned 64-bit int

nside

property nside : unsigned 64-bit int

omega

property omega : double

order

property order : unsigned 64-bit int

resolution

property resolution : double

scheme

property scheme : enum

Methods Summary

ang2pix(self, double theta, double phi)

Return the pixel index containing the angular coordinates \((\varphi, \vartheta)\).

ang2pix_many(self, double[, double[)

Return the pixel indices containing the angular coordinates of \((\varphi, \vartheta)\) arrays.

get_ring_info_small(self, uint64_t ring)

Return start index and number of pixels per healpix ring.

pix2ang(self, uint64_t pix)

Convert HEALPix index to angular coordinates \((\varphi, \vartheta)\).

pix2ang_many(self, long[)

Convert HEALPix indices to angular coordinates of \((\varphi, \vartheta)\) arrays.

pix2ring(self, uint64_t pix)

Return ‘ring’ number that contains the HEALPix pixel, ‘pix’.

pix2ring_many(self, long[)

Return ‘ring’ numbers containing HEALPix pixels given in array, ‘pix’.

query_disc(self, double theta, double phi, …)

Return hpx indices of a disc around \((\vartheta, \varphi)\).

query_disc_phi180(self, …)

Return HEALPix indices of a disc around \(\varphi=180^\circ\) for ‘disc_ring’.

Attributes Documentation

ncap
property ncapunsigned 64-bit int

Return the HEALPix ‘ncap’ parameter.

npface
property nfaceunsigned 64-bit int

Return the HEALPix ‘nface’ parameter.

npix
property npixunsigned 64-bit int

Return the HEALPix ‘npix’ parameter.

nrings
property nringsunsigned 64-bit int

Return the HEALPix ‘nrings’ parameter.

nside
property nsideunsigned 64-bit int

The HEALPix ‘nside’ parameter. (Re-)setting ‘nside’ updates other properties.

omega
property omegadouble

Return the solid angle, ‘omega’ of the HEALPix pixels for current nside.

order
property orderunsigned 64-bit int

Return the HEALPix ‘order’ parameter.

resolution
property resolutiondouble

Return the angular size of the HEALPix pixels for current nside.

scheme
property schemeenum

The HEALPix ‘scheme’. Currently only ‘RING’ is supported.

Methods Documentation

ang2pix(self, double theta, double phi)

Return the pixel index containing the angular coordinates \((\varphi, \vartheta)\).

Wrapper around the Cython-only (private) method _ang2pix.

Parameters
thetadouble

\(\vartheta\) coordinate (\(\vartheta = \pi/2 - \mathrm{latitude}\)).

phidouble

\(\varphi\) coordinate (longitude).

Returns
pixunsigned 64-bit int

The HEALPix pixel index.

Raises
ValueError

Invalid theta value.

ang2pix_many(self, double[::1] theta, double[::1] phi)

Return the pixel indices containing the angular coordinates of \((\varphi, \vartheta)\) arrays.

Wrapper around the Cython-only (private) method _ang2pix.

Parameters
thetaarray of doubles

\(\vartheta\) coordinate (\(\vartheta = \pi/2 - \mathrm{latitude}\)).

phiarray of doubles

\(\varphi\) coordinate (longitude).

Returns
pixarray of unsigned 64-bit ints

The HEALPix pixel index.

get_ring_info_small(self, uint64_t ring)

Return start index and number of pixels per healpix ring.

Wrapper around the Cython-only (private) method _get_ring_info_small.

Parameters
ringunsigned 64-bit int

The HEALPix ring parameter to get information on.

Returns
startpixunsigned 64-bit int

The HEALPix index of the first pixel in ring.

num_pix_in_ringunsigned 64-bit int

The number of HEALPix pixels in ring.

shiftedbool

Whether the central HEALPix pixel in that ring is shifted from \(\varphi=180^\circ\).

Raises
ValueError

Ring index not in valid range.

pix2ang(self, uint64_t pix)

Convert HEALPix index to angular coordinates \((\varphi, \vartheta)\).

Wrapper around the Cython-only (private) method _pix2ang.

Parameters
pixunsigned 64-bit int

The HEALPix pixel index.

Returns
thetadouble

\(\vartheta\) coordinate (\(\vartheta = \pi/2 - \mathrm{latitude}\)).

phidouble

\(\varphi\) coordinate (longitude).

Raises
ValueError

pix not in valid range.

pix2ang_many(self, long[::1] pix)

Convert HEALPix indices to angular coordinates of \((\varphi, \vartheta)\) arrays.

Wrapper around the Cython-only (private) method _pix2ang.

Parameters
pixarray of unsigned 64-bit ints

The HEALPix pixel index.

Returns
thetaarray of doubles

\(\vartheta\) coordinate (\(\vartheta = \pi/2 - \mathrm{latitude}\)).

phiarray of doubles

\(\varphi\) coordinate (longitude).

pix2ring(self, uint64_t pix)

Return ‘ring’ number that contains the HEALPix pixel, ‘pix’.

Wrapper around the Cython-only (private) method _pix2ring.

Parameters
pixunsigned 64-bit int

The HEALPix index.

Returns
ringunsigned 64-bit int

The HEALPix ring.

Raises
ValueError

Pixel index not in valid range.

pix2ring_many(self, long[::1] pix)

Return ‘ring’ numbers containing HEALPix pixels given in array, ‘pix’.

Wrapper around the Cython-only (private) method _pix2ring.

Parameters
pixarray of unsigned 64-bit ints

The HEALPix indices.

Returns
ringarray of unsigned 64-bit ints

The HEALPix rings.

query_disc(self, double theta, double phi, double disc_size_rad)

Return hpx indices of a disc around \((\vartheta, \varphi)\).

This uses query_disc_phi180 and shifts the pixels along ring.

Wrapper around the cython-only (private) method _query_disc.

Parameters
theta/phidouble

Coordinates \((\vartheta, \varphi)\) in radians.

disc_size_raddouble

Size of the disc in radians.

Returns
disc_indicesarray of unsigned 64-bit ints

The HEALPix indices of the disc.

query_disc_phi180(self, double disc_size_rad, uint64_t disc_ring)

Return HEALPix indices of a disc around \(\varphi=180^\circ\) for ‘disc_ring’.

This is a modified version of the HEALPix library query_disc routine that returns the HEALPix indices of a disc around arbitrary coordinates. Here, it was modified to only work for coordinates having \(\varphi=180^\circ\) and a \(\vartheta\) that coincides with the latitude of a HEALPix ring. These discs can be shifted along \(\varphi\) - which is faster than calling query_disc if one cashes the \(\varphi=180^\circ\) discs.

Wrapper around the Cython-only (private) method _query_disc_phi180.

Parameters
disc_size_raddouble

Size of the disc in radians.

disc_ringunsigned 64-bit int

HEALPix ring index of the requested disc center.

Returns
disc_indicesarray of unsigned 64-bit ints

The HEALPix indices of the disc.