25
The HEALPix Primer Revision: Version 3.80; June 22, 2021 Prepared by: Krzysztof M. Górski, Benjamin D. Wandelt, Eric Hivon, Frode K. Hansen, and Anthony J. Banday Abstract: HEALPix is a Hierarchical, Equal Area, and iso- Latitude Pixelation of the sphere designed to sup- port efficiently (1) local operations on the pixel set, (2) a hierarchical tree structure for multi-resolution applications, and (3) the global Fast Spherical Har- monic transform. HEALPix based mathematical software meets the challenges presented by high reso- lution and large volume data sets, such as the WMAP and Planck CMB mission products. https://healpix.sourceforge.io http://healpix.sf.net

The HEALPix Primer

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The HEALPix Primer

The HEALPix Primer

Revision: Version 3.80; June 22, 2021

Prepared by: Krzysztof M. Górski, Benjamin D. Wandelt, EricHivon, Frode K. Hansen, and Anthony J. Banday

Abstract: HEALPix is a Hierarchical, Equal Area, and iso-Latitude Pixelation of the sphere designed to sup-port efficiently (1) local operations on the pixel set,(2) a hierarchical tree structure for multi-resolutionapplications, and (3) the global Fast Spherical Har-monic transform. HEALPix based mathematicalsoftware meets the challenges presented by high reso-lution and large volume data sets, such as the WMAPand Planck CMB mission products.

https://healpix.sourceforge.iohttp://healpix.sf.net

Page 2: The HEALPix Primer

2 The HEALPix Primer

TABLE OF CONTENTS1 Introduction 3

2 Discretisation of Functions on the Sphere 4

3 Geometric and Algebraic Properties of HEALPix 63.1 RING and NESTED numbering schemes . . . . . . . . . . . . . . . . . . . 73.2 The Unique Identifier scheme . . . . . . . . . . . . . . . . . . . . . . . . . 9

4 The HEALPix Software Package 104.1 Contents and purposes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.2 Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

A HEALPix conventions 12A.1 Angular power spectrum conventions . . . . . . . . . . . . . . . . . . . . . 12A.2 HEALPix and Boltzmann codes . . . . . . . . . . . . . . . . . . . . . . . 13

A.2.1 CMBFAST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13A.2.2 CAMB and CLASS . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

A.3 Polarisation convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14A.3.1 Internal convention . . . . . . . . . . . . . . . . . . . . . . . . . . . 14A.3.2 Relation to previous releases . . . . . . . . . . . . . . . . . . . . . . 18A.3.3 Relation with IAU convention . . . . . . . . . . . . . . . . . . . . . 19A.3.4 How HEALPix deals with these discrepancies: POLCCONV keyword 20

A.4 Spherical harmonic conventions . . . . . . . . . . . . . . . . . . . . . . . . 21

B Pixel window functions 21

C A Comment on the Random Number Generator 23

D Finite precision and cross-platform reproducibility 23

References 24

HEALPix 3.80

Page 3: The HEALPix Primer

Introduction 3

1 Introduction

The analysis of functions on domains with spherical topology occupies a central place inphysical science and engineering disciplines. This is particularly apparent in the fields ofastronomy, cosmology, geophysics, atomic and nuclear physics. In many cases the geometryis either dictated by the object under study or approximate spherical symmetry can beexploited to yield powerful perturbation methods. Practical limits for the purely analyticalstudy of these problems create an urgent necessity for efficient and accurate numerical tools.The simplicity of the spherical form belies the intricacy of global analysis on the sphere.There is no known point set which achieves the analogue of uniform sampling in Euclideanspace and allows exact and invertible discrete spherical harmonic decompositions of arbi-trary but band-limited functions. Any existing proposition of practical schemes for thediscrete treatment of such functions on the sphere introduces some (hopefully tiny) sys-tematic error dependent on the global properties of the point set. The goal is to minimisethese errors and faithfully represent deterministic functions as well as realizations of ran-dom variates both in configuration and Fourier space while maintaining computationalefficiency.We illustrate these points using as an example the field which is particularly close to theauthors’ hearts, Cosmic Microwave Background (CMB) anisotropies. As some of us hadlearned while working with the COBE mission (launched by NASA in 1989) products thedigitised sky map is an essential intermediate stage in information processing betweenthe entry point of data acquisition by the instruments — very large time ordered datastreams, and the final stage of astrophysical analysis — typically producing a ’few’ numer-ical values of physical parameters of interest. COBE-DMR sky maps (angular resolutionof 7(FWHM) in three frequency bands, two channels each, 6144 pixels per map) wereconsidered large at the time of their release.In the following decade, we saw an explosion of available data. The Wilkinson MicrowaveAnisotropy Probe (WMAP, launched by NASA in 2001) and Planck Surveyor (launchedby ESA in 2009) were aiming at providing multi-frequency, high resolution, full sky mea-surements of the anisotropy in both temperature and polarization of the cosmic microwavebackground radiation. The ultimate data products of these missions — multiple microwavesky maps, each of which comprises more than ∼ 106 pixels in order to render the angularresolution of the instruments — presented serious challenges to those involved in the anal-ysis and scientific exploitation of the results of both surveys, and motived the developmentof many new theoretical and numerical tools.As for ongoing and future CMB maps, a whole sky CMB survey at the angular resolu-tion of ∼ 10′ (FWHM), discretised with a few pixels per resolution element (so that thediscretisation effects on the signal are sub-dominant with respect to the effects of instru-ment’s angular response), require map sizes of at least Npix ∼ 107 pixels. More pixels thanthat are needed to represent the Planck-HFI higher resolution channels. This estimate,Npix, should be multiplied by the number of frequency bands (or, indeed, by the numberof individual observing channels — 74 in the case of Planck — for the analysis work to

HEALPix 3.80

Page 4: The HEALPix Primer

4 The HEALPix Primer

be done before the final coadded maps are made for each frequency band) to render anapproximate expected size of the already very compressed form of survey data which is theinput to the astrophysical analysis pipeline.It appears to us that very careful attention ought to be given to devising high resolutionCMB map structures which can maximally facilitate the forthcoming analyses of large sizedata sets, for the following reasons:

