Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# Copyright (C) 2020 ETH Zurich, Institute for Particle Physics and Astrophysics 

2# Author: Raphael Sgier and Jörg Herbel 

3 

4import numpy as np 

5from scipy import integrate 

6import healpy as hp 

7from UFalcon import constants 

8 

9def dimensionless_comoving_distance(z_low, z_up, cosmo): 

10 """ 

11 Computes the dimensionless comoving distance between two redshifts. Scalar input only. 

12 :param z_low: lower redshift 

13 :param z_up: upper redshift, must have same shape as z_low 

14 :param cosmo: Astropy.Cosmo instance, controls the cosmology used 

15 :return: dimensionless comoving distance 

16 """ 

17 dimless_com = integrate.quad(cosmo.inv_efunc, z_low, z_up)[0] 

18 return dimless_com 

19 

20 

21def comoving_distance(z_low, z_up, cosmo): 

22 """ 

23 Computes the comoving distance between two redshifts. Scalar input only. 

24 :param z_low: lower redshift 

25 :param z_up: upper redshift, must have same shape as z_low 

26 :param cosmo: Astropy.Cosmo instance, controls the cosmology used 

27 :return: comoving distance 

28 """ 

29 com = dimensionless_comoving_distance(z_low, z_up, cosmo) * constants.c / cosmo.H0.value 

30 return com 

31 

32 

33def kappa_to_gamma(kappa_map, lmax=None): 

34 """ 

35 Computes a gamma_1- and gamma_2-map from a kappa-map, s.t. the kappa TT-spectrum equals the gamma EE-spectrum. 

36 :param kappa_map: kappa map 

37 :param lmax: maximum multipole to consider, default: 3 * nside - 1 

38 :return: gamma_1- and gamma_2-map 

39 """ 

40 

41 nside = hp.npix2nside(kappa_map.size) 

42 

43 if lmax is None: 

44 lmax = 3 * nside - 1 

45 

46 kappa_alm = hp.map2alm(kappa_map, lmax=lmax) 

47 l = hp.Alm.getlm(lmax)[0] 

48 

49 # Add the appropriate factor to the kappa_alm 

50 fac = np.where(np.logical_and(l != 1, l != 0), -np.sqrt(((l + 2.0) * (l - 1))/((l + 1) * l)), 0) 

51 kappa_alm *= fac 

52 t, q, u = hp.alm2map([np.zeros_like(kappa_alm), kappa_alm, np.zeros_like(kappa_alm)], nside=nside) 

53 

54 return q, u