cora.util.hputil
Convenience functions for dealing with Healpix maps.
Makes heavy use of the healpy module.
Forward Transform Routines
Backward Transforms
Sky Transforms
Transform sets of polarised maps at multiple frequencies.
Miscellaneous
Co-ordinate Transform
Functions
|
Fetch the angular position of each pixel in a map. |
|
Rotate a map from celestial co-ordinates into galactic co-ordinates. |
|
Rotate a map from galactic co-ordinates into celestial co-ordinates. |
|
Rotate a map from galactic co-ordinates into celestial co-ordinates. |
|
Return an nside appropriate for a spherical harmonic decomposition. |
|
Pack \(a_{lm}\) into Healpix format from 2D [l,m] array. |
|
|
|
Spherical harmonic transform of a complex function. |
|
Spherical harmonic transform of the polarisation on the sky (can be complex). |
|
Inverse spherical harmonic transform onto a complex field. |
|
Inverse spherical harmonic transform onto a real field. |
|
Inverse spherical harmonic transform onto a real polarised field. |
|
Invert a set of alms back into a 3d sky. |
|
Spherical Harmonic transform of a real map. |
|
Spherical Harmonic transform of polarisation functions on the sky. |
|
Transform a 3d skymap, slice by slice. |
|
Unpack \(a_{lm}\) from Healpix format into 2D [l,m] array. |
- cora.util.hputil.ang_positions(nside)
Fetch the angular position of each pixel in a map.
- Parameters:
nside (scalar) – The size of the map (nside is a definition specific to Healpix).
- Returns:
angpos – The angular position (in spherical polars), of each pixel in a Healpix map. Packed at [ [theta1, phi1], [theta2, phi2], …]
- Return type:
np.ndarray
- cora.util.hputil.nside_for_lmax(lmax, accuracy_boost=1)
Return an nside appropriate for a spherical harmonic decomposition.
- Parameters:
lmax (integer) – Maximum multipole in decomposition.
- Returns:
nside – Appropriate nside for decomposition. Is power of two.
- Return type:
integer
- cora.util.hputil.unpack_alm(alm, lmax, fullm=False)
Unpack \(a_{lm}\) from Healpix format into 2D [l,m] array.
This only unpacks into the
- Parameters:
alm (np.ndarray) – a_lm packed in Healpix format.
lmax (integer) – The maximum multipole in the a_lm’s.
fullm (boolean, optional) – Write out the negative m values.
- Returns:
almarray – a_lm in a 2D array packed as [l,m]. If fullm write out the negative m’s, packed into the second half of the array (they can be indexed as [l,-m]).
- Return type:
np.ndarray
- cora.util.hputil.pack_alm(almarray, lmax=None)
Pack \(a_{lm}\) into Healpix format from 2D [l,m] array.
This only unpacks into the
- Parameters:
almarray (np.ndarray) – a_lm packed in a 2D array as [l,m].
lmax (integer, optional) – The maximum multipole in the a_lm’s. If None (default) work it out from the first index.
- Returns:
alm – a_lm in Healpix packing. If fullm write out the negative m’s, packed into the second half of the array (they can be indexed as [l,-m]).
- Return type:
np.ndarray
- cora.util.hputil.sphtrans_real(hpmap, lmax=None, lside=None)
Spherical Harmonic transform of a real map.
- Parameters:
hpmap (np.ndarray[npix]) – A Healpix map.
lmax (scalar, optional) – The maximum l to calculate. If None (default), calculate up to
3*NSIDE - 1.lside (scalar, optional) – Size of array to return minus one, i.e. what would be lmax if the array was filled.
- Returns:
alm – A 2d array of alms, packed as
alm[l,m].- Return type:
np.ndarray[lside+1, lside+1]
Notes
This only includes m > 0. As this is the transform of a real field:
\[a_{l -m} = (-1)^m a_{lm}^*\]
- cora.util.hputil.sphtrans_complex(hpmap, lmax=None, centered=False, lside=None)
Spherical harmonic transform of a complex function.
- Parameters:
hpmap (np.ndarray) – A complex Healpix map.
lmax (scalar, optional) – The maximum l to calculate. If None (default), calculate up to 3*nside - 1.
centered (boolean, optional) – If False (default) similar to an FFT, alm[l,:lmax+1] contains m >= 0, and the latter half alm[l,lmax+1:], contains m < 0. If True the first half of alm[l,:] contains m < 0, and the second half m > 0. m = 0 is the central column.
lside (scalar, optional) – Size of array to return minus one, i.e. what would be lmax if the array was filled.
- Returns:
alm – A 2d array of alms, packed as alm[l,m].
- Return type:
np.ndarray
- cora.util.hputil.sphtrans_real_pol(hpmaps, lmax=None, lside=None)
Spherical Harmonic transform of polarisation functions on the sky.
Accepts real T, Q, U and optionally V like maps, and returns \(a^T_{lm}\), \(a^E_{lm}\), \(a^B_{lm}\) and \(a^V_{lm}\).
- Parameters:
hpmaps (np.ndarray[npol, npix]) – An array of Healpix maps, assumed to be T, Q, U and potentially V.
lmax (scalar, optional) – The maximum l to calculate. If None (default), calculate up to 3*nside - 1.
- Returns:
alms[npol, lmax+1, lmax+1] – A 3d array of alms, packed as alm[pol, l, m].
- Return type:
np.ndarray
Notes
This only includes m >= 0. As these are the transforms of a real field:
\[a_{l -m} = (-1)^m a_{lm}^*\]
- cora.util.hputil.sphtrans_complex_pol(hpmaps, lmax=None, centered=False, lside=None)
Spherical harmonic transform of the polarisation on the sky (can be complex).
Accepts complex T, Q, U and optionally V like maps, and returns \(a^T_{lm}\), \(a^E_{lm}\), \(a^B_{lm}\) and \(a^V_{lm}\).
- Parameters:
hpmaps (np.ndarray) – A list of complex Healpix maps, assumed to be T, Q, U (and optionally V).
lmax (scalar, optional) – The maximum l to calculate. If None (default), calculate up to 3*nside - 1.
centered (boolean, optional) – If False (default) similar to an FFT, alm[l,:lmax+1] contains m >= 0, and the latter half alm[l,lmax+1:], contains m < 0. If True the first half opf alm[l,:] contains m < 0, and the second half m > 0. m = 0 is the central column.
lside (scalar, optional) – Size of array to return minus one, i.e. what would be lmax if the array was filled.
- Returns:
alm_T, alm_E, alm_B – A 2d array of alms, packed as alm[l,m].
- Return type:
np.ndarray
- cora.util.hputil.sphtrans_inv_real(alm, nside)
Inverse spherical harmonic transform onto a real field.
- Parameters:
alm (np.ndarray) – The array of alms. Only expects the real half of the array.
nside (integer) – The Healpix resolution of the final map.
- Returns:
hpmaps
- Return type:
np.ndarray
- cora.util.hputil.sphtrans_inv_real_pol(alm, nside)
Inverse spherical harmonic transform onto a real polarised field.
- Parameters:
alm (np.ndarray[npol, lmax+1, lmax+1]) – The array of alms. Only expects the real half of the array. The first index is over polarisation T, Q, U (and optionally V).
nside (integer) – The Healpix resolution of the final map.
- Returns:
hpmaps – The T, Q, U and optionally V maps of the sky.
- Return type:
np.ndarray[npol, 12*nside**2]
- cora.util.hputil.sphtrans_inv_complex(alm, nside)
Inverse spherical harmonic transform onto a complex field.
- Parameters:
alm (np.ndarray) – The array of alms. Expects both positive and negative alm.
nside (integer) – The Healpix resolution of the final map.
- Returns:
hpmaps – Complex Healpix maps.
- Return type:
np.ndarray
- cora.util.hputil.sphtrans_sky(skymap, lmax=None)
Transform a 3d skymap, slice by slice.
This will perform the polarised transformation if there are three dimensions, and one is the appropriate length (3 or 4).
- Parameters:
skymap (np.ndarray[freq, healpix_index] or np.ndarray[freq, pol, healpix_index])
lmax (integer, optional) – Maximum l to transform.
- Returns:
alms
- Return type:
np.ndarray[frequencies, pol, l, m]
- cora.util.hputil.sphtrans_inv_sky(alm, nside)
Invert a set of alms back into a 3d sky.
If the polarisation dimension is length is 3 or 4, this will automatically do the polarised transform.
- Parameters:
alm (np.ndarray[freq, pol, l, m]) – Expects the full range (both positive and negative m).
nside (integer) – Resolution of final Healpix maps.
- Returns:
skymaps
- Return type:
np.ndarray[freq, npol, healpix_index]
- cora.util.hputil.coord_x2y(map, x, y)
Rotate a map from galactic co-ordinates into celestial co-ordinates.
This will operate on a series of maps (provided the Healpix index is last).
- Parameters:
map (np.ndarray[..., npix]) – Healpix map.
x ({'C', 'G', 'E'}) – Coordinate system to transform to/from. Celestial, ‘C’; Galactic ‘G’; or Ecliptic ‘E’.
y ({'C', 'G', 'E'}) – Coordinate system to transform to/from. Celestial, ‘C’; Galactic ‘G’; or Ecliptic ‘E’.
- Returns:
rotmap – The rotated map.
- Return type:
np.ndarray
- cora.util.hputil.coord_g2c(map_)
Rotate a map from galactic co-ordinates into celestial co-ordinates.
This will operate on a series of maps (provided the Healpix index is last).
- Parameters:
map (np.ndarray[..., npix]) – Healpix map.
- Returns:
rotmap – The rotated map.
- Return type:
np.ndarray
- cora.util.hputil.coord_c2g(map_)
Rotate a map from celestial co-ordinates into galactic co-ordinates.
This will operate on a series of maps (provided the Healpix index is last).
- Parameters:
map (np.ndarray[..., npix]) – Healpix map.
- Returns:
rotmap – The rotated map.
- Return type:
np.ndarray