Healpy 1.9.0
Healpy 1.9.0
Release 1.9.0
Contents
Tutorial
1.1 Healpy tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1
Installation
2.1 Installation procedure for Healpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
7
Reference
3.1 pixelfunc Pixelisation related functions
3.2 sphtfunc Spherical harmonic transforms
3.3 visufunc Visualisation . . . . . . . . .
3.4 fitsfunc FITS file related functions . .
3.5 rotator Rotation and geometry functions
3.6 projector Spherical projections . . . .
3.7 projaxes Axes for projection . . . . . .
3.8 zoomtool Interactive visualisation . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
11
. 11
. 30
. 40
. 50
. 55
. 61
. 76
. 107
109
ii
CHAPTER 1
Tutorial
%matplotlib
%matplotlib
%matplotlib
%matplotlib
inline
qt
osx
gtk
#
#
#
#
The resolution of the map is defined by the NSIDE parameter. The nside2npix() function gives the number of
pixel NPIX of the map:
>>>
>>>
>>>
>>>
>>>
import numpy as np
import healpy as hp
NSIDE = 32
m = np.arange(hp.nside2npix(NSIDE))
hp.mollview(m, title="Mollview image RING")
Healpix supports two different ordering schemes, RING or NESTED. By default, healpy maps are in RING ordering.
In order to work with NESTED ordering, all map related functions support the nest keyword, for example:
>>> hp.mollview(m, nest=True, title="Mollview image NESTED")
Chapter 1. Tutorial
By default, input maps are converted to RING ordering, if they are in NESTED ordering. You can otherwise specify
nest=True to retrieve a map is NESTED ordering, or nest=None to keep the ordering unchanged.
By default, read_map() loads the first column, for reading other columns you can specify the field keyword.
write_map() writes a map to disk in FITS format, if the input map is a list of 3 maps, they are written to a single
file as I,Q,U polarization components:
>>> hp.write_map("my_map.fits", wmap_map_I)
1.1.3 Visualization
Mollweide projection with mollview() is the most common visualization tool for HEALPIX maps. It also supports
coordinate transformation:
coord does galactic to ecliptic coordinate transformation, norm=hist sets a histogram equalized color scale and xsize
increases the size of the image. graticule() adds meridians and parallels.
shows a projection of the galactic center, xsize and ysize change the dimension of the sky patch.
mollzoom() is a powerful tool for interactive inspection of a map, it provides a mollweide projection where you
can click to set the center of the adjacent gnomview panel.
By convention the mask is 0 where the data are masked, while numpy defines data masked when the mask is True, so
it is necessary to flip the mask.
>>> hp.mollview(wmap_map_I_masked.filled())
filling a masked array fills in the UNSEEN value and return a standard array that can be used by mollview. compressed()
instead removes all the masked pixels and returns a standard array that can be used for examples by the matplotlib
4
Chapter 1. Tutorial
hist() function:
>>> import matplotlib.pyplot as plt
>>> plt.hist(wmap_map_I_masked.compressed(), bins = 1000)
plt.figure()
plt.plot(ell, ell * (ell+1) * cl)
plt.xlabel('ell'); plt.ylabel('ell(ell+1)cl'); plt.grid()
hp.write_cl('cl.fits', cl)
Chapter 1. Tutorial
CHAPTER 2
Installation
If you have installed with pip, you can keep your installation up to date by upgrading from time to time:
pip install --user --upgrade healpy
Binary apt-get style packages are also available in the development versions of Debian (sid) and Ubuntu (utopic).
2.1.7 Clean
When you run python setup.py, temporary build products are placed in the build directory. If you want to clean
out and remove the build directory, then run:
Chapter 2. Installation
10
Chapter 2. Installation
CHAPTER 3
Reference
healpy.pixelfunc.pix2ang
healpy.pixelfunc.pix2ang(nside, ipix, nest=False)
pix2ang : nside,ipix,nest=False -> theta[rad],phi[rad] (default RING)
Parameters nside : int or array-like
The healpix nside parameter, must be a power of 2, less than 2**30
ipix : int or array-like
Pixel indices
nest : bool, optional
if True, assume NESTED pixel ordering, otherwise, RING pixel ordering
Returns theta, phi : float, scalar or array-like
The angular coordinates corresponding to ipix. Scalar if all input are scalar, array otherwise. Usual numpy broadcasting rules apply.
See also:
ang2pix, vec2pix, pix2vec
11
Examples
>>> import healpy as hp
>>> hp.pix2ang(16, 1440)
(1.5291175943723188, 0.0)
>>> hp.pix2ang(16, [1440, 427, 1520,
0, 3068])
(array([ 1.52911759, 0.78550497, 1.57079633, 0.05103658,
>>> hp.pix2ang([1, 2, 4, 8], 11)
(array([ 2.30052398, 0.84106867,
0.41113786,
3.09055608]), array([ 0.
5.89048623,
healpy.pixelfunc.pix2vec
healpy.pixelfunc.pix2vec(nside, ipix, nest=False)
pix2vec : nside,ipix,nest=False -> x,y,z (default RING)
Parameters nside : int, scalar or array-like
The healpix nside parameter, must be a power of 2, less than 2**30
ipix : int, scalar or array-like
Healpix pixel number
nest : bool, optional
if True, assume NESTED pixel ordering, otherwise, RING pixel ordering
Returns x, y, z : floats, scalar or array-like
The coordinates of vector corresponding to input pixels. Scalar if all input are scalar,
array otherwise. Usual numpy broadcasting rules apply.
See also:
ang2pix, pix2ang, vec2pix
Examples
>>> import healpy as hp
>>> hp.pix2vec(16, 1504)
(0.99879545620517241, 0.049067674327418015, 0.0)
>>> hp.pix2vec(16, [1440, 427])
(array([ 0.99913157, 0.5000534 ]), array([ 0.
healpy.pixelfunc.ang2pix
healpy.pixelfunc.ang2pix(nside, theta, phi, nest=False)
ang2pix : nside,theta[rad],phi[rad],nest=False -> ipix (default:RING)
Parameters nside : int, scalar or array-like
The healpix nside parameter, must be a power of 2, less than 2**30
12
Chapter 3. Reference
0.7070
0.66
healpy.pixelfunc.vec2pix
healpy.pixelfunc.vec2pix(nside, x, y, z, nest=False)
vec2pix : nside,x,y,z,nest=False -> ipix (default:RING)
Parameters nside : int or array-like
The healpix nside parameter, must be a power of 2, less than 2**30
x,y,z : floats or array-like
vector coordinates defining point on the sphere
nest : bool, optional
if True, assume NESTED pixel ordering, otherwise, RING pixel ordering
Returns ipix : int, scalar or array-like
The healpix pixel number corresponding to input vector. Scalar if all input are scalar,
array otherwise. Usual numpy broadcasting rules apply.
See also:
ang2pix, pix2ang, pix2vec
13
Examples
>>> import healpy as hp
>>> hp.vec2pix(16, 1, 0, 0)
1504
>>> hp.vec2pix(16, [1, 0], [0, 1], [0, 0])
array([1504, 1520])
>>> hp.vec2pix([1, 2, 4, 8], 1, 0, 0)
array([ 4, 20, 88, 368])
healpy.pixelfunc.vec2ang
healpy.pixelfunc.vec2ang(vectors)
vec2ang: vectors [x, y, z] -> theta[rad], phi[rad]
Parameters vectors : float, array-like
the vector(s) to convert, shape is (3,) or (N, 3)
Returns theta, phi : float, tuple of two arrays
the colatitude and longitude in radians
See also:
ang2vec, rotator.vec2dir, rotator.dir2vec
healpy.pixelfunc.ang2vec
healpy.pixelfunc.ang2vec(theta, phi)
ang2vec : convert angles to 3D position vector
Parameters theta : float, scalar or arry-like
colatitude in radians measured southward from north pole (in [0,pi]).
phi : float, scalar or array-like
longitude in radians measured eastward (in [0, 2*pi]).
Returns vec : float, array
if theta and phi are vectors, the result is a 2D array with a vector per row otherwise, it is
a 1D array of shape (3,)
See also:
vec2ang, rotator.dir2vec, rotator.vec2dir
healpy.pixelfunc.get_neighbours
healpy.pixelfunc.get_neighbours(nside, theta, phi=None, nest=False)
14
Chapter 3. Reference
healpy.pixelfunc.get_all_neighbours
healpy.pixelfunc.get_all_neighbours(nside, theta, phi=None, nest=False)
Return the 8 nearest pixels.
Parameters nside : int
the nside to work with
theta, phi : scalar or array-like
if phi is not given or None, theta is interpreted as pixel number, otherwise,
theta[rad],phi[rad] are angular coordinates
nest : bool
if True, pixel number will be NESTED ordering, otherwise RING ordering.
Returns ipix : int, array
pixel number of the SW, W, NW, N, NE, E, SE and S neighbours, shape is (8,) if input
is scalar, otherwise shape is (8, N) if input is of length N. If a neighbor does not exist (it
can be the case for W, N, E and S) the corresponding pixel number will be -1.
See also:
get_interp_weights, get_interp_val
Examples
>>> import healpy as hp
>>> hp.get_all_neighbours(1, 4)
array([11, 7, 3, -1, 0, 5, 8, -1])
>>> hp.get_all_neighbours(1, np.pi/2, np.pi/2)
array([ 8, 4, 0, -1, 1, 6, 9, -1])
healpy.pixelfunc.nest2ring
healpy.pixelfunc.nest2ring(nside, ipix)
Convert pixel number from NESTED ordering to RING ordering.
Parameters nside : int, scalar or array-like
the healpix nside parameter
ipix : int, scalar or array-like
the pixel number in NESTED scheme
Returns ipix : int, scalar or array-like
the pixel number in RING scheme
3.1. pixelfunc Pixelisation related functions
15
See also:
ring2nest, reorder
Examples
>>> import healpy as hp
>>> hp.nest2ring(16, 1130)
1504
>>> hp.nest2ring(2, np.arange(10))
array([13, 5, 4, 0, 15, 7, 6,
1, 17,
9])
healpy.pixelfunc.ring2nest
healpy.pixelfunc.ring2nest(nside, ipix)
Convert pixel number from RING ordering to NESTED ordering.
Parameters nside : int, scalar or array-like
the healpix nside parameter
ipix : int, scalar or array-like
the pixel number in RING scheme
Returns ipix : int, scalar or array-like
the pixel number in NESTED scheme
See also:
nest2ring, reorder
Examples
>>> import healpy as hp
>>> hp.ring2nest(16, 1504)
1130
>>> hp.ring2nest(2, np.arange(10))
array([ 3, 7, 11, 15, 2, 1, 6,
5, 10,
9])
healpy.pixelfunc.reorder
healpy.pixelfunc.reorder(map_in, *args, **kwds)
Reorder an healpix map from RING/NESTED ordering to NESTED/RING
Parameters map_in : array-like
the input map to reorder, accepts masked arrays
16
Chapter 3. Reference
11.],
3.1.3 nside/npix/resolution
17
nside2npix(nside)
npix2nside(npix)
nside2order(nside)
order2nside(order)
nside2resol(nside[, arcmin])
nside2pixarea(nside[, degrees])
max_pixrad(nside)
isnsideok(nside)
isnpixok(npix)
get_map_size(m)
get_min_valid_nside(npix)
get_nside(m)
maptype(m)
ud_grade(map_in, *args, **kwds)
healpy.pixelfunc.nside2npix
healpy.pixelfunc.nside2npix(nside)
Give the number of pixels for the given nside.
Parameters nside : int
healpix nside parameter; an exception is raised if nside is not valid (nside must be a
power of 2, less than 2**30)
Returns npix : int
corresponding number of pixels
Notes
healpy.pixelfunc.npix2nside
healpy.pixelfunc.npix2nside(npix)
Give the nside parameter for the given number of pixels.
18
Chapter 3. Reference
Raise a ValueError exception if number of pixel does not correspond to the number of pixel of an healpix map.
Examples
>>> import healpy as hp
>>> hp.npix2nside(768)
8
>>> np.all([hp.npix2nside(12 * nside**2) == nside for nside in [2**n for n in range(12)]])
True
>>> hp.npix2nside(1000)
Traceback (most recent call last):
...
ValueError: Wrong pixel number (it is not 12*nside**2)
healpy.pixelfunc.nside2order
healpy.pixelfunc.nside2order(nside)
Give the resolution order for a given nside.
Parameters nside : int
healpix nside parameter; an exception is raised if nside is not valid (nside must be a
power of 2, less than 2**30)
Returns order : int
corresponding order where nside = 2**(order)
Notes
19
>>> hp.nside2order(7)
Traceback (most recent call last):
...
ValueError: 7 is not a valid nside parameter (must be a power of 2, less than 2**30)
healpy.pixelfunc.order2nside
healpy.pixelfunc.order2nside(order)
Give the nside parameter for the given resolution order.
Parameters order : int
the resolution order
Returns nside : int
the nside parameter corresponding to order
Notes
64, 128])
>>> hp.order2nside(31)
Traceback (most recent call last):
...
ValueError: 2147483648 is not a valid nside parameter (must be a power of 2, less than 2**30)
healpy.pixelfunc.nside2resol
healpy.pixelfunc.nside2resol(nside, arcmin=False)
Give approximate resolution (pixel size in radian or arcmin) for nside.
Resolution is just the square root of the pixel area, which is a gross approximation given the different pixel
shapes
Parameters nside : int
healpix nside parameter, must be a power of 2, less than 2**30
arcmin : bool
if True, return resolution in arcmin, otherwise in radian
Returns resol : float
approximate pixel size in radians or arcmin
20
Chapter 3. Reference
Notes
healpy.pixelfunc.nside2pixarea
healpy.pixelfunc.nside2pixarea(nside, degrees=False)
Give pixel area given nside in square radians or square degrees.
Parameters nside : int
healpix nside parameter, must be a power of 2, less than 2**30
degrees : bool
if True, returns pixel area in square degrees, in square radians otherwise
Returns pixarea : float
pixel area in square radian or square degree
Notes
21
healpy.pixelfunc.max_pixrad
healpy.pixelfunc.max_pixrad(nside)
Maximum angular distance between any pixel center and its corners
Parameters nside : int
the nside to work with
Returns rads: double
angular distance (in radians)
Examples
>>> '%.15f' % max_pixrad(1)
'0.841068670567930'
>>> '%.15f' % max_pixrad(16)
'0.066014761432513'
healpy.pixelfunc.isnsideok
healpy.pixelfunc.isnsideok(nside)
Returns True if nside is a valid nside parameter, False otherwise.
Parameters nside : int, scalar or array-like
integer value to be tested
Returns ok : bool, scalar or array-like
True if given value is a valid nside, False otherwise.
Examples
>>> import healpy as hp
>>> hp.isnsideok(13)
False
>>> hp.isnsideok(32)
True
>>> hp.isnsideok([1, 2, 3, 4, 8, 16])
array([ True, True, False, True, True,
True], dtype=bool)
healpy.pixelfunc.isnpixok
healpy.pixelfunc.isnpixok(npix)
Return True if npix is a valid value for healpix map size, False otherwise.
Parameters npix : int, scalar or array-like
integer value to be tested
Returns ok : bool, scalar or array-like
True if given value is a valid number of pixel, False otherwise
22
Chapter 3. Reference
Examples
>>> import healpy as hp
>>> hp.isnpixok(12)
True
>>> hp.isnpixok(768)
True
>>> hp.isnpixok([12, 768, 1002])
array([ True, True, False], dtype=bool)
healpy.pixelfunc.get_map_size
healpy.pixelfunc.get_map_size(m)
Returns the npix of a given map (implicit or explicit pixelization).
If map is a dict type, assumes explicit pixelization: use nside key if present, or use nside attribute
if present, otherwise use the smallest valid npix given the maximum key value. otherwise assumes
implicit pixelization and returns len(m).
Parameters m : array-like or dict-like
a map with implicit (array-like) or explicit (dict-like) pixellization
Returns npix : int
a valid number of pixel
Notes
In implicit pixellization, raise a ValueError exception if the size of the input is not a valid pixel number.
Examples
>>> import healpy as hp
>>> m = {0: 1, 1: 1, 2: 1, 'nside': 1}
>>> print(hp.get_map_size(m))
12
>>> m = {0: 1, 767: 1}
>>> print(hp.get_map_size(m))
768
>>> print(hp.get_map_size(np.zeros(12 * 8 ** 2)))
768
healpy.pixelfunc.get_min_valid_nside
healpy.pixelfunc.get_min_valid_nside(npix)
Returns the minimum acceptable nside so that npix <= nside2npix(nside).
Parameters npix : int
23
healpy.pixelfunc.get_nside
healpy.pixelfunc.get_nside(m)
Return the nside of the given map.
Parameters m : sequence
the map to get the nside from.
Returns nside : int
the healpix nside parameter of the map (or sequence of maps)
Notes
If the input is a sequence of maps, all of them must have same size. If the input is not a valid map (not a
sequence, unvalid number of pixels), a TypeError exception is raised.
healpy.pixelfunc.maptype
healpy.pixelfunc.maptype(m)
Describe the type of the map (valid, single, sequence of maps). Checks : the number of maps, that all maps have
same length and that this length is a valid map size (using isnpixok()).
Parameters m : sequence
the map to get info from
Returns info : int
-1 if the given object is not a valid map, 0 if it is a single map, info > 0 if it is a sequence
of maps (info is then the number of maps)
Examples
>>> import healpy as hp
>>> hp.pixelfunc.maptype(np.arange(12))
0
>>> hp.pixelfunc.maptype([np.arange(12), np.arange(12)])
2
24
Chapter 3. Reference
healpy.pixelfunc.ud_grade
healpy.pixelfunc.ud_grade(map_in, *args, **kwds)
Upgrade or degrade resolution of a map (or list of maps).
in degrading the resolution, ud_grade sets the value of the superpixel as the mean of the children pixels.
Parameters map_in : array-like or sequence of array-like
the input map(s) (if a sequence of maps, all must have same size)
nside_out : int
the desired nside of the output map(s)
pess : bool
if True, in degrading, reject pixels which contains a bad sub_pixel. Otherwise, estimate
average with good pixels
order_in, order_out : str
pixel ordering of input and output (RING or NESTED)
power : float
if non-zero, divide the result by (nside_in/nside_out)**power Examples: power=-2
keeps the sum of the map invariant (useful for hitmaps), power=2 divides the mean
by another factor of (nside_in/nside_out)**2 (useful for variance maps)
dtype : type
the type of the output map
Returns map_out : array-like or sequence of array-like
the upgraded or degraded map(s)
Examples
>>> import healpy as hp
>>> hp.ud_grade(np.arange(48.), 1)
array([ 5.5 ,
7.25,
9. , 10.75, 21.75,
36.5 , 38.25, 40. , 41.75])
21.75,
23.75,
25.75,
healpy.pixelfunc.UNSEEN
healpy.pixelfunc.UNSEEN = -1.6375e+30
Special value used for masked pixels
25
healpy.pixelfunc.mask_bad
healpy.pixelfunc.mask_bad(m, badval=-1.6375e+30, rtol=1e-05, atol=1e-08)
Returns a bool array with True where m is close to badval.
Parameters m : a map (may be a sequence of maps)
badval : float, optional
The value of the pixel considered as bad (UNSEEN by default)
rtol : float, optional
The relative tolerance
atol : float, optional
The absolute tolerance
Returns mask
a bool array with the same shape as the input map, True where input map is close to
badval, and False elsewhere.
See also:
mask_good, ma
Examples
>>> import healpy as hp
>>> import numpy as np
>>> m = np.arange(12.)
>>> m[3] = hp.UNSEEN
>>> hp.mask_bad(m)
array([False, False, False, True, False, False, False, False, False,
False, False, False], dtype=bool)
healpy.pixelfunc.mask_good
healpy.pixelfunc.mask_good(m, badval=-1.6375e+30, rtol=1e-05, atol=1e-08)
Returns a bool array with False where m is close to badval.
Parameters m : a map (may be a sequence of maps)
badval : float, optional
The value of the pixel considered as bad (UNSEEN by default)
rtol : float, optional
The relative tolerance
atol : float, optional
The absolute tolerance
Returns a bool array with the same shape as the input map, False where input map is
close to badval, and True elsewhere.
See also:
mask_bad, ma
26
Chapter 3. Reference
Examples
>>> import healpy as hp
>>> m = np.arange(12.)
>>> m[3] = hp.UNSEEN
>>> hp.mask_good(m)
array([ True, True, True, False, True,
True, True, True], dtype=bool)
True,
True,
True,
True,
healpy.pixelfunc.ma
healpy.pixelfunc.ma(m, badval=-1.6375e+30, rtol=1e-05, atol=1e-08, copy=True)
Return map as a masked array, with badval pixels masked.
Parameters m : a map (may be a sequence of maps)
badval : float, optional
The value of the pixel considered as bad (UNSEEN by default)
rtol : float, optional
The relative tolerance
atol : float, optional
The absolute tolerance
copy : bool, optional
If True, a copy of the input map is made.
Returns a masked array with the same shape as the input map,
masked where input map is close to badval.
See also:
mask_good, mask_bad, numpy.ma.masked_values
Examples
>>> import healpy as hp
>>> m = np.arange(12.)
>>> m[3] = hp.UNSEEN
>>> hp.ma(m)
masked_array(data = [0.0 1.0 2.0 -- 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0],
mask = [False False False True False False False False False False False False],
fill_value = -1.6375e+30)
27
28
Chapter 3. Reference
healpy.pixelfunc.remove_dipole
healpy.pixelfunc.remove_dipole(m, nest=False, bad=-1.6375e+30, gal_cut=0, fitval=False,
copy=True, verbose=True)
Fit and subtract the dipole and the monopole from the given map m.
Parameters m : float, array-like
the map to which a dipole is fitted and subtracted, accepts masked arrays
nest : bool
if False m is assumed in RING scheme, otherwise map is NESTED
bad : float
bad values of pixel, default to UNSEEN .
gal_cut : float
pixels at latitude in [-gal_cut;+gal_cut] are not taken into account
fitval : bool
whether to return or not the fitted values of monopole and dipole
copy : bool
whether to modify input map or not (by default, make a copy)
verbose : bool
print values of monopole and dipole
Returns res : array or tuple of length 3
if fitval is False, returns map with monopole and dipole subtracted, otherwise, returns
map (array, in res[0]), monopole (float, in res[1]), dipole_vector (array, in res[2])
See also:
fit_dipole, fit_monopole, remove_monopole
healpy.pixelfunc.remove_monopole
healpy.pixelfunc.remove_monopole(m, nest=False, bad=-1.6375e+30, gal_cut=0, fitval=False,
copy=True, verbose=True)
Fit and subtract the monopole from the given map m.
Parameters m : float, array-like
the map to which a monopole is fitted and subtracted
nest : bool
if False m is assumed in RING scheme, otherwise map is NESTED
bad : float
bad values of pixel, default to UNSEEN .
gal_cut : float
pixels at latitude in [-gal_cut;+gal_cut] are not taken into account
fitval : bool
whether to return or not the fitted value of monopole
3.1. pixelfunc Pixelisation related functions
29
copy : bool
whether to modify input map or not (by default, make a copy)
verbose: bool
whether to print values of monopole
Returns res : array or tuple of length 3
if fitval is False, returns map with monopole subtracted, otherwise, returns map (array,
in res[0]) and monopole (float, in res[1])
See also:
fit_dipole, fit_monopole, remove_dipole
healpy.pixelfunc.get_interp_val
healpy.pixelfunc.get_interp_val(m, theta, phi, nest=False)
Return the bi-linear interpolation value of a map using 4 nearest neighbours.
Parameters m : array-like
an healpix map, accepts masked arrays
theta, phi : float, scalar or array-like
angular coordinates of point at which to interpolate the map
nest : bool
if True, the is assumed to be in NESTED ordering.
Returns val : float, scalar or arry-like
the interpolated value(s), usual numpy broadcasting rules apply.
See also:
get_interp_weights, get_all_neighbours
Examples
>>> import healpy as hp
>>> hp.get_interp_val(np.arange(12.),
4.0
>>> hp.get_interp_val(np.arange(12.),
5.0
>>> hp.get_interp_val(np.arange(12.),
5.0
>>> hp.get_interp_val(np.arange(12.),
array([ 1.5
, 1.5
, 1.5
5.31546486, 7.94639458, 9.5
np.pi/2, 0)
np.pi/2, np.pi/2)
np.pi/2, np.pi/2 + 2*np.pi)
np.linspace(0, np.pi, 10), 0)
, 2.20618428, 3.40206143,
, 9.5
, 9.5
])
30
Chapter 3. Reference
healpy.sphtfunc.anafast
healpy.sphtfunc.anafast(map1, map2=None, nspec=None, lmax=None, mmax=None, iter=3,
alm=False, pol=True, use_weights=False, datapath=None)
Computes the power spectrum of an Healpix map, or the cross-spectrum between two maps if map2 is given.
No removal of monopole or dipole is performed.
Parameters map1 : float, array-like shape (Npix,) or (3, Npix)
Either an array representing a map, or a sequence of 3 arrays representing I, Q, U maps
map2 : float, array-like shape (Npix,) or (3, Npix)
Either an array representing a map, or a sequence of 3 arrays representing I, Q, U maps
nspec : None or int, optional
The number of spectra to return. If None, returns all, otherwise returns cls[:nspec]
lmax : int, scalar, optional
Maximum l of the power spectrum (default: 3*nside-1)
mmax : int, scalar, optional
Maximum m of the alm (default: lmax)
iter : int, scalar, optional
Number of iteration (default: 3)
alm : bool, scalar, optional
If True, returns both cl and alm, otherwise only cl is returned
pol : bool, optional
If True, assumes input maps are TQU. Output will be TEB cls and correlations (input
must be 1 or 3 maps). If False, maps are assumed to be described by spin 0 spherical
harmonics. (input can be any number of maps) If there is only one input map, it has no
effect. Default: True.
datapath : None or str, optional
If given, the directory where to find the weights data.
Returns res : array or sequence of arrays
If alm is False, returns cl or a list of cls (TT, EE, BB, TE, EB, TB for polarized input
map) Otherwise, returns a tuple (cl, alm), where cl is as above and alm is the spherical
harmonic transform or a list of almT, almE, almB for polarized input
healpy.sphtfunc.map2alm
healpy.sphtfunc.map2alm(maps, lmax=None, mmax=None, iter=3, pol=True, use_weights=False,
datapath=None)
Computes the alm of an Healpix map.
Parameters maps : array-like, shape (Npix,) or (n, Npix)
31
The pixels which have the special UNSEEN value are replaced by zeros before spherical harmonic transform.
They are converted back to UNSEEN value, so that the input maps are not modified. Each map have its own,
independent mask.
healpy.sphtfunc.synfast
healpy.sphtfunc.synfast(cls, nside, lmax=None, mmax=None, alm=False, pol=True, pixwin=False,
fwhm=0.0, sigma=None, new=False, verbose=True)
Create a map(s) from cl(s).
Parameters cls : array or tuple of array
A cl or a list of cl (either 4 or 6, see synalm())
nside : int, scalar
The nside of the output map(s)
lmax : int, scalar, optional
Maximum l for alm. Default: min of 3*nside-1 or length of the cls - 1
32
Chapter 3. Reference
The order of the spectra will change in a future release. The new= parameter help to make the transition
smoother. You can start using the new order by setting new=True. In the next version of healpy, the default will
be new=True. This change is done for consistency between the different tools (alm2cl, synfast, anafast). In the
new order, the spectra are ordered by diagonal of the correlation matrix. Eg, if fields are T, E, B, the spectra are
TT, EE, BB, TE, EB, TB with new=True, and TT, TE, TB, EE, EB, BB if new=False.
healpy.sphtfunc.alm2map
healpy.sphtfunc.alm2map(alms, nside, lmax=None, mmax=None, pixwin=False,
sigma=None, pol=True, inplace=False, verbose=True)
Computes an Healpix map given the alm.
fwhm=0.0,
The alm are given as a complex array. You can specify lmax and mmax, or they will be computed from array
size (assuming lmax==mmax).
Parameters alms : complex, array or sequence of arrays
A complex array or a sequence of complex arrays. Each array must have a size of the
form: mmax * (2 * lmax + 1 - mmax) / 2 + lmax + 1
nside : int, scalar
The nside of the output map.
lmax : None or int, scalar, optional
Explicitly define lmax (needed if mmax!=lmax)
mmax : None or int, scalar, optional
3.2. sphtfunc Spherical harmonic transforms
33
34
Chapter 3. Reference
35
healpy.sphtfunc.smoothalm
healpy.sphtfunc.smoothalm(alms, fwhm=0.0, sigma=None, pol=True, mmax=None, verbose=True,
inplace=True)
Smooth alm with a Gaussian symmetric beam function.
Parameters alms : array or sequence of 3 arrays
Either an array representing one alm, or a sequence of arrays. See pol parameter.
fwhm : float, optional
The full width half max parameter of the Gaussian. Default:0.0 [in radians]
sigma : float, optional
The sigma of the Gaussian. Override fwhm. [in radians]
pol : bool, optional
If True, assumes input alms are TEB. Output will be TQU maps. (input must be 1 or 3
alms) If False, apply spin 0 harmonic transform to each alm. (input can be any number
of alms) If there is only one input alm, it has no effect. Default: True.
mmax : None or int, optional
The maximum m for alm. Default: mmax=lmax
inplace : bool, optional
If True, the alms are modified inplace if they are contiguous arrays of type complex128.
Otherwise, a copy of alm is made. Default: True.
verbose : bool, optional
If True prints diagnostic information. Default: True
Returns alms : array or sequence of 3 arrays
The smoothed alm. If alm[i] is a contiguous array of type complex128, and inplace is
True the smoothing is applied inplace. Otherwise, a copy is made.
healpy.sphtfunc.alm2cl
healpy.sphtfunc.alm2cl(alms1, alms2=None, lmax=None, mmax=None, lmax_out=None,
nspec=None)
Computes (cross-)spectra from alm(s). If alm2 is given, cross-spectra between alm and alm2 are computed. If
alm (and alm2 if provided) contains n alm, then n(n+1)/2 auto and cross-spectra are returned.
Parameters alm : complex, array or sequence of arrays
The alm from which to compute the power spectrum. If n>=2 arrays are given, computes
both auto- and cross-spectra.
alms2 : complex, array or sequence of 3 arrays, optional
If provided, computes cross-spectra between alm and alm2. Default: alm2=alm, so
auto-spectra are computed.
lmax : None or int, optional
The maximum l of the input alm. Default: computed from size of alm and mmax_in
mmax : None or int, optional
The maximum m of the input alm. Default: assume mmax_in = lmax_in
36
Chapter 3. Reference
The order of the spectra will change in a future release. The new= parameter help to make the transition
smoother. You can start using the new order by setting new=True. In the next version of healpy, the default will
be new=True. This change is done for consistency between the different tools (alm2cl, synfast, anafast). In the
new order, the spectra are ordered by diagonal of the correlation matrix. Eg, if fields are T, E, B, the spectra are
TT, EE, BB, TE, EB, TB with new=True, and TT, TE, TB, EE, EB, BB if new=False.
healpy.sphtfunc.almxfl
healpy.sphtfunc.almxfl(alm, fl, mmax=None, inplace=False)
Multiply alm by a function of l. The function is assumed to be zero where not defined.
Parameters alm : array
37
getlm(lmax[, i])
getidx(lmax, l, m)
getsize(lmax[, mmax])
getlmax(s[, mmax])
healpy.sphtfunc.Alm.getlm
38
Chapter 3. Reference
The index for which to compute the l and m. If None, the function return l and m for
i=0..Alm.getsize(lmax)
healpy.sphtfunc.Alm.getidx
static Alm.getidx(lmax, l, m)
Returns index corresponding to (l,m) in an array describing alm up to lmax.
Parameters lmax : int
The maximum l, defines the alm layout
l : int
The l for which to get the index
m : int
The m for which to get the index
Returns idx : int
The index corresponding to (l,m)
healpy.sphtfunc.Alm.getsize
39
healpy.sphtfunc.gauss_beam
healpy.sphtfunc.gauss_beam(fwhm, lmax=512, pol=False)
Gaussian beam window function
Computes the spherical transform of an axisimmetric gaussian beam
For a sky of underlying power spectrum C(l) observed with beam of given FWHM, the measured power spectrum
will be C(l)_meas = C(l) B(l)^2 where B(l) is given by gaussbeam(Fwhm,Lmax). The polarization beam is
also provided (when pol = True ) assuming a perfectly co-polarized beam (e.g., Challinor et al 2000, astroph/0008228)
Parameters fwhm : float
full width half max in radians
lmax : integer
ell max
pol : bool
if False, output has size (lmax+1) and is temperature beam if True output has size
(lmax+1, 4) with components: * temperature beam * grad/electric polarization beam
* curl/magnetic polarization beam * temperature * grad beam
Returns beam : array
beam window function [0, lmax] if dim not specified otherwise (lmax+1, 4) contains
polarized beam
healpy.visufunc.mollview
healpy.visufunc.mollview(map=None, fig=None, rot=None, coord=None, unit=, xsize=800, title=Mollweide view, nest=False, min=None, max=None, flip=astro,
remove_dip=False, remove_mono=False, gal_cut=0, format=%g,
format2=%g, cbar=True, cmap=None, notext=False, norm=None,
hold=False, margins=None, sub=None, return_projected_map=False)
Plot an healpix map (given as an array) in Mollweide projection.
Parameters map : float, array-like or None
An array containing the map, supports masked maps, see the ma function. If None, will
display a blank map, useful for overplotting.
40
Chapter 3. Reference
41
Chapter 3. Reference
43
See also:
mollview, cartview, orthview
healpy.visufunc.cartview
healpy.visufunc.cartview(map=None, fig=None, rot=None, zat=None, coord=None, unit=,
xsize=800, ysize=None, lonra=None, latra=None, title=Cartesian
view, nest=False, remove_dip=False, remove_mono=False, gal_cut=0,
min=None, max=None, flip=astro, format=%.3g, cbar=True,
cmap=None, norm=None, aspect=None, hold=False, sub=None,
margins=None, notext=False, return_projected_map=False)
Plot an healpix map (given as an array) in Cartesian projection.
Parameters map : float, array-like or None
An array containing the map, supports masked maps, see the ma function. If None, will
display a blank map, useful for overplotting.
fig : int or None, optional
The figure number to use. Default: create a new figure
rot : scalar or sequence, optional
Describe the rotation to apply. In the form (lon, lat, psi) (unit: degrees) : the point at
longitude lon and latitude lat will be at the center. An additional rotation of angle psi
around this direction is applied.
coord : sequence of character, optional
Either one of G, E or C to describe the coordinate system of the map, or a sequence
of 2 of these to rotate the map from the first to the second coordinate system.
unit : str, optional
A text describing the unit of the data. Default:
xsize : int, optional
The size of the image. Default: 800
lonra : sequence, optional
Range in longitude. Default: [-180,180]
latra : sequence, optional
Range in latitude. Default: [-90,90]
title : str, optional
The title of the plot. Default: Mollweide view
nest : bool, optional
If True, ordering scheme is NESTED. Default: False (RING)
min : float, optional
The minimum range value
max : float, optional
The maximum range value
44
Chapter 3. Reference
45
healpy.visufunc.orthview
healpy.visufunc.orthview(map=None, fig=None, rot=None, coord=None, unit=, xsize=800,
half_sky=False, title=Orthographic view, nest=False, min=None,
max=None, flip=astro, remove_dip=False, remove_mono=False,
gal_cut=0, format=%g, format2=%g, cbar=True, cmap=None,
notext=False, norm=None, hold=False, margins=None, sub=None,
return_projected_map=False)
Plot an healpix map (given as an array) in Orthographic projection.
Parameters map : float, array-like or None
An array containing the map. If None, will display a blank map, useful for overplotting.
fig : int or None, optional
The figure number to use. Default: create a new figure
rot : scalar or sequence, optional
Describe the rotation to apply. In the form (lon, lat, psi) (unit: degrees) : the point at
longitude lon and latitude lat will be at the center. An additional rotation of angle psi
around this direction is applied.
coord : sequence of character, optional
Either one of G, E or C to describe the coordinate system of the map, or a sequence
of 2 of these to rotate the map from the first to the second coordinate system.
half_sky : bool, optional
Plot only one side of the sphere. Default: False
unit : str, optional
A text describing the unit of the data. Default:
xsize : int, optional
The size of the image. Default: 800
title : str, optional
The title of the plot. Default: Orthographic view
nest : bool, optional
If True, ordering scheme is NESTED. Default: False (RING)
min : float, optional
The minimum range value
max : float, optional
The maximum range value
flip : {astro, geo}, optional
Defines the convention of projection : astro (default, east towards left, west towards
right) or geo (east towards roght, west towards left)
remove_dip : bool, optional
If True, remove the dipole+monopole
remove_mono : bool, optional
46
Chapter 3. Reference
3.3.2 Graticules
graticule([dpar, dmer, coord, local])
delgraticules()
healpy.visufunc.graticule
healpy.visufunc.graticule(dpar=None, dmer=None, coord=None, local=None, **kwds)
Draw a graticule on the current Axes.
Parameters dpar, dmer : float, scalars
Interval in degrees between meridians and between parallels
3.3. visufunc Visualisation
47
coord : {E, G, C}
The coordinate system of the graticule (make rotation if needed, using coordinate system of the map if it is defined).
local : bool
If True, draw a local graticule (no rotation is performed, useful for a gnomonic view,
for example)
See also:
delgraticules
Notes
healpy.visufunc.projplot
healpy.visufunc.projplot(*args, **kwds)
projplot is a wrapper around matplotlib.Axes.plot() to take into account the spherical projection.
You can call this function as:
projplot(theta, phi)
projplot(theta, phi, 'bo')
projplot(thetaphi)
projplot(thetaphi, 'bx')
#
#
#
#
plot
plot
plot
idem
48
Chapter 3. Reference
If True, theta and phi are interpreted as longitude and latitude in degree, otherwise, as
colatitude and longitude in radian
coord : {E, G, C, None}
The coordinate system of the points, only used if the coordinate coordinate system of
the Axes has been defined and in this case, a rotation is performed
rot : None or sequence
rotation to be applied =(lon, lat, psi) : lon, lat will be position of the new Z axis, and psi
is rotation around this axis, all in degree. if None, no rotation is performed
direct : bool
if True, the rotation to center the projection is not taken into account
See also:
projscatter, projtext
Notes
49
See also:
projplot, projtext
Notes
50
Chapter 3. Reference
healpy.fitsfunc.read_map
healpy.fitsfunc.read_map(filename, field=0, dtype=<type numpy.float64>, nest=False, partial=False, hdu=1, h=False, verbose=True, memmap=False)
Read an healpix map from a fits file. Partial-sky files, if properly identified, are expanded to full size and filled
with UNSEEN.
Parameters filename : str or HDU or HDUList
the fits file name
field : int or tuple of int, or None, optional
The column to read. Default: 0. By convention 0 is temperature, 1 is Q, 2 is U. Field
can be a tuple to read multiple columns (0,1,2) If the fits file is a partial-sky file, field=0
corresponds to the first column after the pixel index column. If None, all columns are
read in.
dtype : data type, optional
Force the conversion to some type. Default: np.float64
nest : bool, optional
If True return the map in NEST ordering, otherwise in RING ordering; use fits keyword
ORDERING to decide whether conversion is needed or not If None, no conversion is
performed.
partial : bool, optional
If True, fits file is assumed to be a partial-sky file with explicit indexing, if the indexing scheme cannot be determined from the header. If False, implicit indexing is
assumed. Default: False. A partial sky file is one in which OBJECT=PARTIAL and
INDXSCHM=EXPLICIT, and the first column is then assumed to contain pixel indices.
A full sky file is one in which OBJECT=FULLSKY and INDXSCHM=IMPLICIT. At
least one of these keywords must be set for the indexing scheme to be properly identified.
hdu : int, optional
the header number to look at (start at 0)
h : bool, optional
If True, return also the header. Default: False.
verbose : bool, optional
If True, print a number of diagnostic messages
memmap : bool, optional
Argument passed to astropy.io.fits.open, if True, the map is not read into memory, but
only the required pixels are read when needed. Default: False.
Returns m | (m0, m1, ...) [, header] : array or a tuple of arrays, optionally with header appended
The map(s) read from the file, and the header if h is True.
51
healpy.fitsfunc.write_map
healpy.fitsfunc.write_map(filename,
m,
nest=False,
dtype=<type
numpy.float32>,
fits_IDL=True, coord=None, partial=False, column_names=None,
column_units=None, extra_header=())
Writes an healpix map into an healpix file.
Parameters filename : str
the fits file name
m : array or sequence of 3 arrays
the map to write. Possibly a sequence of 3 maps of same size. They will be considered
as I, Q, U maps. Supports masked maps, see the ma function.
nest : bool, optional
If True, ordering scheme is assumed to be NESTED, otherwise, RING. Default: RING.
The map ordering is not modified by this function, the input map array should already
be in the desired ordering (run ud_grade beforehand).
fits_IDL : bool, optional
If True, reshapes columns in rows of 1024, otherwise all the data will go in one column.
Default: True
coord : str
The coordinate system, typically E for Ecliptic, G for Galactic or C for Celestial
(equatorial)
partial : bool, optional
If True, fits file is written as a partial-sky file with explicit indexing. Otherwise, implicit
indexing is used. Default: False.
column_names : str or list
Column name or list of column names, if None we use: I_STOKES for 1 component,
I/Q/U_STOKES for 3 components, II, IQ, IU, QQ, QU, UU for 6 components, COLUMN_0, COLUMN_1... otherwise
column_units : str or list
Units for each column, or same units for all columns.
extra_header : list
Extra records to add to FITS header.
healpy.fitsfunc.read_alm
healpy.fitsfunc.read_alm(filename, hdu=1, return_mmax=False)
Read alm from a fits file.
52
Chapter 3. Reference
In the fits file, the alm are written with explicit index scheme, index = l**2+l+m+1, while healpix cxx uses index
= m*(2*lmax+1-m)/2+l. The conversion is done in this function.
Parameters filename : str or HDUList or HDU
The name of the fits file to read
hdu : int, optional
The header to read. Start at 0. Default: hdu=1
return_mmax : bool, optional
If true, both the alms and mmax is returned in a tuple. Default: return_mmax=False
Returns alms[, mmax] : complex array or tuple of a complex array and an int
The alms read from the file and optionally mmax read from the file
healpy.fitsfunc.write_alm
healpy.fitsfunc.write_alm(filename, alms, out_dtype=None, lmax=-1, mmax=-1, mmax_in=-1)
Write alms to a fits file.
In the fits file the alms are written with explicit index scheme, index = l*l + l + m +1, possibly out of order. By
default write_alm makes a table with the same precision as the alms. If specified, the lmax and mmax parameters
truncate the input data to include only alms for which l <= lmax and m <= mmax.
Parameters filename : str
The filename of the output fits file
alms : array, complex or list of arrays
A complex ndarray holding the alms, index = m*(2*lmax+1-m)/2+l, see Alm.getidx
lmax : int, optional
The maximum l in the output file
mmax : int, optional
The maximum m in the output file
out_dtype : data type, optional
data type in the output file (must be a numpy dtype). Default: alms.real.dtype
mmax_in : int, optional
maximum m in the input array
3.4.3 Reading/writing cl
read_cl(filename[, dtype, h])
write_cl(filename, cl[, dtype])
healpy.fitsfunc.read_cl
healpy.fitsfunc.read_cl(filename, dtype=<type numpy.float64>, h=False)
Reads Cl from an healpix file, as IDL fits2cl.
53
healpy.fitsfunc.mrdfits
healpy.fitsfunc.mrdfits(filename, hdu=1)
Read a table in a fits file.
Parameters filename : str or HDUList or HDU
The name of the fits file to read, or an HDUList or HDU instance.
hdu : int, optional
The header to read. Start at 0. Default: hdu=1
Returns cols : a list of arrays
A list of column data in the given header
healpy.fitsfunc.mwrfits
healpy.fitsfunc.mwrfits(filename, data, hdu=1, colnames=None, keys=None)
Write columns to a fits file in a table extension.
Parameters filename : str
The fits file name
data : list of 1D arrays
A list of 1D arrays to write in the table
54
Chapter 3. Reference
3.4.5 Helper
getformat(t)
healpy.fitsfunc.getformat
healpy.fitsfunc.getformat(t)
Get the FITS convention format string of data type t.
Parameters t : data type
The data type for which the FITS type is requested
Returns fits_type : str or None
The FITS string code describing the data type, or None if unknown type.
healpy.rotator.Rotator
class healpy.rotator.Rotator(rot=None, coord=None, inv=None, deg=True, eulertype=ZYX)
Rotation operator, including astronomical coordinate systems.
This class provides tools for spherical rotations. It is meant to be used in the healpy library for plotting, and for
this reason reflects the convention used in the Healpix IDL library.
Parameters rot : None or sequence
Describe the rotation by its euler angle. See euler_matrix_new().
coord : None or sequence of str
Describe the coordinate system transform. If rot is also given, the coordinate transform
is applied first, and then the rotation.
inv : bool
55
Attributes
mat
coordin
coordout
coordinstr
coordoutstr
rots
coords
healpy.rotator.Rotator.mat
Rotator.mat
The matrix representing the rotation.
healpy.rotator.Rotator.coordin
Rotator.coordin
The input coordinate system.
56
Chapter 3. Reference
healpy.rotator.Rotator.coordout
Rotator.coordout
The output coordinate system.
healpy.rotator.Rotator.coordinstr
Rotator.coordinstr
The input coordinate system in str.
healpy.rotator.Rotator.coordoutstr
Rotator.coordoutstr
The output coordinate system in str.
healpy.rotator.Rotator.rots
Rotator.rots
The sequence of rots defining the rotation.
healpy.rotator.Rotator.coords
Rotator.coords
The sequence of coords defining the rotation.
Methods
I(*args, **kwds)
__call__(*args, **kwds)
angle_ref(*args, **kwds)
do_rot(i)
get_inverse()
healpy.rotator.Rotator.I
Rotator.I(*args, **kwds)
Rotate the given vector or direction using the inverse matrix. rot.I(vec) <==> rot(vec,inv=True)
healpy.rotator.Rotator.__call__
Rotator.__call__(*args, **kwds)
Use the rotator to rotate either spherical coordinates (theta, phi) or a vector (x,y,z). You can use lonla keyword to use longitude, latitude (in degree) instead of theta, phi (in radian). In this case, returns longitude,
latitude in degree.
Accepted forms:
57
r(x,y,z) # x,y,z either scalars or arrays r(theta,phi) # theta, phi scalars or arrays r(lon,lat,lonlat=True) # lon,
lat scalars or arrays r(vec) # vec 1-D array with 3 elements, or 2-D array 3xN r(direction) # direction 1-D
array with 2 elements, or 2xN array
Parameters vec_or_dir : array or multiple arrays
The direction to rotate. See above for accepted formats.
lonlat : bool, optional
If True, assumes the input direction is longitude/latitude in degrees. Otherwise, assumes
co-latitude/longitude in radians. Default: False
inv : bool, optional
If True, applies the inverse rotation. Default: False.
healpy.rotator.Rotator.angle_ref
Rotator.angle_ref(*args, **kwds)
Compute the angle between transverse reference direction of initial and final frames
For example, if angle of polarisation is psi in initial frame, it will be psi+angle_ref in final frame.
Parameters dir_or_vec : array
Direction or vector (see Rotator.__call__)
lonlat: bool, optional
If True, assume input is longitude,latitude in degrees. Otherwise, theta,phi in radian.
Default: False
inv : bool, optional
If True, use the inverse transforms. Default: False
Returns angle : float, scalar or array
Angle in radian (a scalar or an array if input is a sequence of direction/vector)
healpy.rotator.Rotator.do_rot
Rotator.do_rot(i)
Returns True if rotation is not (close to) identity.
healpy.rotator.Rotator.get_inverse
Rotator.get_inverse()
healpy.rotator.rotateVector
healpy.rotator.rotateVector(rotmat, vec, vy=None, vz=None, do_rot=True)
Rotate a vector (or a list of vectors) using the rotation matrix given as first argument.
Parameters rotmat : float, array-like shape (3,3)
The rotation matrix
vec : float, scalar or array-like
58
Chapter 3. Reference
The vector to transform (shape (3,) or (3,N)), or x component (scalar or shape (N,)) if
vy and vz are given
vy : float, scalar or array-like, optional
The y component of the vector (scalar or shape (N,))
vz : float, scalar or array-like, optional
The z component of the vector (scalar or shape (N,))
do_rot : bool, optional
if True, really perform the operation, if False do nothing.
Returns vec : float, array
The component of the rotated vector(s).
See also:
Rotator
healpy.rotator.rotateDirection
healpy.rotator.rotateDirection(rotmat, theta, phi=None, do_rot=True, lonlat=False)
Rotate the vector described by angles theta,phi using the rotation matrix given as first argument.
Parameters rotmat : float, array-like shape (3,3)
The rotation matrix
theta : float, scalar or array-like
The angle theta (scalar or shape (N,)) or both angles (scalar or shape (2, N)) if phi is not
given.
phi : float, scalar or array-like, optionnal
The angle phi (scalar or shape (N,)).
do_rot : bool, optional
if True, really perform the operation, if False do nothing.
lonlat : bool
If True, input angles are assumed to be longitude and latitude in degree, otherwise, they
are co-latitude and longitude in radians.
Returns angles : float, array
The angles of describing the rotated vector(s).
See also:
Rotator
59
healpy.rotator.vec2dir
healpy.rotator.vec2dir(vec, vy=None, vz=None, lonlat=False)
Transform a vector to angle given by theta,phi.
Parameters vec : float, scalar or array-like
The vector to transform (shape (3,) or (3,N)), or x component (scalar or shape (N,)) if
vy and vz are given
vy : float, scalar or array-like, optional
The y component of the vector (scalar or shape (N,))
vz : float, scalar or array-like, optional
The z component of the vector (scalar or shape (N,))
lonlat : bool, optional
If True, return angles will be longitude and latitude in degree, otherwise, angles will be
longitude and co-latitude in radians (default)
Returns angles : float, array
The angles (unit depending on lonlat) in an array of shape (2,) (if scalar input) or (2, N)
See also:
dir2vec(), pixelfunc.ang2vec(), pixelfunc.vec2ang()
healpy.rotator.dir2vec
healpy.rotator.dir2vec(theta, phi=None, lonlat=False)
Transform a direction theta,phi to a unit vector.
Parameters theta : float, scalar or array-like
The angle theta (scalar or shape (N,)) or both angles (scalar or shape (2, N)) if phi is not
given.
phi : float, scalar or array-like, optionnal
The angle phi (scalar or shape (N,)).
lonlat : bool
If True, input angles are assumed to be longitude and latitude in degree, otherwise, they
are co-latitude and longitude in radians.
Returns vec : array
The vector(s) corresponding to given angles, shape is (3,) or (3, N).
See also:
vec2dir(), pixelfunc.ang2vec(), pixelfunc.vec2ang()
healpy.rotator.angdist
healpy.rotator.angdist(dir1, dir2, lonlat=False)
Returns the angular distance between dir1 and dir2.
Parameters dir1, dir2 : float, array-like
60
Chapter 3. Reference
The directions between which computing the angular distance. Angular if len(dir) == 2
or vector if len(dir) == 3. See lonlat for unit
lonlat : bool, scalar or sequence
If True, angles are assumed to be longitude and latitude in degree, otherwise they are
interpreted as colatitude and longitude in radian. If a sequence, lonlat[0] applies to dir1
and lonlat[1] applies to dir2.
Returns angles : float, scalar or array-like
The angle(s) between dir1 and dir2 in radian.
Examples
>>> import healpy as hp
>>> hp.rotator.angdist([.2,0], [.2, 1e-6])
array([ 1.98669331e-07])
healpy.projector.SphericalProj
class healpy.projector.SphericalProj(rot=None, coord=None, flipconv=None, **kwds)
This class defines functions for spherical projection.
This class contains class method for spherical projection computation. It should not be instantiated. It should
be inherited from and methods should be overloaded for desired projection.
Attributes
arrayinfo
healpy.projector.SphericalProj.arrayinfo
SphericalProj.arrayinfo
Dictionary with information on the projection array
Methods
61
healpy.projector.SphericalProj.ang2xy
SphericalProj.get_center(lonlat=False)
Get the center of the projection.
Input:
lonlat [if True, will return longitude and latitude in degree,] otherwise, theta and phi in radian
Return:
theta,phi or lonlat depending on lonlat keyword
healpy.projector.SphericalProj.get_extent
SphericalProj.get_extent()
Get the extension of the projection plane.
Return: extent = (left,right,bottom,top)
62
Chapter 3. Reference
healpy.projector.SphericalProj.get_fov
SphericalProj.get_fov()
Get the field of view in degree of the plane of projection
Return: fov: the diameter in radian of the field of view
healpy.projector.SphericalProj.get_proj_plane_info
SphericalProj.get_proj_plane_info()
healpy.projector.SphericalProj.ij2xy
SphericalProj.ij2xy(i=None, j=None)
From image array indices to position in projection plane (%s).
Input:
if i and j are None, generate arrays of i and j as input
i : if j is None, i[0], j[1] define array indices in %s image.
j : if defined, i,j define array indices in image.
projinfo : additional projection information.
Return:
x,y : position in projection plane.
healpy.projector.SphericalProj.mkcoord
SphericalProj.mkcoord(coord)
healpy.projector.SphericalProj.projmap
63
healpy.projector.SphericalProj.set_flip
SphericalProj.set_flip(flipconv)
flipconv is either astro or geo. None will be default.
With astro, east is toward left and west toward right. It is the opposite for geo
healpy.projector.SphericalProj.set_proj_plane_info
SphericalProj.set_proj_plane_info(**kwds)
healpy.projector.SphericalProj.vec2xy
SphericalProj.xy2ij(x, y=None)
From position in the projection plane to image array index (%s).
Input:
x : if y is None, x[0], x[1] define the position in %s plane.
y : if defined, x,y define the position in projection plane.
64
Chapter 3. Reference
xsize=None,
ysize=None,
Attributes
arrayinfo
healpy.projector.GnomonicProj.arrayinfo
GnomonicProj.arrayinfo
Dictionary with information on the projection array
Methods
65
healpy.projector.GnomonicProj.ang2xy
GnomonicProj.get_center(lonlat=False)
Get the center of the projection.
Input:
lonlat [if True, will return longitude and latitude in degree,] otherwise, theta and phi in radian
Return:
theta,phi or lonlat depending on lonlat keyword
healpy.projector.GnomonicProj.get_extent
GnomonicProj.get_extent()
healpy.projector.GnomonicProj.get_fov
GnomonicProj.get_fov()
healpy.projector.GnomonicProj.get_proj_plane_info
GnomonicProj.get_proj_plane_info()
66
Chapter 3. Reference
healpy.projector.GnomonicProj.ij2xy
GnomonicProj.ij2xy(i=None, j=None)
From image array indices to position in projection plane (Gnomonic).
Input:
if i and j are None, generate arrays of i and j as input
i : if j is None, i[0], j[1] define array indices in Gnomonic image.
j : if defined, i,j define array indices in image.
projinfo : additional projection information.
Return:
x,y : position in projection plane.
healpy.projector.GnomonicProj.mkcoord
GnomonicProj.mkcoord(coord)
healpy.projector.GnomonicProj.projmap
GnomonicProj.set_flip(flipconv)
flipconv is either astro or geo. None will be default.
With astro, east is toward left and west toward right. It is the opposite for geo
healpy.projector.GnomonicProj.set_proj_plane_info
67
healpy.projector.GnomonicProj.vec2xy
GnomonicProj.xy2ij(x, y=None)
From position in the projection plane to image array index (Gnomonic).
Input:
x : if y is None, x[0], x[1] define the position in Gnomonic plane.
y : if defined, x,y define the position in projection plane.
projinfo : additional projection information.
Return:
i,j : image array indices.
healpy.projector.GnomonicProj.xy2vec
68
Chapter 3. Reference
arrayinfo
healpy.projector.MollweideProj.arrayinfo
MollweideProj.arrayinfo
Dictionary with information on the projection array
Methods
healpy.projector.MollweideProj.ang2xy
69
MollweideProj.get_center(lonlat=False)
Get the center of the projection.
Input:
lonlat [if True, will return longitude and latitude in degree,] otherwise, theta and phi in radian
Return:
theta,phi or lonlat depending on lonlat keyword
healpy.projector.MollweideProj.get_extent
MollweideProj.get_extent()
healpy.projector.MollweideProj.get_fov
MollweideProj.get_fov()
Get the field of view in degree of the plane of projection
Return: fov: the diameter in radian of the field of view
healpy.projector.MollweideProj.get_proj_plane_info
MollweideProj.get_proj_plane_info()
healpy.projector.MollweideProj.ij2xy
MollweideProj.ij2xy(i=None, j=None)
From image array indices to position in projection plane (Mollweide).
Input:
if i and j are None, generate arrays of i and j as input
i : if j is None, i[0], j[1] define array indices in Mollweide image.
j : if defined, i,j define array indices in image.
projinfo : additional projection information.
Return:
x,y : position in projection plane.
70
Chapter 3. Reference
healpy.projector.MollweideProj.mkcoord
MollweideProj.mkcoord(coord)
healpy.projector.MollweideProj.projmap
MollweideProj.set_flip(flipconv)
flipconv is either astro or geo. None will be default.
With astro, east is toward left and west toward right. It is the opposite for geo
healpy.projector.MollweideProj.set_proj_plane_info
MollweideProj.set_proj_plane_info(xsize)
healpy.projector.MollweideProj.vec2xy
71
healpy.projector.MollweideProj.xy2ang
MollweideProj.xy2ij(x, y=None)
From position in the projection plane to image array index (Mollweide).
Input:
x : if y is None, x[0], x[1] define the position in Mollweide plane.
y : if defined, x,y define the position in projection plane.
projinfo : additional projection information.
Return:
i,j : image array indices.
healpy.projector.MollweideProj.xy2vec
72
ysize=None,
Chapter 3. Reference
Attributes
arrayinfo
healpy.projector.CartesianProj.arrayinfo
CartesianProj.arrayinfo
Dictionary with information on the projection array
Methods
healpy.projector.CartesianProj.ang2xy
CartesianProj.get_center(lonlat=False)
Get the center of the projection.
Input:
lonlat [if True, will return longitude and latitude in degree,] otherwise, theta and phi in radian
3.6. projector Spherical projections
73
Return:
theta,phi or lonlat depending on lonlat keyword
healpy.projector.CartesianProj.get_extent
CartesianProj.get_extent()
Get the extension of the projection plane.
Return: extent = (left,right,bottom,top)
healpy.projector.CartesianProj.get_fov
CartesianProj.get_fov()
healpy.projector.CartesianProj.get_proj_plane_info
CartesianProj.get_proj_plane_info()
healpy.projector.CartesianProj.ij2xy
CartesianProj.ij2xy(i=None, j=None)
From image array indices to position in projection plane (Cartesian).
Input:
if i and j are None, generate arrays of i and j as input
i : if j is None, i[0], j[1] define array indices in Cartesian image.
j : if defined, i,j define array indices in image.
projinfo : additional projection information.
Return:
x,y : position in projection plane.
healpy.projector.CartesianProj.mkcoord
CartesianProj.mkcoord(coord)
healpy.projector.CartesianProj.projmap
Chapter 3. Reference
CartesianProj.set_flip(flipconv)
flipconv is either astro or geo. None will be default.
With astro, east is toward left and west toward right. It is the opposite for geo
healpy.projector.CartesianProj.set_proj_plane_info
75
healpy.projector.CartesianProj.xy2ij
CartesianProj.xy2ij(x, y=None)
From position in the projection plane to image array index (Cartesian).
Input:
x : if y is None, x[0], x[1] define the position in Cartesian plane.
y : if defined, x,y define the position in projection plane.
projinfo : additional projection information.
Return:
i,j : image array indices.
healpy.projector.CartesianProj.xy2vec
MollweideAxes(*args, **kwds)
HpxMollweideAxes(*args, **kwds)
CartesianAxes(*args, **kwds)
HpxCartesianAxes(*args, **kwds)
Methods
Methods
Methods
healpy.projaxes.SphericalProjAxes
class healpy.projaxes.SphericalProjAxes(ProjClass, *args, **kwds)
Define a special Axes to take care of spherical projection.
Parameters projection : a SphericalProj class or a class derived from it.
76
Chapter 3. Reference
type of projection
rot : list or string
define rotation. See rotator.
coord : list or string
define coordinate system. See rotator.
coordprec : number of digit after floating point for coordinates display.
format : format string for value display.
Notes
delgraticules()
format_coord(x, y)
get_lonlat(x, y)
get_meridian_interval(vx[, vy, vz])
get_parallel_interval(vx[, vy, vz])
get_value(x, y)
graticule([dpar, dmer, coord, local, verbose])
projmap(map, vec2pix_func[, vmin, vmax, ...])
projplot(*args, **kwds)
projscatter(theta[, phi])
projtext(theta, phi, s, **kwds)
set_coordprec(n)
set_format(f)
healpy.projaxes.SphericalProjAxes.delgraticules
SphericalProjAxes.delgraticules()
Delete all graticules previously created on the Axes.
healpy.projaxes.SphericalProjAxes.format_coord
SphericalProjAxes.format_coord(x, y)
Format the coordinate for display in status bar. Take projection into account.
healpy.projaxes.SphericalProjAxes.get_lonlat
SphericalProjAxes.get_lonlat(x, y)
Get the coordinate in the coord system of the image, in lon/lat in deg.
77
healpy.projaxes.SphericalProjAxes.get_meridian_interval
SphericalProjAxes.get_value(x, y)
Get the value of the map at position x,y
healpy.projaxes.SphericalProjAxes.graticule
78
Chapter 3. Reference
SphericalProjAxes.projplot(*args, **kwds)
projplot is a wrapper around matplotlib.Axes.plot() to take into account the spherical projection.
You can call this function as:
projplot(theta, phi)
projplot(theta, phi, 'bo')
projplot(thetaphi)
projplot(thetaphi, 'bx')
#
#
#
#
plot
plot
plot
idem
79
The coordinate system of the points, only used if the coordinate coordinate system of
the Axes has been defined and in this case, a rotation is performed
rot : None or sequence
rotation to be applied =(lon, lat, psi) : lon, lat will be position of the new Z axis, and psi
is rotation around this axis, all in degree. if None, no rotation is performed
direct : bool
if True, the rotation to center the projection is not taken into account
See also:
projscatter, projtext
Notes
80
Chapter 3. Reference
Notes
SphericalProjAxes.set_coordprec(n)
Set the number of digits after floating point for coord display.
healpy.projaxes.SphericalProjAxes.set_format
SphericalProjAxes.set_format(f )
Set the format string for value display
81
healpy.projaxes.GnomonicAxes
class healpy.projaxes.GnomonicAxes(*args, **kwds)
Define a gnomonic Axes to handle gnomonic projection.
Input:
rot=, coord= : define rotation and coordinate system. See rotator.
coordprec= : number of digit after floating point for coordinates display.
format= : format string for value display.
Other keywords from Axes (see Axes).
Methods
delgraticules()
format_coord(x, y)
get_lonlat(x, y)
get_meridian_interval(vx[, vy, vz])
get_parallel_interval(vx[, vy, vz])
get_value(x, y)
graticule([dpar, dmer, coord, local, verbose])
projmap(map, vec2pix_func[, xsize, ysize, reso])
projplot(*args, **kwds)
projscatter(theta[, phi])
projtext(theta, phi, s, **kwds)
set_coordprec(n)
set_format(f)
healpy.projaxes.GnomonicAxes.delgraticules
GnomonicAxes.delgraticules()
Delete all graticules previously created on the Axes.
healpy.projaxes.GnomonicAxes.format_coord
GnomonicAxes.format_coord(x, y)
Format the coordinate for display in status bar. Take projection into account.
healpy.projaxes.GnomonicAxes.get_lonlat
GnomonicAxes.get_lonlat(x, y)
Get the coordinate in the coord system of the image, in lon/lat in deg.
healpy.projaxes.GnomonicAxes.get_meridian_interval
82
Chapter 3. Reference
Input:
the normalized vector of the direction of the center of the projection, in the reference frame of the
graticule.
Return:
vmin,vmax [the interval of phi for the] meridians crossing the field of view.
healpy.projaxes.GnomonicAxes.get_parallel_interval
GnomonicAxes.get_value(x, y)
Get the value of the map at position x,y
healpy.projaxes.GnomonicAxes.graticule
GnomonicAxes.projplot(*args, **kwds)
projplot is a wrapper around matplotlib.Axes.plot() to take into account the spherical projection.
You can call this function as:
83
projplot(theta, phi)
projplot(theta, phi, 'bo')
projplot(thetaphi)
projplot(thetaphi, 'bx')
#
#
#
#
plot
plot
plot
idem
84
Chapter 3. Reference
If True, theta and phi are interpreted as longitude and latitude in degree, otherwise, as
colatitude and longitude in radian
coord : {E, G, C, None}, optional
The coordinate system of the points, only used if the coordinate coordinate system of
the axes has been defined and in this case, a rotation is performed
rot : None or sequence, optional
rotation to be applied =(lon, lat, psi) : lon, lat will be position of the new Z axis, and psi
is rotation around this axis, all in degree. if None, no rotation is performed
direct : bool, optional
if True, the rotation to center the projection is not taken into account
See also:
projplot, projtext
Notes
85
Notes
GnomonicAxes.set_coordprec(n)
Set the number of digits after floating point for coord display.
healpy.projaxes.GnomonicAxes.set_format
GnomonicAxes.set_format(f )
Set the format string for value display
healpy.projaxes.HpxGnomonicAxes
class healpy.projaxes.HpxGnomonicAxes(*args, **kwds)
Methods
delgraticules()
format_coord(x, y)
get_lonlat(x, y)
get_meridian_interval(vx[, vy, vz])
get_parallel_interval(vx[, vy, vz])
get_value(x, y)
graticule([dpar, dmer, coord, local, verbose])
projmap(map[, nest])
projplot(*args, **kwds)
projscatter(theta[, phi])
projtext(theta, phi, s, **kwds)
set_coordprec(n)
set_format(f)
healpy.projaxes.HpxGnomonicAxes.delgraticules
HpxGnomonicAxes.delgraticules()
Delete all graticules previously created on the Axes.
healpy.projaxes.HpxGnomonicAxes.format_coord
HpxGnomonicAxes.format_coord(x, y)
Format the coordinate for display in status bar. Take projection into account.
86
Chapter 3. Reference
healpy.projaxes.HpxGnomonicAxes.get_lonlat
HpxGnomonicAxes.get_lonlat(x, y)
Get the coordinate in the coord system of the image, in lon/lat in deg.
healpy.projaxes.HpxGnomonicAxes.get_meridian_interval
HpxGnomonicAxes.get_value(x, y)
Get the value of the map at position x,y
healpy.projaxes.HpxGnomonicAxes.graticule
HpxGnomonicAxes.graticule(dpar=None, dmer=None,
bose=True, **kwds)
Draw a graticule.
coord=None,
local=None,
ver-
Input:
dpar: angular separation between parallels in degree
dmer: angular separation between meridians in degree
coord: coordinate system of the graticule (G, E or C)
local: if True, no rotation performed at all
87
healpy.projaxes.HpxGnomonicAxes.projmap
HpxGnomonicAxes.projplot(*args, **kwds)
projplot is a wrapper around matplotlib.Axes.plot() to take into account the spherical projection.
You can call this function as:
projplot(theta, phi)
projplot(theta, phi, 'bo')
projplot(thetaphi)
projplot(thetaphi, 'bx')
#
#
#
#
plot
plot
plot
idem
88
Chapter 3. Reference
89
rotation to be applied =(lon, lat, psi) : lon, lat will be position of the new Z axis, and psi
is rotation around this axis, all in degree. if None, no rotation is performed
direct : bool, optional
if True, the rotation to center the projection is not taken into account
See also:
projplot, projscatter
Notes
HpxGnomonicAxes.set_coordprec(n)
Set the number of digits after floating point for coord display.
healpy.projaxes.HpxGnomonicAxes.set_format
HpxGnomonicAxes.set_format(f )
Set the format string for value display
healpy.projaxes.MollweideAxes
class healpy.projaxes.MollweideAxes(*args, **kwds)
Define a mollweide Axes to handle mollweide projection.
Input:
rot=, coord= : define rotation and coordinate system. See rotator.
coordprec= : number of digit after floating point for coordinates display.
format= : format string for value display.
Other keywords from Axes (see Axes).
Methods
delgraticules()
format_coord(x, y)
get_lonlat(x, y)
get_meridian_interval(vx[, vy, vz])
get_parallel_interval(vx[, vy, vz])
get_value(x, y)
graticule([dpar, dmer, coord, local, verbose])
projmap(map, vec2pix_func[, xsize])
projplot(*args, **kwds)
projscatter(theta[, phi])
90
Chapter 3. Reference
healpy.projaxes.MollweideAxes.delgraticules
MollweideAxes.delgraticules()
Delete all graticules previously created on the Axes.
healpy.projaxes.MollweideAxes.format_coord
MollweideAxes.format_coord(x, y)
Format the coordinate for display in status bar. Take projection into account.
healpy.projaxes.MollweideAxes.get_lonlat
MollweideAxes.get_lonlat(x, y)
Get the coordinate in the coord system of the image, in lon/lat in deg.
healpy.projaxes.MollweideAxes.get_meridian_interval
MollweideAxes.get_value(x, y)
Get the value of the map at position x,y
3.7. projaxes Axes for projection
91
healpy.projaxes.MollweideAxes.graticule
MollweideAxes.projplot(*args, **kwds)
projplot is a wrapper around matplotlib.Axes.plot() to take into account the spherical projection.
You can call this function as:
projplot(theta, phi)
projplot(theta, phi, 'bo')
projplot(thetaphi)
projplot(thetaphi, 'bx')
#
#
#
#
plot
plot
plot
idem
92
Chapter 3. Reference
See also:
projscatter, projtext
Notes
93
Coordinates of point to plot. Can be put into one 2-d array, first line is then theta and
second line is phi. See lonlat parameter for unit.
text : str
The text to be displayed.
lonlat : bool, optional
If True, theta and phi are interpreted as longitude and latitude in degree, otherwise, as
colatitude and longitude in radian
coord : {E, G, C, None}, optional
The coordinate system of the points, only used if the coordinate coordinate system of
the axes has been defined and in this case, a rotation is performed
rot : None or sequence, optional
rotation to be applied =(lon, lat, psi) : lon, lat will be position of the new Z axis, and psi
is rotation around this axis, all in degree. if None, no rotation is performed
direct : bool, optional
if True, the rotation to center the projection is not taken into account
See also:
projplot, projscatter
Notes
MollweideAxes.set_coordprec(n)
Set the number of digits after floating point for coord display.
healpy.projaxes.MollweideAxes.set_format
MollweideAxes.set_format(f )
Set the format string for value display
healpy.projaxes.HpxMollweideAxes
class healpy.projaxes.HpxMollweideAxes(*args, **kwds)
Methods
delgraticules()
format_coord(x, y)
get_lonlat(x, y)
get_meridian_interval(vx[, vy, vz])
94
Chapter 3. Reference
healpy.projaxes.HpxMollweideAxes.delgraticules
HpxMollweideAxes.delgraticules()
Delete all graticules previously created on the Axes.
healpy.projaxes.HpxMollweideAxes.format_coord
HpxMollweideAxes.format_coord(x, y)
Format the coordinate for display in status bar. Take projection into account.
healpy.projaxes.HpxMollweideAxes.get_lonlat
HpxMollweideAxes.get_lonlat(x, y)
Get the coordinate in the coord system of the image, in lon/lat in deg.
healpy.projaxes.HpxMollweideAxes.get_meridian_interval
95
healpy.projaxes.HpxMollweideAxes.get_value
HpxMollweideAxes.get_value(x, y)
Get the value of the map at position x,y
healpy.projaxes.HpxMollweideAxes.graticule
HpxMollweideAxes.graticule(dpar=None, dmer=None,
bose=True, **kwds)
Draw a graticule.
coord=None,
local=None,
ver-
Input:
dpar: angular separation between parallels in degree
dmer: angular separation between meridians in degree
coord: coordinate system of the graticule (G, E or C)
local: if True, no rotation performed at all
healpy.projaxes.HpxMollweideAxes.projmap
HpxMollweideAxes.projplot(*args, **kwds)
projplot is a wrapper around matplotlib.Axes.plot() to take into account the spherical projection.
You can call this function as:
projplot(theta, phi)
projplot(theta, phi, 'bo')
projplot(thetaphi)
projplot(thetaphi, 'bx')
#
#
#
#
plot
plot
plot
idem
96
Chapter 3. Reference
rotation to be applied =(lon, lat, psi) : lon, lat will be position of the new Z axis, and psi
is rotation around this axis, all in degree. if None, no rotation is performed
direct : bool
if True, the rotation to center the projection is not taken into account
See also:
projscatter, projtext
Notes
97
healpy.projaxes.HpxMollweideAxes.projtext
HpxMollweideAxes.set_coordprec(n)
Set the number of digits after floating point for coord display.
healpy.projaxes.HpxMollweideAxes.set_format
HpxMollweideAxes.set_format(f )
Set the format string for value display
healpy.projaxes.CartesianAxes
class healpy.projaxes.CartesianAxes(*args, **kwds)
Define a cylindrical Axes to handle cylindrical projection.
98
Chapter 3. Reference
Methods
delgraticules()
format_coord(x, y)
get_lonlat(x, y)
get_meridian_interval(vx[, vy, vz])
get_parallel_interval(vx[, vy, vz])
get_value(x, y)
graticule([dpar, dmer, coord, local, verbose])
projmap(map, vec2pix_func[, xsize, ysize, ...])
projplot(*args, **kwds)
projscatter(theta[, phi])
projtext(theta, phi, s, **kwds)
set_coordprec(n)
set_format(f)
healpy.projaxes.CartesianAxes.delgraticules
CartesianAxes.delgraticules()
Delete all graticules previously created on the Axes.
healpy.projaxes.CartesianAxes.format_coord
CartesianAxes.format_coord(x, y)
Format the coordinate for display in status bar. Take projection into account.
healpy.projaxes.CartesianAxes.get_lonlat
CartesianAxes.get_lonlat(x, y)
Get the coordinate in the coord system of the image, in lon/lat in deg.
healpy.projaxes.CartesianAxes.get_meridian_interval
99
Input:
the normalized vector of the direction of the center of the projection, in the reference frame of the
graticule.
Return:
vmin,vmax [between 0 and pi, vmin<vmax, the interval of theta] for the parallels crossing the
field of view
healpy.projaxes.CartesianAxes.get_value
CartesianAxes.get_value(x, y)
Get the value of the map at position x,y
healpy.projaxes.CartesianAxes.graticule
CartesianAxes.projplot(*args, **kwds)
projplot is a wrapper around matplotlib.Axes.plot() to take into account the spherical projection.
You can call this function as:
projplot(theta, phi)
projplot(theta, phi, 'bo')
projplot(thetaphi)
projplot(thetaphi, 'bx')
#
#
#
#
plot
plot
plot
idem
Chapter 3. Reference
If True, theta and phi are interpreted as longitude and latitude in degree, otherwise, as
colatitude and longitude in radian
coord : {E, G, C, None}
The coordinate system of the points, only used if the coordinate coordinate system of
the Axes has been defined and in this case, a rotation is performed
rot : None or sequence
rotation to be applied =(lon, lat, psi) : lon, lat will be position of the new Z axis, and psi
is rotation around this axis, all in degree. if None, no rotation is performed
direct : bool
if True, the rotation to center the projection is not taken into account
See also:
projscatter, projtext
Notes
101
See also:
projplot, projtext
Notes
CartesianAxes.set_coordprec(n)
Set the number of digits after floating point for coord display.
102
Chapter 3. Reference
healpy.projaxes.CartesianAxes.set_format
CartesianAxes.set_format(f )
Set the format string for value display
healpy.projaxes.HpxCartesianAxes
class healpy.projaxes.HpxCartesianAxes(*args, **kwds)
Methods
delgraticules()
format_coord(x, y)
get_lonlat(x, y)
get_meridian_interval(vx[, vy, vz])
get_parallel_interval(vx[, vy, vz])
get_value(x, y)
graticule([dpar, dmer, coord, local, verbose])
projmap(map[, nest])
projplot(*args, **kwds)
projscatter(theta[, phi])
projtext(theta, phi, s, **kwds)
set_coordprec(n)
set_format(f)
healpy.projaxes.HpxCartesianAxes.delgraticules
HpxCartesianAxes.delgraticules()
Delete all graticules previously created on the Axes.
healpy.projaxes.HpxCartesianAxes.format_coord
HpxCartesianAxes.format_coord(x, y)
Format the coordinate for display in status bar. Take projection into account.
healpy.projaxes.HpxCartesianAxes.get_lonlat
HpxCartesianAxes.get_lonlat(x, y)
Get the coordinate in the coord system of the image, in lon/lat in deg.
healpy.projaxes.HpxCartesianAxes.get_meridian_interval
103
the normalized vector of the direction of the center of the projection, in the reference frame of the
graticule.
Return:
vmin,vmax [the interval of phi for the] meridians crossing the field of view.
healpy.projaxes.HpxCartesianAxes.get_parallel_interval
HpxCartesianAxes.get_value(x, y)
Get the value of the map at position x,y
healpy.projaxes.HpxCartesianAxes.graticule
HpxCartesianAxes.graticule(dpar=None, dmer=None,
bose=True, **kwds)
Draw a graticule.
coord=None,
local=None,
ver-
Input:
dpar: angular separation between parallels in degree
dmer: angular separation between meridians in degree
coord: coordinate system of the graticule (G, E or C)
local: if True, no rotation performed at all
healpy.projaxes.HpxCartesianAxes.projmap
HpxCartesianAxes.projplot(*args, **kwds)
projplot is a wrapper around matplotlib.Axes.plot() to take into account the spherical projection.
You can call this function as:
104
Chapter 3. Reference
projplot(theta, phi)
projplot(theta, phi, 'bo')
projplot(thetaphi)
projplot(thetaphi, 'bx')
#
#
#
#
plot
plot
plot
idem
105
If True, theta and phi are interpreted as longitude and latitude in degree, otherwise, as
colatitude and longitude in radian
coord : {E, G, C, None}, optional
The coordinate system of the points, only used if the coordinate coordinate system of
the axes has been defined and in this case, a rotation is performed
rot : None or sequence, optional
rotation to be applied =(lon, lat, psi) : lon, lat will be position of the new Z axis, and psi
is rotation around this axis, all in degree. if None, no rotation is performed
direct : bool, optional
if True, the rotation to center the projection is not taken into account
See also:
projplot, projtext
Notes
106
Chapter 3. Reference
Notes
HpxCartesianAxes.set_coordprec(n)
Set the number of digits after floating point for coord display.
healpy.projaxes.HpxCartesianAxes.set_format
HpxCartesianAxes.set_format(f )
Set the format string for value display
healpy.zoomtool.mollzoom
healpy.zoomtool.mollzoom(map=None, fig=None, rot=None, coord=None, unit=, xsize=800, title=Mollweide view, nest=False, min=None, max=None, flip=astro,
remove_dip=False, remove_mono=False, gal_cut=0, format=%g,
cmap=None, norm=None, hold=False, margins=None, sub=None)
Interactive mollweide plot with zoomed gnomview.
107
108
Chapter 3. Reference
CHAPTER 4
genindex
modindex
search
109
110
Index
Symbols
__call__() (healpy.rotator.Rotator method), 57
A
Alm (class in healpy.sphtfunc), 38
alm2cl() (in module healpy.sphtfunc), 36
alm2map() (in module healpy.sphtfunc), 33
alm2map_der1() (in module healpy.sphtfunc), 34
almxfl() (in module healpy.sphtfunc), 37
anafast() (in module healpy.sphtfunc), 31
ang2pix() (in module healpy.pixelfunc), 12
ang2vec() (in module healpy.pixelfunc), 14
ang2xy() (healpy.projector.CartesianProj method), 73
ang2xy() (healpy.projector.GnomonicProj method), 66
ang2xy() (healpy.projector.MollweideProj method), 69
ang2xy() (healpy.projector.SphericalProj method), 62
angdist() (in module healpy.rotator), 60
angle_ref() (healpy.rotator.Rotator method), 58
arrayinfo (healpy.projector.CartesianProj attribute), 73
arrayinfo (healpy.projector.GnomonicProj attribute), 65
arrayinfo (healpy.projector.MollweideProj attribute), 69
arrayinfo (healpy.projector.SphericalProj attribute), 61
C
CartesianAxes (class in healpy.projaxes), 98
CartesianProj (class in healpy.projector), 72
cartview() (in module healpy.visufunc), 44
coordin (healpy.rotator.Rotator attribute), 56
coordinstr (healpy.rotator.Rotator attribute), 57
coordout (healpy.rotator.Rotator attribute), 57
coordoutstr (healpy.rotator.Rotator attribute), 57
coords (healpy.rotator.Rotator attribute), 57
delgraticules()
(healpy.projaxes.HpxGnomonicAxes
method), 86
delgraticules()
(healpy.projaxes.HpxMollweideAxes
method), 95
delgraticules() (healpy.projaxes.MollweideAxes method),
91
delgraticules()
(healpy.projaxes.SphericalProjAxes
method), 77
delgraticules() (in module healpy.visufunc), 48
dir2vec() (in module healpy.rotator), 60
do_rot() (healpy.rotator.Rotator method), 58
F
fit_dipole() (in module healpy.pixelfunc), 28
fit_monopole() (in module healpy.pixelfunc), 28
format_coord() (healpy.projaxes.CartesianAxes method),
99
format_coord()
(healpy.projaxes.GnomonicAxes
method), 82
format_coord()
(healpy.projaxes.HpxCartesianAxes
method), 103
format_coord()
(healpy.projaxes.HpxGnomonicAxes
method), 86
format_coord()
(healpy.projaxes.HpxMollweideAxes
method), 95
format_coord()
(healpy.projaxes.MollweideAxes
method), 91
format_coord()
(healpy.projaxes.SphericalProjAxes
method), 77
Index
N
nest2ring() (in module healpy.pixelfunc), 15
npix2nside() (in module healpy.pixelfunc), 18
nside2npix() (in module healpy.pixelfunc), 18
nside2order() (in module healpy.pixelfunc), 19
nside2pixarea() (in module healpy.pixelfunc), 21
nside2resol() (in module healpy.pixelfunc), 20
O
order2nside() (in module healpy.pixelfunc), 20
orthview() (in module healpy.visufunc), 46
P
pix2ang() (in module healpy.pixelfunc), 11
pix2vec() (in module healpy.pixelfunc), 12
pixwin() (in module healpy.sphtfunc), 38
projmap() (healpy.projaxes.CartesianAxes method), 100
projmap() (healpy.projaxes.GnomonicAxes method), 83
projmap() (healpy.projaxes.HpxCartesianAxes method),
104
projmap() (healpy.projaxes.HpxGnomonicAxes method),
88
projmap() (healpy.projaxes.HpxMollweideAxes method),
96
projmap() (healpy.projaxes.MollweideAxes method), 92
projmap() (healpy.projaxes.SphericalProjAxes method),
78
projmap() (healpy.projector.CartesianProj method), 74
projmap() (healpy.projector.GnomonicProj method), 67
projmap() (healpy.projector.MollweideProj method), 71
projmap() (healpy.projector.SphericalProj method), 63
projplot() (healpy.projaxes.CartesianAxes method), 100
projplot() (healpy.projaxes.GnomonicAxes method), 83
projplot() (healpy.projaxes.HpxCartesianAxes method),
104
projplot() (healpy.projaxes.HpxGnomonicAxes method),
88
Index
R
read_alm() (in module healpy.fitsfunc), 52
read_cl() (in module healpy.fitsfunc), 53
read_map() (in module healpy.fitsfunc), 51
remove_dipole() (in module healpy.pixelfunc), 29
remove_monopole() (in module healpy.pixelfunc), 29
reorder() (in module healpy.pixelfunc), 16
ring2nest() (in module healpy.pixelfunc), 16
rotateDirection() (in module healpy.rotator), 59
rotateVector() (in module healpy.rotator), 58
Rotator (class in healpy.rotator), 55
rots (healpy.rotator.Rotator attribute), 57
S
set_coordprec() (healpy.projaxes.CartesianAxes method),
102
set_coordprec()
(healpy.projaxes.GnomonicAxes
method), 86
set_coordprec()
(healpy.projaxes.HpxCartesianAxes
method), 107
113
set_coordprec()
(healpy.projaxes.HpxGnomonicAxes
method), 90
set_coordprec()
(healpy.projaxes.HpxMollweideAxes
method), 98
set_coordprec()
(healpy.projaxes.MollweideAxes
method), 94
set_coordprec()
(healpy.projaxes.SphericalProjAxes
method), 81
set_flip() (healpy.projector.CartesianProj method), 75
set_flip() (healpy.projector.GnomonicProj method), 67
set_flip() (healpy.projector.MollweideProj method), 71
set_flip() (healpy.projector.SphericalProj method), 64
set_format() (healpy.projaxes.CartesianAxes method),
103
set_format() (healpy.projaxes.GnomonicAxes method),
86
set_format()
(healpy.projaxes.HpxCartesianAxes
method), 107
set_format()
(healpy.projaxes.HpxGnomonicAxes
method), 90
set_format()
(healpy.projaxes.HpxMollweideAxes
method), 98
set_format() (healpy.projaxes.MollweideAxes method),
94
set_format()
(healpy.projaxes.SphericalProjAxes
method), 81
set_proj_plane_info()
(healpy.projector.CartesianProj
method), 75
set_proj_plane_info() (healpy.projector.GnomonicProj
method), 67
set_proj_plane_info() (healpy.projector.MollweideProj
method), 71
set_proj_plane_info()
(healpy.projector.SphericalProj
method), 64
smoothalm() (in module healpy.sphtfunc), 36
smoothing() (in module healpy.sphtfunc), 35
SphericalProj (class in healpy.projector), 61
SphericalProjAxes (class in healpy.projaxes), 76
synalm() (in module healpy.sphtfunc), 37
synfast() (in module healpy.sphtfunc), 32
W
write_alm() (in module healpy.fitsfunc), 53
write_cl() (in module healpy.fitsfunc), 54
write_map() (in module healpy.fitsfunc), 52
X
xy2ang() (healpy.projector.CartesianProj method), 75
xy2ang() (healpy.projector.GnomonicProj method), 68
xy2ang() (healpy.projector.MollweideProj method), 72
xy2ang() (healpy.projector.SphericalProj method), 64
xy2ij() (healpy.projector.CartesianProj method), 76
xy2ij() (healpy.projector.GnomonicProj method), 68
xy2ij() (healpy.projector.MollweideProj method), 72
xy2ij() (healpy.projector.SphericalProj method), 64
xy2vec() (healpy.projector.CartesianProj method), 76
xy2vec() (healpy.projector.GnomonicProj method), 68
xy2vec() (healpy.projector.MollweideProj method), 72
xy2vec() (healpy.projector.SphericalProj method), 65
U
ud_grade() (in module healpy.pixelfunc), 25
UNSEEN (in module healpy.pixelfunc), 25
V
vec2ang() (in module healpy.pixelfunc), 14
vec2dir() (in module healpy.rotator), 60
vec2pix() (in module healpy.pixelfunc), 13
vec2xy() (healpy.projector.CartesianProj method), 75
vec2xy() (healpy.projector.GnomonicProj method), 68
vec2xy() (healpy.projector.MollweideProj method), 71
vec2xy() (healpy.projector.SphericalProj method), 64
114
Index