HEALPix¶
- class astropy_healpix.HEALPix(nside=None, order='ring', frame=None)[source]¶
Bases:
object
A HEALPix pixellization.
- Parameters:
- nsideint
Number of pixels along the side of each of the 12 top-level HEALPix tiles
- order{ ‘nested’ | ‘ring’ }, optional
Order of HEALPix pixels. Input string can be lower or upper case.
- framestr or
BaseCoordinateFrame
, optional The celestial coordinate frame of the pixellization. This can be ommitted, in which case the pixellization will not be attached to any particular celestial frame, and the methods ending in _skycoord will not work (but the _lonlat methods will still work and continue to return generic longitudes/latitudes). The frame may be passed as a string (such as
galactic
), as a frame class, or as an instance of a frame class.
- Raises:
- ValueError
If ‘order’ is not one of the allowed options.
Attributes Summary
The HEALPix level.
The number of pixels in the pixellization of the sphere.
The area of a single HEALPix pixel.
The resolution of a single HEALPix pixel.
Methods Summary
bilinear_interpolation_weights
(lon, lat)Get the four neighbours for each (lon, lat) position and the weight associated with each one for bilinear interpolation.
boundaries_lonlat
(healpix_index, step)Return the longitude and latitude of the edges of HEALPix pixels
boundaries_skycoord
(healpix_index, step)Return the celestial coordinates of the edges of HEALPix pixels
cone_search_lonlat
(lon, lat, radius)Find all the HEALPix pixels within a given radius of a longitude/latitude.
cone_search_skycoord
(skycoord, radius)Find all the HEALPix pixels within a given radius of a celestial position.
from_header
(input_data[, field, hdu_in, nested])- Parameters:
healpix_to_lonlat
(healpix_index[, dx, dy])Convert HEALPix indices (optionally with offsets) to longitudes/latitudes
healpix_to_skycoord
(healpix_index[, dx, dy])Convert HEALPix indices (optionally with offsets) to celestial coordinates.
healpix_to_xyz
(healpix_index[, dx, dy])Convert HEALPix indices (optionally with offsets) to Cartesian coordinates
interpolate_bilinear_lonlat
(lon, lat, values)Interpolate values at specific longitudes/latitudes using bilinear interpolation
interpolate_bilinear_skycoord
(skycoord, values)Interpolate values at specific celestial coordinates using bilinear interpolation.
lonlat_to_healpix
(lon, lat[, return_offsets])Convert longitudes/latitudes to HEALPix indices (optionally with offsets)
neighbours
(healpix_index)Find all the HEALPix pixels that are the neighbours of a HEALPix pixel
nested_to_ring
(nested_index)Convert a healpix 'nested' index to a healpix 'ring' index
ring_to_nested
(ring_index)Convert a healpix 'ring' index to a healpix 'nested' index
skycoord_to_healpix
(skycoord[, return_offsets])Convert celestial coordinates to HEALPix indices (optionally with offsets).
xyz_to_healpix
(x, y, z[, return_offsets])Convert Cartesian coordinates to HEALPix indices (optionally with offsets)
Attributes Documentation
- level¶
The HEALPix level.
- npix¶
The number of pixels in the pixellization of the sphere.
- pixel_area¶
The area of a single HEALPix pixel.
- pixel_resolution¶
The resolution of a single HEALPix pixel.
Methods Documentation
- bilinear_interpolation_weights(lon, lat)[source]¶
Get the four neighbours for each (lon, lat) position and the weight associated with each one for bilinear interpolation.
- Parameters:
- Returns:
- boundaries_lonlat(healpix_index, step)[source]¶
Return the longitude and latitude of the edges of HEALPix pixels
This returns the longitude and latitude of points along the edge of each HEALPIX pixel. The number of points returned for each pixel is
4 * step
, so settingstep
to 1 returns just the corners.
- boundaries_skycoord(healpix_index, step)[source]¶
Return the celestial coordinates of the edges of HEALPix pixels
This returns the celestial coordinates of points along the edge of each HEALPIX pixel. The number of points returned for each pixel is
4 * step
, so settingstep
to 1 returns just the corners.This method requires that a celestial frame was specified when initializing HEALPix. If you don’t know or need the celestial frame, you can instead use
boundaries_lonlat()
.
- cone_search_lonlat(lon, lat, radius)[source]¶
Find all the HEALPix pixels within a given radius of a longitude/latitude.
Note that this returns all pixels that overlap, including partially, with the search cone. This function can only be used for a single lon/lat pair at a time, since different calls to the function may result in a different number of matches.
- cone_search_skycoord(skycoord, radius)[source]¶
Find all the HEALPix pixels within a given radius of a celestial position.
Note that this returns all pixels that overlap, including partially, with the search cone. This function can only be used for a single celestial position at a time, since different calls to the function may result in a different number of matches.
This method requires that a celestial frame was specified when initializing HEALPix. If you don’t know or need the celestial frame, you can instead use
cone_search_lonlat()
.
- classmethod from_header(input_data, field=0, hdu_in=None, nested=None)[source]¶
- Parameters:
- input_datastr or
TableHDU
orBinTableHDU
or tuple The input data to reproject. This can be:
The name of a HEALPIX FITS file
A
TableHDU
orBinTableHDU
instanceA tuple where the first element is a
ndarray
and the second element is aBaseCoordinateFrame
instance or a string alias for a coordinate frame.
- hdu_inint or str, optional
If
input_data
is a FITS file, specifies the HDU to use. (the default HDU for HEALPIX data is 1, unlike with image files where it is generally 0)- nestedbool, optional
The order of the healpix_data, either nested (True) or ring (False). If a FITS file is passed in, this is determined from the header.
- input_datastr or
- Returns:
- healpix
HEALPix
A HEALPix pixellization corresponding to the input data.
- healpix
- healpix_to_lonlat(healpix_index, dx=None, dy=None)[source]¶
Convert HEALPix indices (optionally with offsets) to longitudes/latitudes
- Parameters:
- Returns:
- healpix_to_skycoord(healpix_index, dx=None, dy=None)[source]¶
Convert HEALPix indices (optionally with offsets) to celestial coordinates.
Note that this method requires that a celestial frame was specified when initializing HEALPix. If you don’t know or need the celestial frame, you can instead use
healpix_to_lonlat()
.- Parameters:
- Returns:
- coord
SkyCoord
The resulting celestial coordinates
- coord
- healpix_to_xyz(healpix_index, dx=None, dy=None)[source]¶
Convert HEALPix indices (optionally with offsets) to Cartesian coordinates
- Parameters:
- Returns:
- interpolate_bilinear_lonlat(lon, lat, values)[source]¶
Interpolate values at specific longitudes/latitudes using bilinear interpolation
If a position does not have four neighbours, this currently returns NaN.
- Parameters:
- Returns:
- result
ndarray
1-D array of interpolated values
- result
- interpolate_bilinear_skycoord(skycoord, values)[source]¶
Interpolate values at specific celestial coordinates using bilinear interpolation.
If a position does not have four neighbours, this currently returns NaN.
Note that this method requires that a celestial frame was specified when initializing HEALPix. If you don’t know or need the celestial frame, you can instead use
interpolate_bilinear_lonlat()
.
- lonlat_to_healpix(lon, lat, return_offsets=False)[source]¶
Convert longitudes/latitudes to HEALPix indices (optionally with offsets)
- Parameters:
- Returns:
- neighbours(healpix_index)[source]¶
Find all the HEALPix pixels that are the neighbours of a HEALPix pixel
- Parameters:
- healpix_index
ndarray
Array of HEALPix pixels
- healpix_index
- Returns:
- neigh
ndarray
Array giving the neighbours starting SW and rotating clockwise. This has one extra dimension compared to
healpix_index
- the first dimension - which is set to 8. For example if healpix_index has shape (2, 3),neigh
has shape (8, 2, 3).
- neigh
- skycoord_to_healpix(skycoord, return_offsets=False)[source]¶
Convert celestial coordinates to HEALPix indices (optionally with offsets).
Note that this method requires that a celestial frame was specified when initializing HEALPix. If you don’t know or need the celestial frame, you can instead use
lonlat_to_healpix()
.- Parameters:
- Returns: