Pixel functions

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.

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 from

  • firstPixIdx: index of the first pixel (using the RING scheme) belonging to this ring

  • numOfPixels: number of consecutive pixels within the ring

  • colatitude_rad: value of the colatitude for this ring (in radians)

  • shifted: Boolean flag; it is true 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))
source
Healpix.getringinfoFunction.
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!.

source
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.

source
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.

source

Reference

Healpix.ang2vecMethod.
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.

source
Healpix.vec2angMethod.
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.

source
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)!

source
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)!

source
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.

source
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.

source
Healpix.ring2nestMethod.
ring2nest(resol::Resolution, ipix) :: Int

Convert the number of a pixel from RING to NESTED scheme.

source
Healpix.nest2ringMethod.
nest2ring(resol::Resolution, ipix) :: Int

Convert the number of a pixel from NESTED to RING scheme.

source
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 sky
  • i is the ring index, from 1 to 4NSIDE - 1
  • j is the pixel-in-ring index
source
pix2xyfNest(resol::Resolution, ipix) :: (Int, Int, Int)

Convert a pixel number into (x, y, face), using NESTED ordering.

source
pix2xyfRing(resol::Resolution, ipix) :: (Int, Int, Int)

Convert a pixel number into (x, y, face), using RING ordering.

source
xyf2pixNest(resol::Resolution, ix, iy, facenum) :: Int

Convert (x, y, face) into a pixel number, using NESTED ordering.

source
xyf2pixRing(resol::Resolution, ix, iy, facenum) :: Int

Convert (x, y, face) into a pixel number, using RING ordering.

source