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.Map
— Type.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
.
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.Order
— Type.Abstract type representing the ordering of pixels in a Healpix map. See also RingOrder
and NestedOrder
.
Healpix.RingOrder
— Type.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
.)
Healpix.NestedOrder
— Type.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
.)
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.pix2ang
— Function.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
.
Healpix.ang2pix
— Function.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
.
Loading and saving maps
Healpix.jl implements a number of functions to save maps in FITS files.
Healpix.saveToFITS
— Function.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.)
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.
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.
Healpix.savePixelsToFITS
— Function.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.
To load a map from a FITS file, you can use readMapFromFITS
.
Healpix.readMapFromFITS
— Function.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.)
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.conformables
— Function.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.
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.tod2map
— Function.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.
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.