Pixel functions
In this section we document the functions that convert from a direction in the sky into a pixel index, and vice versa.
First of all, Healpix.jl implements the most basic functions to convert between spherical and Cartesian coordinates. Note that Healpix uses co-latitude instead of latitude:
julia> ang2vec(0.0, 0.0)
3-element Array{Float64,1}:
0.0
0.0
1.0
julia> vec2ang(0.0, 0.0, 1.0)
(0.0, 0.0)
More interesting functions return the index of the pixel on a Healpix-tessellated sphere. For these functions to work, you have to provide a Resolution
object:
julia> res = Resolution(16)
Healpix resolution(NSIDE = 16)
julia> ang2pixRing(res, π/2, 0)
1441
julia> ang2pixNest(res, π/2, 0)
1217
Ring functions
The Healpix projection has the advantage of storing pixels along iso-latitude rings; this allows to implement efficient spherical-transform functions. Healpix.jl provides a number of functions that manage rings. Many of them use the RingInfo
structure, which encodes details about a ring.
Healpix.RingInfo
— Type.RingInfo
Information about a ring of pixels, i.e., the set of pixels on a Healpix map which have the same colatitude. The type is "mutable", so that one object can begin reused many times without further memory allocations.
The list of fields defined in this structure is the following:
ring
: an integer index, running fromfirstPixIdx
: index of the first pixel (using theRING
scheme) belonging to this ringnumOfPixels
: number of consecutive pixels within the ringcolatitude_rad
: value of the colatitude for this ring (in radians)shifted
: Boolean flag; it istrue
if the longitude of the first pixel in the ring is not zero.
References
See also getringinfo!
and getringinfo
.
Example
import Healpix
res = Healpix.Resolution(256)
# Show information about ring #10
print(getringinfo(res, 10))
Healpix.getringinfo
— Function.getringinfo(resol::Resolution, ring; kwargs...) :: RingInfo
Return a RingInfo structure containing information about the specified ring. For the list of accepted keyword arguments, see getringinfo!.
Healpix.getringinfo!
— Function.getringinfo!(resol::Resolution, ring, ringinfo::RingInfo; full=true) :: RingInfo
Fill the RingInfo structure with information about the specified ring. If full
is false
, the field colatitude_rad
(the most expensive in terms of computation) is set to NaN
.
Healpix.getinterpolRing
— Function.getinterpolRing(resol::Resolution, θ, ϕ) :: (Array{Int,1}, Array{Float64, 1})
Return the indices and the weights of the four neighbour pixels for the given direction (θ, ϕ) in a map with the specified resolution.
Reference
Healpix.ang2vec
— Method.ang2vec(theta, phi) -> Array{Float64}
Given a direction in the sky with colatitude theta
and longitude phi
(in radians), return an array of 3 elements containing the x
, y
, and z
components of the one-length vector pointing to that direction.
Healpix.vec2ang
— Method.vec2ang(x, y, z) -> (Number, Number)
Given a vector (not necessarily normalized) whose Cartesian components are x
, y
, and z
, return a pair (theta
, phi
) containing the colatitude theta
and the longitude phi
(in radians) of the direction in the sky the vector is pointing at.
Healpix.ang2pixNest
— Method.ang2pixNest(resol::Resolution, theta, phi) -> Integer
Return the index of the pixel which contains the point with coordinates (theta
, the colatitude, and phi
, the longitude), in radians, for a Healpix map with pixels in nested order. Note that pixel indexes are 1-based (this is Julia)!
Healpix.ang2pixRing
— Method.ang2pixRing(resol::Resolution, theta, phi) -> Integer
Return the index of the pixel which contains the point with coordinates (theta
, the colatitude, and phi
, the longitude), in radians, for a Healpix map with pixels in ring order. Note that pixel indexes are 1-based (this is Julia)!
Healpix.pix2angNest
— Method.pix2angNest(resol::Resolution, pixel) -> (Float64, Float64)
Given the (1-based) index of a pixel in a Healpix map in nested order, return a pair containing the (colatitude
, longitude
) angles corresponding to its center, both expressed in radians.
Healpix.pix2angRing
— Method.pix2angRing(resol::Resolution, pixel) -> (Float64, Float64)
Given the (1-based) index of a pixel in a Healpix map in ring order, return a pair containing the (colatitude
, longitude
) angles corresponding to its center, both expressed in radians.
Healpix.ring2nest
— Method.ring2nest(resol::Resolution, ipix) :: Int
Convert the number of a pixel from RING to NESTED scheme.
Healpix.nest2ring
— Method.nest2ring(resol::Resolution, ipix) :: Int
Convert the number of a pixel from NESTED to RING scheme.
Healpix.pix2ringpos
— Method.pix2ringpos(resol::Resolution, pixel)
Given the (1-based) index of a pixel in a Healpix map in ring order, return a pair of numbers (n, i, j) whose meaning is the following:
n
can be one of the symbols:northcap
,:equator
, or:southcap
, representing the region of the skyi
is the ring index, from 1 to 4NSIDE - 1j
is the pixel-in-ring index
Healpix.pix2xyfNest
— Method.pix2xyfNest(resol::Resolution, ipix) :: (Int, Int, Int)
Convert a pixel number into (x, y, face), using NESTED ordering.
Healpix.pix2xyfRing
— Method.pix2xyfRing(resol::Resolution, ipix) :: (Int, Int, Int)
Convert a pixel number into (x, y, face), using RING ordering.
Healpix.xyf2pixNest
— Method.xyf2pixNest(resol::Resolution, ix, iy, facenum) :: Int
Convert (x, y, face) into a pixel number, using NESTED ordering.
Healpix.xyf2pixRing
— Method.xyf2pixRing(resol::Resolution, ix, iy, facenum) :: Int
Convert (x, y, face) into a pixel number, using RING ordering.