Map functions

Map functions

Functions like pix2angNest and ang2pixNest fully define the Healpix tessellation scheme. They are however extremely impractical in a number of situations. It happens often that a large fraction of pixels in a map need to be processed together. Healpix.jl introduces the Map{T, O <: Order} type, which acts as a collection of all the pixels on the sphere. A Map type holds the value of all the pixels in its pixels field, and it keeps track of the ordering (either RING or NESTED). Here is an example that shows how to create a map and initialize it:

nside = 32
m = Map{Float64, RingOrder}(nside)
m.pixels[:] = 1.0  # Set all pixels to 1

Healpix.jl defines the basic operations on maps (sum, subtraction, multiplication, division). These operations can either combine two maps or a map and a scalar value:

mollweide(m * 2.0)
mollweide(m * m)
Healpix.MapType.

A Healpix map. The type T is used for the value of the pixels in a map, and it can be anything (even a string!). The type O is used to specify the ordering of the pixels, and it can either be RingOrder or NestedOrder.

source

Encoding the order

Healpix.jl distinguishes between RING and NEST orderings using Julia's typesystem. The abstract type Order has two descendeants, RingOrder and NestedOrder, which are used to instantiate objects of type Map.

Healpix.OrderType.

Abstract type representing the ordering of pixels in a Healpix map. See also RingOrder and NestedOrder.

source

The RingOrder type should be used when creating Map types in order to specify that the pixels in the map are sorted in ring ordering. (See also NestedOrder.)

source

The NestedOrder type should be used when creating Map types in order to specify that the pixels in the map are sorted in ring ordering. (See also RingOrder.)

source

Pixel functions

When working with maps, it is not needed to pick between ang2pixNest and ang2pixRing because a Map type already encodes the ordering. Functions pix2ang and ang2pix always choose the correct ordering, but they require a Map instead of a Resolution as their first argument.

Healpix.pix2angFunction.
pix2ang{T, O <: Order}(map::Map{T, O}, ipix) -> (Float64, Float64)

Return the pair (theta, phi), where theta is the colatitude and phi the longitude of the direction of the pixel center with index ipix.

source
Healpix.ang2pixFunction.
ang2pix{T, O <: Order}(map::Map{T, O}, theta::Real, phi::Real)

Convert the direction specified by the colatitude theta (∈ [0, π]) and the longitude phi (∈ [0, 2π]) into the index of the pixel in the Healpix map map.

source

Loading and saving maps

Healpix.jl implements a number of functions to save maps in FITS files.

Healpix.saveToFITSFunction.
saveToFITS{T <: Number, O <: Order}(map::Map{T, O},
                                    f::FITSIO.FITSFile,
                                    column)
saveToFITS{T <: Number, O <: Order}(map::Map{T, O},
                                    fileName::String,
                                    typechar="D",
                                    unit="",
                                    extname="MAP")

Save a Healpix map in the specified (1-based index) column in a FITS file. If the code fails, FITSIO will raise an exception. (Refer to the FITSIO library for more information.)

source
saveToFITS(map::Map{T, O}, filename::AbstractString, typechar="D", unit="", extname="MAP") where {T <: Number, O <: Order}

Save a map into a FITS file. The name of the file is specified in filename; if it begins with !, existing files will be overwritten without warning. The parameter typechar specifies the data type to be used in the FITS file: the default (D) will save 64-bit floating-point values. See the CFITSIO documentation for other values. The keyword unit specifies the measure unit used for the pixels in the map. The keyword extname specifies the name of the HDU where the map pixels will be written.

source

Function savePixelsToFITS is a low-level function. It knows nothing about the ordering schema used for the pixels, so the caller should manually write the ORDERING keyword in the HDU header by itself.

savePixelsToFITS(map::Map{T}, f::FITSIO.FITSFile, column) where {T <: Number}

Save the pixels of map into the column with index/name column in the FITS file, which must have been already opened.

source

To load a map from a FITS file, you can use readMapFromFITS.

readMapFromFITS{T <: Number}(f::FITSIO.FITSFILE, column, t::Type{T})
readMapFromFITS{T <: Number}(fileName::String, column, t::Type{T})

Read a Healpix map from the specified (1-base indexed) column in a FITS file. The values will be read as numbers of type T. If the code fails, FITSIO will raise an exception. (Refer to the FITSIO library for more information.)

source

Testing for conformability

It often happens that two Healpix maps need to be combined together: for instance, pixels on a sky map might need to be masked using a sky mask, or one map might need to be subtracted from another one. «Conformability» means that the operation between the two maps can be done directly on the pixels, without oordering or resolution conversions. The function conformables checks this.


julia> m1 = Map{Float64, RingOrder}(1)
12-element Map{Float64,RingOrder}:
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0

julia> m2 = Map{Float64, RingOrder}(1)
12-element Map{Float64,RingOrder}:
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0

julia> m3 = Map{Float64, NestedOrder}(1)
12-element Map{Float64,NestedOrder}:
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0

julia> m4 = Map{Float64, NestedOrder}(2)
48-element Map{Float64,NestedOrder}:
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 ⋮
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0

julia> conformables(m1, m2)
true

julia> conformables(m1, m3)
false

julia> conformables(m1, m4)
false
Healpix.conformablesFunction.
conformables{T, S, O1 <: Order, O2 <: Order}(map1::Map{T, O1},
                                             map2::Map{S, O2}) -> Bool

Determine if two Healpix maps are "conformables", i.e., if their shape and ordering are the same.

source

Map-making

Map-making is the process of converting a time series of measurements into a sky map. The most basic form of map-making is the so-called "binning", where samples in the time stream falling within the same sky pixel are averaged. This map-making algorithm is strictly accurate only if the noise in the time stream is white.

Healpix.jl implements two functions to perform binning, tod2map and combinemaps!.

Healpix.tod2mapFunction.
tod2map{T,O}(pixidx, tod::Array{T}; nside=128) :: (map, hits)

Create a binned map for a TOD and return a tuple containing the map itself and the hit map.

source
Healpix.combinemaps!Function.
combinemaps{T, O, H}(destmap::Map{T, O}, desthitmap::Map{H, O}, othermap::Map{T, O}, otherhitmap::Map{H, O})

Sum "othermap" to "destmap", assuming that both maps have been produced by binning TODs. The parameters desthitmap and otherhitmap are the two hit maps. At the end of the call, destmap and desthitmap are updated.

source