• It is clearly very easy to end up with an estimated size of many GBy for the dataobjects which would be directly involved in the science extraction part of the futureCMB missions.

• Many essential scientific questions can only be answered by global studies of futuredata sets.

This document is an introduction to the properties of our proposed approach for a highresolution numerical representation of functions on the sphere — the Hierarchical EqualArea and iso-Latitude Pixelation (HEALPix, see https://healpix.sourceforge.io),and the associated multi-purpose computer software package.

2 Discretisation of Functions on the Sphere forHigh Resolution Applications: a Motivation forHEALPix

Numerical analysis of functions on the sphere involves (1) a class of mathematical oper-ations, whose objects are (2) discretised maps, i.e. quantizations of arbitrary functionsaccording to a chosen tessellation (exhaustive partition of the sphere into finite area el-ements). Hereafter we mostly specialise our discussion to CMB related applications ofHEALPix, but all our statements hold true generally for any relevant deterministic andrandom functions on the sphere.Considering point (1): Standard operations of numerical analysis which one might wish toexecute on the sphere include convolutions with local and global kernels, Fourier analysiswith spherical harmonics and power spectrum estimation, wavelet decomposition, nearest-neighbour searches, topological analysis, including searches for extrema or zero-crossings,computing Minkowski functionals, extraction of patches and finite differencing for solvingpartial differential equations. Some of these operations become prohibitively slow if thesampling of functions on the sphere, and the related structure of the discrete data set, arenot designed carefully.Regarding point (2): Typically, a whole sky map rendered by a CMB experiment contains(i) signals coming from the sky, which are by design strongly band-width limited (in thesense of spatial Fourier decomposition) by the instrument’s angular response function, and

HEALPix 3.80

Page 5: The HEALPix Primer

Discretisation of Functions on the Sphere 5

(ii) a projection into the elements of a discrete map, or pixels, of the observing instrument’snoise; this pixel noise should be random, and white, at least near the discretisation scale,with a band-width significantly exceeding that of all the signals.With these considerations in mind we propose the following list of desiderata for the math-ematical structure of discretised full sky maps:1. Hierarchical structure of the data base. This is recognised as essential forvery large data bases, and was postulated in construction of the Quadrilateralized Spheri-cal Cube (or quad-sphere, see https://lambda.gsfc.nasa.gov/product/cobe/skymap_info_new.cfm), which was used for the COBE data. An argument in favour of this propo-sition states that the data elements which are nearby in a multi-dimensional configura-tion space (here, on the surface of a sphere), are also nearby in the tree structure of thedata base, hence the near-neighbour searches are conducted optimally in the data stor-age medium or computer RAM. This property, especially when implemented with a smallnumber of base resolution elements, facilitates various topological methods of analysis, andallows easy construction of wavelet transforms on quadrilateral (and also triangular) grids.Figure 1 shows how a hierarchical partition with quadrilateral structure naturally allowsfor a binary vector indexing of the data base.

2010121101

010011 10201 200

2

810

911

14 12

2

0111211

3 1

0

2

00 00 102 00 22

Degrade

Prograde

11

10 102 10 00

1021110

1011 2

01 20100211002

6

00210

201211

2

3 14

571315

2 0

Figure 1: Quadrilateral tree pixel numbering. The coarsely pixelated coordinate patch onthe left consists of four pixels. Two bits suffice to label the pixels. To increase the resolution,every pixel splits into 4 daughter pixels shown on the right. These daughters inherit thepixel index of their parent (boxed) and acquire two new bits to give the new pixel index.Several such curvilinearly mapped coordinate patches (12 in the case of HEALPix, and 6in the case of the COBE quad-sphere) are joined at the boundaries to cover the sphere. Allpixels indices carry a prefix (here omitted for clarity) which identifies which base-resolutionpixel they belong to.

2. Equal areas of discrete elements of partition. This is advantageous because(i) white noise generated by the signal receiver gets integrated exactly into white noisein the pixel space, and (ii) sky signals are sampled without regional dependence, except

HEALPix 3.80

Page 6: The HEALPix Primer

6 The HEALPix Primer

for the dependence on pixel shapes, which is unavoidable with tessellations of the sphere.Hence, as much as possible given the experimental details, the pixel size should be madesufficiently small compared to the instrument’s resolution to avoid any excessive, and pixelshape dependent, signal smoothing.3. Iso-Latitude distribution of discrete area elements on a sphere. This prop-erty is critical for computational speed of all operations involving evaluation of sphericalharmonics. Since the associated Legendre polynomial components of spherical harmonicsare evaluated via slow recursions, and can not be simply handled in an analogous way tothe trigonometric Fast Fourier Transform, any deviations in the sampling grid from aniso-latitude distribution result in a prohibitive loss of computational performance with thegrowing number of sampling points, or increasing map resolution. It is precisely this prop-erty that the COBE quad-sphere is lacking, and this renders it impractical for applicationsto high resolution data.A number of tessellations have been used for discretisation and analysis of functions on thesphere (for example, see Driscoll & Healy (1994), Muciaccia, Natoli & Vittorio (1998),Doroshkevich et al. (2005) — rectangular grids, Baumgardner & Frederickson (1985),Tegmark (1996) — icosahedral grids, Saff & Kuijlaars (1997), Crittenden & Turok (1998)— ‘igloo’ grids, and Szalay & Brunner (1998) — a triangular grid), but none satisfiessimultaneously all three stated requirements.All three requirements formulated above are satisfied by construction with the HierarchicalEqual Area, iso-Latitude Pixelation (HEALPix) of the sphere, which is shown in Figure 2.A more detailed description of HEALPix, its motivations, and applications can be foundin Górski et al. (2005).

3 Geometric and Algebraic Properties of HEALPix

HEALPix is a genuinely curvilinear partition of the sphere into exactly equal area quadri-laterals of varying shape. The base-resolution comprises twelve pixels in three rings aroundthe poles and equator.The resolution of the grid is expressed by the parameter Nside which defines the numberof divisions along the side of a base-resolution pixel that is needed to reach a desiredhigh-resolution partition.All pixel centers are placed on 4×Nside−1 rings of constant latitude, and are equidistant inazimuth (on each ring). All iso-latitude rings located between the upper and lower cornersof the equatorial base-resolution pixels, the equatorial zone, are divided into the samenumber of pixels: Neq = 4 × Nside. The remaining rings are located within the polar capregions and contain a varying number of pixels, increasing from ring to ring with increasingdistance from the poles by one pixel within each quadrant.Pixel boundaries are non-geodesic and take the very simple forms cos θ = a ± b · φ in theequatorial zone (| cos θ| ≤ 2/3), and cos θ = a + b/φ2, or cos θ = a + b/(π/2 − φ)2, in the

HEALPix 3.80

Page 7: The HEALPix Primer

3.1 RING and NESTED numbering schemes 7

Figure 2: Orthographic view of HEALPix partition of the sphere. Overplot of equator andmeridians illustrates the octahedral symmetry of HEALPix. Light-gray shading showsone of the eight (four north, and four south) identical polar base-resolution pixels. Dark-gray shading shows one of the four identical equatorial base-resolution pixels. Movingclockwise from the upper left panel the grid is hierarchically subdivided with the gridresolution parameter equal to Nside = 1, 2, 4, 8, and the total number of pixels equal toNpix = 12×N2

side = 12, 48, 192, 768. All pixel centers are located on Nring = 4×Nside − 1rings of constant latitude. Within each panel the areas of all pixels are identical.

polar caps, with θ being the co-latitude, and φ the longitude. This allows one to explicitlycheck by simple analytical integration the exact area equality among pixels (Górski et al.2005), and to compute efficiently more complex objects, e.g. the Fourier transforms ofindividual pixels.

3.1 RING and NESTED numbering schemes

Specific geometrical properties allow HEALPix to support two different numberingschemes for the pixels, as illustrated in Figure 3.First, in the RING scheme, one can simply count the pixels moving down from the northto the south pole along each iso-latitude ring. It is in the RING scheme that Fouriertransforms with spherical harmonics are easy to implement.Second, in the NESTED scheme, one can arrange the pixel indices in twelve tree structures,

HEALPix 3.80

Page 8: The HEALPix Primer

8 The HEALPix Primer

Figure 3: Cylindrical projection of the HEALPix division of a sphere and two naturalpixel numbering schemes (RING and NESTED) allowed by HEALPix. Both numberingschemes map the two dimensional distribution of discrete area elements on a sphere into theone dimensional, integer pixel number array, which is essential for computations involvingdata sets with very large total pixel numbers. From top to bottom: Panel one (resolutionparameterNside = 2) and panel two (Nside = 4) show the RING scheme for pixel numbering,with the pixel number winding down from north to south pole through the consecutiveisolatitude rings. Panel three (resolution parameter Nside = 2) and panel four (Nside = 4)show the NESTED scheme for pixel numbering within which the pixel number growswith consecutive hierarchical subdivisions on a tree structure seeded by the twelve base-resolution pixels.

HEALPix 3.80

Page 9: The HEALPix Primer

3.2 The Unique Identifier scheme 9

corresponding to base-resolution pixels. Each of those is organised as shown in Fig. 1. Thiscan easily be implemented since, due to the simple description of pixel boundaries, theanalytical mapping of the HEALPix base-resolution elements (curvilinear quadrilaterals)into a [0,1]×[0,1] square exists. This tree structure allows one to implement efficientlyall applications involving nearest-neighbour searches (Wandelt, Hivon & Górski 1998), andalso allows for an immediate construction of the fast Haar wavelet transform onHEALPix.

3.2 The Unique Identifier scheme

As exposed above, aHEALPix pixel is identified by three variables: its numbering scheme(RING or NESTED), its resolution or size parameter Nside = 2k (where k is a integersometimes called ’order’), and its index p lying in [0, 12N2

side − 1]. Since some applicationsrequire to process simultaneously pixels of different resolutions, it is possible to merge theresolution Nside and index p into a single unique number u

u = p+ 4N2side, (1)

so that all pixels with Nside = 1 have the unique indices 4 to 15, those with Nside = 2 arein the range 16 to 63, and so on (Reinecke & Hivon 2015), thus simplifying the handlingof data with heteregenous Nside. Splitting the unique index u into its original Nside and pis as simple as

Nside = 2floor(log2(u/4)/2), (2)p = u− 4N2

side, (3)

giving immediate access to the usual pixel based tools.

This unique indexing could in principle be applied to both the RING and NESTEDschemes, even though the latter appears more relevant for a hierarchical description ofdata with variable resolutions: since, as noted previously, a pixel with NESTED indexp at resolution Nside is subdivided in four pixels with index 4p, 4p + 1, 4p + 2, 4p + 3 atresolution 2Nside, Eq. (1) shows that a pixel with Nested-based unique identifier u is sub-divided in four smaller pixels whose unique identifiers are 4u, 4u+ 1, 4u+ 2, 4u+ 3. ThisNested-based Unique identification is for instance the basis of the NUNIQ storage schemeused for Multi-Order Coverage map (MOC) description of astronomical datasets proposedfor virtual observatories (Boch et al. 2014).

Routines implementing Eqs (1) and (2, 3) in various languages have been available sincerelease 3.30.

HEALPix 3.80

Page 10: The HEALPix Primer

10 The HEALPix Primer

4 The HEALPix Software Package

4.1 Contents and purposes

We have developed a package of HEALPix based mathematical software, consisting ofC, C++, Fortran90, IDL/GDL, Java and Python source codes as well as documentationand examples. Successful installation produces a set of facilities using standardised FITSI/O interfaces (https://heasarc.gsfc.nasa.gov/docs/software/fitsio) as well as li-braries which users can link to their own applications. Among the tasks performed by thecomponents of the HEALPix package are the following:

• Simulation of the full sky CMB temperature and polarisation maps as realisationsof random Gaussian fields, with an option to constrain the realisation by prior infor-mation.

• Analysis of the full sky CMB temperature and polarisation maps resulting in powerspectra and/or spherical harmonic coefficients. Relevant conventions are given in Ap-pendix A.Note that the convention used for polarization has been changedin release 1.2!.• Global smoothing of whole sky maps with a Gaussian kernel.

• Degradation and upgrade of the resolution of discrete maps.

• Global searches on the maps for nearest-neighbours and the maxima/minima of thediscretised functions.

• Algebraic conversion of the maps between the RING and NESTED numberingschemes, and mapping back and forth between positions on the sphere and discretepixel index space.

• Pixel queries for various geometrical shapes (discs, triangles, polygons ...)

• Visualisation of the HEALPix formatted sky maps in the Mollweide, orthographic,cartesian cylindrical and gnomonic projections of the whole sky or small areas of it.

The package includes documents which describe the installation process, the facilities avail-able and a large number of subroutines contained in the various libraries. It is available tothe scientific community at https://healpix.sourceforge.io.HEALPix was the format chosen by the WMAP collaboration for the production of skymaps (see https://map.gsfc.nasa.gov/news/index.html) from the mission data.HEALPix software and format have been used by the HFI and LFI consortia of Planckcollaboration for the simulation, analysis and data release of Planck data (see https://www.cosmos.esa.int/web/planck).

HEALPix 3.80

Page 11: The HEALPix Primer

4.2 Licensing 11

HEALPix software has been selected by the GAIA satellite mission currently sur-veying our Galaxy (see https://www.esa.int/Our_Activities/Space_Science/Gaia_overview)

4.2 Licensing

The full-fledged HEALPix software package described above and in the accompanyingdocumentation can be downloaded from https://sourceforge.net/projects/healpix/files/latest/download under version 2 of the GNU General Public License (GPLv2)which is described at length in https://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.html.

Beside this, a subset of C routines called healpix_bare, and providing support forback and forth conversion between pixel indexes and angular or vector coordinateson the sphere, and between RING and NESTED pixel indexes, is available fromhttps://sourceforge.net/projects/healpix/files/healpix_bare_1.0 under a morepermissive 3-clause BSD license. It was developed with a focus on accuracy, reliabilityand clarity, with good timing performances, and is intended for developers of BSD-licensedHEALPix related codes, so that they won’t have to reimplement some central algorithms.However, for ultimate optimization, and to get all the features of HEALPix, theGPLv2-licensed package must be used.

HEALPix 3.80

Page 12: The HEALPix Primer

12 The HEALPix Primer

A HEALPix conventions

A bandlimited function f on the sphere can be expanded in spherical harmonics, Y`m, as

f(γ) =`max∑`=0

∑m

a`mY`m(γ), (4)

where γ denotes a unit vector pointing at polar angle θ ∈ [0, π] and azimuth φ ∈ [0, 2π).Here we have assumed that there is insignificant signal power in modes with ` > `max andintroduce the notation that all sums over m run from −`max to `max but all quantities withindex `m vanish for m > `. Our conventions for Y`m are defined in subsection A.4 below.The spherical harmomics coefficients are then

a`m ≡∫dγY ∗`m(γ)f(γ), (5)

where, the integral is done over the whole sphere, and the superscript star denotes complexconjugation.Pixelating f(γ) corresponds to sampling it at Npix locations γp, p ∈ [0, Npix − 1]. Thesample function values fp can then be used to estimate a`m. A straightforward estimatoris

a`m = 4πNpix

Npix−1∑p=0

Y ∗`m(γp)f(γp), (6)

where an equal weight was assumed for each pixel. This zeroth order estimator, as wellas higher order estimators, are implemented in various Fortran90, C++, IDL, and pythonfacilities included in the package, such as anafast or anafast_cxx.

A.1 Angular power spectrum conventions

These a`m can be used to compute estimates of the angular power spectrum C` as

C` = 12`+ 1

∑m

|a`m|2. (7)

Equations (6) and (7) above do not consider the impact of a pixel masking or weightingf(γp) −→ f(γp)w(γp) on the power spectrum estimation of f , which is described in Wan-delt, Hivon & Górski (2001) and addressed in Hivon et al. (2002), Chon et al. (2004),Tristram et al. (2005), Rocha et al. (2009) and Planck 2015-XI (2015) among others.The HEALPix package contains the Fortran90 facility synfast, which takes as inputa power spectrum C` and generates a realisation of f(γp) on the HEALPix grid. Theconvention for power spectrum input into synfast is straightforward: each C` is just theexpected variance of the a`m at that `.

HEALPix 3.80

Page 13: The HEALPix Primer

A.2 HEALPix and Boltzmann codes 13

Example: The spherical harmonic coefficient a00 is the integral of thef(γ)/

√4π over the sphere. To obtain realisations of functions which have

a00 distributed as a Gaussian with zero mean and variance 1, set C0 to 1.The value of the synthesised function at each pixel will be Gaussian dis-tributed with mean zero and variance 1/(4π). As required, the integral off(γ) over the full 4π solid angle of the sphere has zero mean and variance4π.

Note that this definition implies the standard result that the total power at the angularwavenumber ` is (2`+ 1)C`, because there are 2`+ 1 modes for each `.This defines unambiguously how the C` have to be defined given the units of the physicalquantity f . In cosmic microwave background research, popular choices for simulated mapsare

• ∆T/T , a dimensionless quantity measuring relative fluctuations about the averageCMB temperature.

• The absolute quantity ∆T in µK or K.

A.2 HEALPix and Boltzmann codes

A.2.1 CMBFAST

A widely used solver of the Boltzmann equations for the computation of theoretical predic-tions of the spectrum of CMB anisotropy used to be CMBFAST (https://lambda.gsfc.nasa.gov/toolbox/tb_cmbfast_ov.cfm).CMBFAST made its outputs in ASCII files, which instead of CX,` contain quantities definedas

DX,` = `(`+ 1)(2π)T 2

CMB

CX,`, (8)

where TCMB = 2.726K is the temperature of the CMB today and X stands for T, E, B orC (see § A.3).The version 4.0 of CMBFAST also created a FITS file containing the power spectra CX,`,designed for interface with HEALPix. The spectra for polarization were renormalized tomatch the normalization used in HEALPix 1.1, which was different from the one used byCMBFAST and by HEALPix 1.2 (see § A.3.2 for details).A later version of CMBFAST (4.2, released in Feb. 2003) generated FITS files containingCX,`, with the same convention for polarization as the one used internally. It thereforematches the convention adopted by HEALPix in its version 1.2.For backward compatibility, we provide an IDL code (convert_oldhpx2cmbfast) to changethe normalization of existing FITS files created with CMBFAST 4.0. When created with

HEALPix 3.80

Page 14: The HEALPix Primer

14 The HEALPix Primer

the correct normalization (with CMBFAST 4.2) or set to the correct normalization (us-ing convert_oldhpx2cmbfast), the FITS file will include a specific keyword (POLNORM =CMBFAST) in their header to identify them. The map simulation code synfast will issuea warning if the input power spectrum file does not contain the keyword POLNORM, but noattempt will be made to renormalize the power spectrum. If the keyword is present, it willbe inherited by the simulated map.

A.2.2 CAMB and CLASS

Newer and actively maintained Boltzmann codes currently include camb and class:

• camb (https://camb.info) is written in Fortran 90 with a python wrapper, andcan optionally output into FITS files the CX(`) power spectra in [K]2 in a formatdirectly usable by HEALPix;

• class (http://class-code.net) is written in C and C++, and only outputs`(`+1)

2π CX(`) in plain text files (optionally in [µK]2 and in a order of columns forpolarized spectra matching the one of camb).

Both codes are parallelized for faster computations and provide fine control of the outputaccuracy.

A.3 Polarisation convention

A.3.1 Internal convention

Starting with version 1.20 (released in Feb 2003),HEALPix uses the same conventions asCMBFAST for the sign and normalization of the polarization power spectra, as exposedbelow (adapted from Zaldarriaga (1998)). How this relates to what was used in previousreleases is exposed in A.3.2.

The CMB radiation field is described by a 2× 2 intensity tensor Iij (Chandrasekhar 1960).The Stokes parameters Q and U are defined as Q = (I11 − I22)/4 and U = I12/2, while thetemperature anisotropy is given by T = (I11 + I22)/4. The fourth Stokes parameter V thatdescribes circular polarization is not necessary in standard cosmological models because itcannot be generated through the process of Thomson scattering. While the temperature is ascalar quantity Q and U are not. They depend on the direction of observation n and on thetwo axis (e1, e2) perpendicular to n used to define them. If for a given n the axes (e1, e2)are rotated by an angle ψ such that e1

′ = cosψ e1 + sinψ e2 and e2′ = − sinψ e1 + cosψ e2

the Stokes parameters change as

Q′ = cos 2ψ Q+ sin 2ψ U

U ′ = − sin 2ψ Q+ cos 2ψ U (9)

HEALPix 3.80

Page 15: The HEALPix Primer

A.3 Polarisation convention 15

Figure 4: Orthographic projection of a fake full sky for temperature (color coded) andpolarization (represented by the rods). All the input Spherical Harmonics coefficients areset to 0, except for aTEMP

21 = − aTEMP2−1 = 1 and aGRAD21 = − aGRAD2−1 = 1

To analyze the CMB temperature on the sky, it is natural to expand it in sphericalharmonics. These are not appropriate for polarization, because the two combinations Q ±iU are quantities of spin ±2 (Goldberg 1967). They should be expanded in spin-weightedharmonics ±2Y

ml (Zaldarriaga & Seljak 1997; Seljak & Zaldarriaga 1997),

T (n) =∑lm

aT,lmYlm(n)

(Q+ iU)(n) =∑lm

a2,lm 2Ylm(n)

(Q− iU)(n) =∑lm

a−2,lm −2Ylm(n). (10)

To perform this expansion, Q and U in equation (10) are measured relative to (e1, e2) =(eθ, eφ), the unit vectors of the spherical coordinate system. Where eθ is tangent to thelocal meridian and directed from North to South, and eφ is tangent to the local parallel, anddirected from West to East. The coefficients ±2alm are observable on the sky and their powerspectra can be predicted for different cosmological models. Instead of ±2alm it is convenientto use their linear combinations

aE,lm = −(a2,lm + a−2,lm)/2aB,lm = −(a2,lm − a−2,lm)/2i, (11)

which transform differently under parity. Four power spectra are needed to characterize

HEALPix 3.80

Page 16: The HEALPix Primer

16 The HEALPix Primer

fluctuations in a gaussian theory, the autocorrelation between T , E and B and the crosscorrelation of E and T . Because of parity considerations the cross-correlations between Band the other quantities vanish and one is left with

〈a∗X,lmaX,lm′〉 = δm,m′CXl,

〈a∗T,lmaE,lm〉 = δm,m′CCl, (12)

where X stands for T , E or B, 〈· · · 〉 means ensemble average and δi,j is the Kronecker delta.We can rewrite equation (10) as

T (n) =∑lm

aT,lmYlm(n)

Q(n) = −∑lm

aE,lmX1,lm + iaB,lmX2,lm

U(n) = −∑lm

aB,lmX1,lm − iaE,lmX2,lm (13)

where we have introduced X1,lm(n) = ( 2Ylm+ −2Ylm)/2 and X2,lm(n) = ( 2Ylm− −2Ylm)/2.They satisfy Y ∗lm = (−1)mYl−m, X∗1,lm = (−1)mX1,l−m and X∗2,lm = (−1)m+1X2,l−m whichtogether with aT,lm = (−1)ma∗T,l−m, aE,lm = (−1)ma∗E,l−m and aB,lm = (−1)ma∗B,l−m makeT , Q and U real.

In factX1,lm(n) andX2,lm(n) have the form, X1,lm(n) =√

(2l + 1)/4πF1,lm(θ) eimφ andX2,lm(n) =

√(2l + 1)/4πF2,lm(θ) eimφ, F(1,2),lm(θ) can be calculated in terms of Legendre

polynomials (Kamionkowski et al. 1997)

F1,lm(θ) = Nlm

[−(l −m2

sin2 θ+ 1

2 l(l − 1))Pml (cos θ) + (l +m) cos θ

sin2 θPml−1(cos θ)

]F2,lm(θ) = Nlm

m

sin2 θ[−(l − 1) cos θPml (cos θ) + (l +m)Pml−1(cos θ)], (14)

where

Nlm(θ) = 2

√(l − 2)!(l −m)!(l + 2)!(l +m)! . (15)

Note that F2,lm(θ) = 0 if m = 0, as it must to make the Stokes parameters real.The correlation functions between 2 points on the sky (noted 1 and 2) separated by

an angle β can be calculated using equations (12) and (13). However, as pointed out inKamionkowski et al. (1997), the natural coordinate system to express the correlations is onein which e1 vectors at each point are tangent to the great circle connecting these 2 points,with the e2 vectors being perpendicular to the e1 vectors. With this choice of referenceframes, and using the addition theorem for the spin harmonics (Hu & White 1997),

∑m

s1Y∗lm(n1) s2Ylm(n2) =

√2l + 1

4π s2Yl−s1(β, ψ1)e−is2ψ2 (16)

HEALPix 3.80

Page 17: The HEALPix Primer

A.3 Polarisation convention 17

we have (Kamionkowski et al. 1997)

〈T1T2〉 =∑l

2l + 14π CTlPl(cosβ)

〈Qr(1)Qr(2)〉 =∑l

2l + 14π [CElF1,l2(β)− CBlF2,l2(β)]

〈Ur(1)Ur(2)〉 =∑l

2l + 14π [CBlF1,l2(β)− CElF2,l2(β)]

〈T (1)Qr(2)〉 = −∑l

2l + 14π CClF1,l0(β)

〈T (1)Ur(2)〉 = 0. (17)

The subscript r here indicate that the Stokes parameters are measured in this particularcoordinate system. We can use the transformation laws in equation (9) to write (Q,U) interms of (Qr, Ur).

Using the fact that, when β → 0, P`(cos β) → 1 and P 2` (cos β) → sin2 β (`+2)!

8(`−2)! , the defi-nitions above imply that the variances of the temperature and polarization are related tothe power spectra by

〈TT 〉 =∑`

2`+ 14π CT`

〈QQ〉+ 〈UU〉 =∑l

2`+ 14π (CE` + CB`)

〈TQ〉 = 〈TU〉 = 0. (18)

It is also worth noting that with these conventions, the cross power CC` for scalar pertur-bations must be positive at low `, in order to produce at large scales a radial pattern ofpolarization around cold temperature spots (and a tangential pattern around hot spots)as it is expected from scalar perturbations (Crittenden et al. 1995).Note that Eq. (13) implies that, if the Stokes parameters are rotated everywhere via(

Q′

U ′

)=(

cos 2ψ sin 2ψ− sin 2ψ cos 2ψ

)(QU

), (19)

then the polarized a`m coefficients are submittted to the same rotation(a′E,`ma′B,`m

)=(

cos 2ψ sin 2ψ− sin 2ψ cos 2ψ

)(aE,`maB,`m

). (20)

Finally, with these conventions, a polarization with (Q > 0, U = 0) will be along theNorth–South axis, and (Q = 0, U > 0) will be along a North-West to South-East axis (seeFig. 5)

HEALPix 3.80

Page 18: The HEALPix Primer

18 The HEALPix Primer

A.3.2 Relation to previous releases

Even though it was stated otherwise in the documention, HEALPix used a differentconvention for the polarization in its previous releases. The tensor harmonics approach(Kamionkowski et al. (1997), hereafter KKS) was used, instead of the current spin weightedspherical harmonics. These two approaches differ by the normalisation and sign of thebasis functions used, which in turns change the normalisation of the power spectra. Table1 summarizes the relations between the CMB power spectra in the different releases. See§ A.2.1 about the interface between HEALPix and CMBFAST.Table 1: Relation between CMB power spectra conventions used in HEALPix, CMBFAST andKKS. The power spectra on the same row are equal.

Component HEALPix ≥ 1.2a CMBFAST KKS HEALPix ≤ 1.1b

Temperature CTEMP` CT,` CT

` CTEMP`

Electric orGradient

CGRAD` CE,` 2CG

` 2CGRAD`

Magnetic or Curl CCURL` CB,` 2CC

` 2CCURL`

Temp.-Electriccross correlation

CT−GRAD` CC,` −

√2 CTG

`

√2CT−GRAD

`

aVersion 1.2 (Feb 2003) or more recent of HEALPix packagebVersion 1.1 or older of HEALPix package

Introducing the matrices

M`m =(

X1,`m iX2,`m−iX2,`m X1,`m

)(21)

where the basis functions X1 and X2 have been defined in Eqs. (14) and above, the decom-position in spherical harmonics coefficients (13) of a given map of the Stokes parameter Qand U can be written in the case of HEALPix 1.2 as Q

U

=∑`m

M`m

−aGRAD`m

−aCURL`m

. (22)

For KKS, with the same definition of M , the decomposition reads Q

−U

=∑`m

M`m

2aE,`m√

2aB,`m

, (23)

whereas in HEALPix 1.1 it was Q

U

=∑`m

M`m

−√

2aGRAD`m

√2aCURL

`m

. (24)

HEALPix 3.80

Page 19: The HEALPix Primer

A.3 Polarisation convention 19

The difference between KKS and 1.1 was due to an error of sign on one the basis functions.

A.3.3 Relation with IAU convention

In a cartesian referential with axes x and y, the Stokes parameters for linear polarisationare defined such that +Q is aligned with +x, −Q with +y and +U with the bisectrix of+x and +y. Although this definition is universally accepted, some confusion may still arisefrom the relation of this local cartesian system to the global spherical one, as describedbelow (Hamaker & Leahy 2003), and as illustrated in Fig. 5.

Figure 5: Coordinate conventions for HEALPix (lhs panels) and IAU (rhs panels). Theupper panels illustrate how the spherical coordinates are measured, and the lower panelhow the Q and U Stokes parameters are identified in the tangential plan.

The polarization conventions defined by the International Astronomical Union (IAU 1974)

HEALPix 3.80

Page 20: The HEALPix Primer

20 The HEALPix Primer

are summarized in Hamaker & Bregman (1996). They define at each point on the celestialsphere a cartesian referential with the x and y axes pointing respectively toward the Northand East, and the z axis along the line of sight pointing toward the observer (ie, inwards)for a right-handed system.On the other hand, following the mathematical and CMB litterature tradition, HEALPixdefines a cartesian referential with the x and y axes pointing respectively toward theSouth and East, and the z axis along the line of sight pointing away from the observer (ie,outwards) for a right-handed system. The Planck CMBmission follows the same convention(Ansari et al. 2003).The consequence of this definition discrepency is a change of sign of U , which, if notaccounted for, jeopardizes the calculation of the Electric and Magnetic CMB polarisationpower spectra.

A.3.4 How HEALPix deals with these discrepancies: POLCCONV keyword

The FITS keyword POLCCONV has been introduced in HEALPix 2.0 to describe the polar-isation coordinate convention applied to the data contained in the file. Its value is either’COSMO’ for files following the HEALPix/CMB/Planck convention (default for sky mapsynthetized with HEALPix routine synfast) or ’IAU’ for those following the IAU conven-tion, as defined above. Absence of this keyword is interpreted as meaning ’COSMO’ (as itis the case for WMAP maps).Starting with HEALPix 3.40, when dealing with a polarized (full-sky or cut-sky) signalmap,– the F90 subroutine input_map in its default mode,– the F90 facilities calling it and dealing with the I, Q and U Stokes parameters as a whole,ie anafast and smoothing,– as well as their IDL wrappers ianafast and ismoothing,– the IDL visualisation routines azeqview, cartview, gnomview, mollview and orthviewcalled with Polarization=2 or 3,– and all C++ facilities (and the input routine read_Healpix_map_from_fits)will all– issue an error message and crash if POLCCONV is explicitely set to a value different from’COSMO’ and ’IAU’,– issue a warning (except in C++), and swap the sign of the U polarisation stored intomemory if the FITS file being read contains POLCCONV=’IAU’,– issue a warning (except in C++) if the keyword POLCCONV is totally absent, and thencarry on with the original data,– or work silently with the original data if POLCCONV=’COSMO’.On the other hand, and as in previous releases, routines treating or showing each of I, Qand U fields separately, such as the F90 facilities median_filter, ud_grade, or map2gifas well as their IDL counterparts median_filter, ud_grade, or mollview et al run withPolarization=0 or 1 will ignore the value of POLCCONV (copying it unchanged into their

HEALPix 3.80

Page 21: The HEALPix Primer

A.4 Spherical harmonic conventions 21

output files, when applicable) and preserve the sign of U .Finally, the IDL subroutine change_polcconv.pro and the Python facilitychange_polcconv.py are provided to add the POLCCONV keyword or change/updateits value and swap the sign of the U Stokes parameter, when applicable, in an existingFITS file.

A.4 Spherical harmonic conventions

The Spherical Harmonics are defined as

Y`m(θ, φ) = λ`m(cos θ)eimφ (25)

where

λ`m(x) =

√√√√2`+ 14π

(`−m)!(`+m)!P`m(x), for m ≥ 0 (26)

λ`m = (−1)mλ`|m|, for m < 0,λ`m = 0, for |m| > `.

Introducing x ≡ cos θ, the associated Legendre Polynomials P`m solve the differentialequation

(1− x2) d2

dx2P`m − 2x ddxP`m +

(`(`+ 1)− m2

1− x2

)P`m = 0. (27)

They are related to the ordinary Legendre Polynomials P` by

P`m = (−1)m(1− x2)m/2 dm

dxmP`(x), (28)

which are given by the Rodrigues formula

P`(x) = 12``!

d`

dx`(x2 − 1)`. (29)

Note that our Y`m are identical to those of Edmonds (1957), even though our definition ofthe P`m differ from his by a factor (−1)m (a.k.a. Condon-Shortley phase).

B Pixel window functions

A pixelated signal f(p) is the average within each pixel p (with surface area Ωpix) of theunderlying signal

f(p) =∫duwp(u)f(u) (30)

HEALPix 3.80

Page 22: The HEALPix Primer

22 The HEALPix Primer

where wp is equal to 1/Ωpix within the pixel, and equal to 0 outside, so that∫duwp(u) = 1.

Eq. (4) then becomes

f(p) =`max∑`=0

∑m

a`mw`m(p), (31)

wherew`m(p) =

∫duwp(u)Y`m(u), (32)

is the Spherical Harmonic Transform of the pixel p.However, complete analysis of a pixelated map with the exact w`m(p) defined above wouldbe computationally intractable (because of azimutal variation of pixel shape over the polarcaps of the HEALPix grid), and some simplifying asumptions have to be made. If thepixel is small compared to the signal correlation length (determined by the beam size), theexact structure of the pixel can be ignored in the subsequent analysis and we can assume

w`m(p) = w`(p)Y`m(p) (33)where we introduced the m-averaged window function

w`(p) = 4π

2`+ 1∑m=−`

|w`m(p)|21/2

, (34)

which is independent of the pixel location on the sky.If we assume all the pixels to be identical, the power spectrum of the pixelated map, Cpix

` ,is related to the hypothetical unpixelated one, Cunpix

` , byCpix` = w2

`Cunpix` (35)

where the effective pixel window function w` is defined as

w` = 1Npix

Npix−1∑p=0

w2` (p)

1/2

. (36)

This function is provided with the HEALPix package for ` ≤ 4Nside for each resolutionparameter Nside.The pixel window functions are now available for both temperature and polarization.For Nside ≤ 128, those window functions are computed exactly using Eqs. (34) and (36).For Nside > 128 the calculations are too costly to be done exactly at all `. The temperaturewindows are extrapolated from the case Nside = 128 assuming a scaling in ` similar to theone exhibited by the window of a tophat pixel. The polarization windows are assumed tobe proportional to those for temperature, with a proportionality factor given by the exactcalculation of w` at low `.Because of a change of the extrapolation scheme used, the temperature window functionsprovided with HEALPix 1.2 and higher for Nside > 128 are slighty different from thoseprovided with HEALPix 1.1. For a given Nside, the relative difference increases almostlinearly with `, and is of the order of ∆w/w < 7 10−4 at ` = 2Nside and ∆w/w < 1.7 10−3

at ` = 4Nside.

HEALPix 3.80

Page 23: The HEALPix Primer

A Comment on the Random Number Generator 23

C A Comment on the Random Number Generator

We provide a new random number generator (RNG) with this package, avail-able both in Fortran90 and C++. It resides in src/f90/mod/rngmod.f90 andsrc/cxx/cxxsupport/planck_rng.h and supersedes the previous RNG (which is stillavailable at src/f90/mod/ran_tools_dist.f90).It produces double precision real numbers x with x ∈]0, 1[ and is based on a xorshiftmethod described by Marsaglia in Journal of Statistical Software 2003, vol 8 (cf. https://www.cs.hku.hk/). It accepts up to four different seeds simultaneously, allowing eachsequence to have a theoretical period of 2128 − 1 ≈ 3.41038. A Gaussian deviate RNG isalso provided. See the respective routines documentation for details on their usage. Pleasenote that we have not extensively tested this generator — it did not represent the maindrive of this project.

D Finite precision and cross-platform reproducibility

Note that, due to finite precision of floating-point arithmetics and differences betweennumerical libraries, the result of HEALPix functions like ang2pix (which converts theangular coordinates of a point into the index of the pixel to which it belongs) may depend onthe underlying hardware, compilers, compiler options and linked libraries, if the requestedposition is very close to (roughly 10−15 radians or less) a pixel border. The result willalways be one of the (two to four) adjacent pixels, and we are confident that it is strictlyreproducible within the same binary on the same hardware platform, but if one of thecomponents is changed, the result may change as well. This may be surprising whentesting apparently "simple" locations like the poles.This issue is not specific to HEALPix, but shared by any library performing nontrivialfloating-point operations, and in particular any pixelisation library or facility (on anymanifold, at any number of dimensions and for any practical pixelisation scheme), in thevicinity of pixel boundaries.

HEALPix 3.80

Page 24: The HEALPix Primer

24 The HEALPix Primer

ReferencesAnsari, R., et al, 2003, Planck parameter definition document (DRAFT 2003-10-23), Tech-

nical Report PL-COM-IAS-SD-L2.02.005, ESA. 20

Baumgardner, J.R. and Frederickson, P.O., 1985, SIAM J. Numerical Analysis, Vol. 22,No. 6, p. 1107 6

Boch, T., Donaldson, T., Durand, D., et al. 2014, “MOC-HEALPix Multi-Order Coveragemap”, http://ivoa.net/documents/MOC/ 9

Chandrasekhar, S. 1960, in Radiative Transfer (Dover: New York) 14

Chon, G., Challinor, A., Prunet, S., Hivon, E. & Szapudi, I., 2004, MNRAS, 350, 914.PolSpice code available at http://www2.iap.fr/users/hivon/software/PolSpice/12

Crittenden, R.G., Coulson, D. & Turok, N.G., 1995, Phys.Rev. D52, 5402 17

Crittenden, R. and Turok, N.G., 1998, astro-ph/9806374 6

Doroshkevich, A.G., Naselsky, P.D., Verkhodanov, O.V., Novikov, D.I., Turchaninov, V.I.,Novikov, I.D., Christensen, P.R. & Chiang, L.-Y., 2005, IJMPD, 14, 2, 275, astro-ph/0305537 6

Driscoll, J.R. and Healy, D., 1994, Adv. in Appl. Math., Vol. 15, p.202 6

Edmonds, A.R., 1957, Angular Momentum in Quantum Mechanics, Princeton UniversityPress 21

Goldberg, J. N., et al. 1967, J. Math. Phys. 8, 2155 15

Górski, K.M., Hivon, E., Banday, A. J., Wandelt, B. D., Hansen, F. K., Reinecke, M. &Bartelmann, M., 2005, ApJ, 622, 759, astro-ph/0409513 6, 7

Hamaker, J.P. & Bregman, J.D., 1996, A&AS 117, 161 20

Hamaker, J.P. & Leahy, J.P., 2003, “A study of CMB differencing polarimetry with partic-ular reference to Planck”, ESA Report SCI-A/2003.312/jt 19

Hivon, E., Górski, K, M., Netterfield, C. B., Crill, B. P., Prunet, S. & Hansen, F., 2002,ApJ, 567, 2, astro-ph/0105302 12

Hu, W. & White, M., 1997, NewA, 2, 323 16

IAU, 1974, Transactions of the IAU Vol. 15B (1973) 166 19

Kamionkowski, M., Kosowsky, A., Stebbins, A., 1997, Ph.Rev. D, 55, 7368 (KKS) 16, 17,18

HEALPix 3.80

Page 25: The HEALPix Primer

REFERENCES 25

Mucaccia, P.F, Natoli, P. and Vittorio, N., 1998, ApJ, 488, L63 6

Planck Collaboration, 2015-XI, arXiv:1507.02704v1 12

Reinecke, M. and Hivon, E., 2015, A&A, 580, A132, arXiv:1505.04632v2 9

Rocha, G., Contaldi, C.R., Bond, J.R. & Górski, K.M., 2009, arXiv:0912.4059v2 12

Saff, E.B. and Kuijlaars, A.B.J., 1997, The Mathematical Intelligencer, 19, #1, p.5 6

Seljak, U. & Zaldarriaga, M., Phys. Rev. Lett. 78, 2054 (1997). 15

Szalay, A.S. and Brunner, R.J., 1998, astro-ph/9812335, to appear in a special issue of theElsevier journal "Future Generation Computer Systems" 6

Tegmark, M., 1996, ApJ, 470, L81 6

Tristram, M., Macias-Perez, J.F., Renault, C., & Santos, D., 2005, MNRAS, 358, 833 12

Wandelt, B.D., Hivon, E. and Górski, K.M., 1998, astro-ph/9803317, in "FundamentalParameters in Cosmology", proceedings of the XXXIIIrd Rencontres de Moriond, TrânThanh Vân (ed.) 9

Wandelt, B.D., Hivon, E. and Górski, K.M., 2001, Phys. Rev. D, 64, 083003, astro-ph/9808292v1 12

Zaldarriaga, M., 1998, ApJ, 503, 1 14

Zaldarriaga, M. & Seljak, U., Phys. Rev. D 55 1830 (1997) 15

HEALPix 3.80