def crosscorr_integral_y_rec_coords( ell, z_i, delta_z ): #This is not working out-don't try this for now. Just leave it. n = n_points #number of points over which to integrate Kp_par = np.geomspace(1.e-6, .15, n) Kp_perp = np.geomspace(1.e-6, 1., n) Z_min = z_i - delta_z Z_max = z_i + delta_z z = np.geomspace(Z_min, Z_max, n) Kpar = np.geomspace(1.e-6, .15, n) kp_perp, kp_par, kpar = np.meshgrid(Kp_perp, Kp_par, Kpar) chi_z = chi(z) T_mean_zi = uf.T_mean(z_i) chi_zi = chi(z_i) f_zi = uf.f(z_i) f_z = uf.f(z) D_zi = uf.D_1(z_i) r_zi = uf.r(z_i) D_z = uf.D_1(z) H_zi = uf.H(z_i) tau_z = uf.tau_inst(z) kpar = y / uf.r(z) const = 1.e6 / ( 8. * np.pi**3 ) * T_rad * T_mean_zi**2 / cc.c_light_Mpc_s * f_zi * D_zi**2 * H_zi / ( chi_zi**2) / (1. + z_i) * x * (sigma_T * rho_g0 / (mu_e * m_p)) kperp = ell / chi_zi k = np.sqrt(kperp**2 + kpar**2) kp = np.sqrt(kp_perp**2 + kp_par**2) cos_theta = kp_par / kp #cos_theta=u, theta is azimuthal angle between k' and z (line of sight) axis sin_theta = kp_perp / kp sin_gamma = kpar / k #gamma is measured between k and xy plane, i.e. elevation of k cos_gamma = kperp / k zeta = sin_gamma * cos_theta + cos_gamma * sin_theta k_dot_kp = kperp * kp_perp + kpar * kp_par * zeta K = np.sqrt(k**2 + kp**2 - 2 * k_dot_kp) theta_K = kpar / K / k**2 * ( k**2 - k_dot_kp) - kp * kperp * np.sqrt(1 - zeta**2) / k / K theta_kp = cos_theta rsd = 1. + f_zi * kpar**2 / k**2 I = theta_kp * (theta_kp / kp**2 + theta_K / K / kp) z_dep_integ = sp.integrate.trapz(f_z * D_z**2 * (1 + z) * np.exp(-tau_z), z) integrand_1 = rsd**2 * Mps_interpf(kp) * Mps_interpf( K) * theta_kp**2 / kp**2 * kp_perp integrand_2 = rsd**2 * Mps_interpf(kp) * Mps_interpf( K) * theta_kp * theta_K / kp / K * kp_perp integral_1 = const * z_dep_integ * sp.integrate.trapz(sp.integrate.trapz( sp.integrate.trapz(integrand_1, Kp_perp, axis=0), Kp_par, axis=0), Kpar, axis=0) integral_2 = const * z_dep_integ * sp.integrate.trapz(sp.integrate.trapz( sp.integrate.trapz(integrand_2, Kp_perp, axis=0), Kp_par, axis=0), Kpar, axis=0) return integral_1 + integral_2
def crosscorr_rec_coords( ell, z_i, y, delta_z ): #with the assumption that zi=z so no cos factor, and we have dz=redshift bin width=2*delta_z defined above n = n_points #number of points over which to integrate Kp_par = np.geomspace(1.e-6, .15, n) Kp_perp = np.geomspace(1.e-6, 1., n) Z_min = z_i - delta_z Z_max = z_i + delta_z Z = np.geomspace(Z_min, Z_max, n) kp_perp, kp_par, z = np.meshgrid(Kp_perp, Kp_par, Z) chi_z = chi(z) T_mean_zi = uf.T_mean(z_i) chi_zi = chi(z_i) chi_z = chi(z) f_zi = uf.f(z_i) f_z = uf.f(z) D_zi = uf.D_1(z_i) r_zi = uf.r(z_i) D_z = uf.D_1(z) H_zi = uf.H(z_i) tau_z = uf.tau_inst(z) kpar = y / uf.r(z) const = 1.e6 / ( 4. * np.pi**2 ) * T_rad * T_mean_zi**2 / cc.c_light_Mpc_s * f_zi * D_zi**2 * H_zi / ( chi_zi**2 * r_zi) / (1. + z_i) * x * (sigma_T * rho_g0 / (mu_e * m_p)) kperp = ell / chi_z k = np.sqrt(kperp**2 + kpar**2) kp = np.sqrt(kp_perp**2 + kp_par**2) cos_theta = kp_par / kp #cos_theta=u, theta is azimuthal angle between k' and z (line of sight) axis sin_theta = kp_perp / kp sin_gamma = kpar / k #gamma is measured between k and xy plane, i.e. elevation of k cos_gamma = kperp / k zeta = sin_gamma * cos_theta + cos_gamma * sin_theta k_dot_kp = kperp * kp_perp + kpar * kp_par * zeta K = np.sqrt(k**2 + kp**2 - 2 * k_dot_kp) theta_K = kpar / K / k**2 * ( k**2 - k_dot_kp) - kp * kperp * np.sqrt(1 - zeta**2) / k / K theta_kp = cos_theta rsd = 1. + f_zi * kpar**2 / k**2 I = theta_kp * (theta_kp / kp**2 + theta_K / K / kp) integrand_1 = f_z * D_z**2 * ( 1 + z) * np.exp(-tau_z) * rsd**2 * Mps_interpf(kp) * Mps_interpf( K) * theta_kp**2 / kp**2 integrand_2 = f_z * D_z**2 * ( 1 + z) * np.exp(-tau_z) * rsd**2 * Mps_interpf(kp) * Mps_interpf( K) * theta_kp * theta_K / kp / K integral_1 = const * sp.integrate.trapz(sp.integrate.trapz( sp.integrate.trapz(integrand_1, Kp_perp, axis=0), Kp_par, axis=0), Z, axis=0) integral_2 = const * sp.integrate.trapz(sp.integrate.trapz( sp.integrate.trapz(integrand_2, Kp_perp, axis=0), Kp_par, axis=0), Z, axis=0) return integral_1 + integral_2
def crosscorr_squeezedlim( ell, z_i, y, delta_z ): #with the assumption that zi=z so no cos factor, and we have dz=redshift bin width=2*delta_z defined above n = n_points #number of points over which to integrate #y=np.geomspace(1.,3000.,n) U = np.linspace(-.9999, .9999, n) Kp = np.geomspace(1.e-6, .1, n) Z_min = z_i - delta_z Z_max = z_i + delta_z z = np.geomspace(Z_min, Z_max, n) u, kp = np.meshgrid(U, Kp) T_mean_zi = uf.T_mean(z_i) chi_zi = chi(z_i) chi_z = chi(z) f_zi = uf.f(z_i) f_z = uf.f(z) D_zi = uf.D_1(z_i) r_zi = uf.r(z_i) D_z = uf.D_1(z) H_zi = uf.H(z_i) tau_z = uf.tau_inst(z) kpar = y / uf.r(z) const = 1.e6 / ( 4. * np.pi**2 ) * T_rad * T_mean_zi**2 / cc.c_light_Mpc_s * f_zi * D_zi**2 * H_zi / ( chi_zi**2 * r_zi) / (1. + z_i) * x * (sigma_T * rho_g0 / (mu_e * m_p)) #Cl=np.array([]) kp_perp = kp * np.sqrt(1 - u**2) kp_par = kp * u k_perp = ell / chi_zi k = np.sqrt(k_perp**2 + kpar**2) rsd = 1. + f_zi * kpar**2 / k**2 zeta = (kpar / k * u + k_perp / k * np.sqrt(1 - u**2)) k_dot_kp = k_perp * kp_perp + kpar * kp_par * zeta K = np.sqrt(k**2 + kp**2 - 2 * k_dot_kp) #theta_kp=kpar*zeta/k+k_perp*np.sqrt(np.abs(1-zeta**2))/k theta_K = kpar / K / k**2 * ( k**2 - k_dot_kp) - kp * k_perp * np.sqrt(1 - zeta**2) / k / K #print (theta_K.min(),theta_K.max()) theta_kp = u #theta_K=np.where(theta_K > 0, theta_K, 0) I = theta_kp * (theta_kp / kp**2 + theta_K / K / kp) z_integral = sp.integrate.trapz(f_z * D_z**2 * (1 + z) * np.exp(-tau_z), z) integrand_1 = z_integral * Mps_interpf(kp) * Mps_interpf( K) * rsd**2 * theta_kp**2 #+theta_K/K/kp)#-mu*kp*np.gradient(Mps_interpf(k),axis=0)) integrand_2 = z_integral * Mps_interpf(kp) * Mps_interpf( k) * rsd**2 * kp**2 * theta_kp * theta_K / kp / K integral_sing_1 = const * sp.integrate.trapz( sp.integrate.trapz(integrand_1, U, axis=0), Kp, axis=0) integral_sing_2 = const * sp.integrate.trapz( sp.integrate.trapz(integrand_2, U, axis=0), Kp, axis=0) #Cl=np.append(Cl,integral) return integral_sing_1 + integral_sing_2
def Cl_21(ell,y,z): #Cl=[] Cl=np.array([]) for i in ell: kpar=y/uf.r(z) k=np.sqrt(kpar**2+(i/uf.chi(z))**2) mu_k_sq=kpar**2/k**2 a=uf.b_HI+uf.f(z)*mu_k_sq Cl_one=(uf.T_mean(z)*a*uf.D_1(z))**2*uf.Mps_interpf(k)/(uf.chi(z)**2*uf.r(z)) Cl=np.append(Cl,Cl_one) return Cl
def Cl_21_func_of_y(ell, z, y): z1 = 1. kpar = y / r(z1) chi_1 = uf.chi(z1) f_1 = uf.f(z1) D_1 = uf.D_1(z1) k = np.sqrt(kpar**2 + (ell / chi_1)**2) mu_k_sq = kpar**2 / k**2 a = uf.b_HI + f_1 * mu_k_sq Cl = (uf.T_mean(z1) * a * D_1)**2 * uf.Mps_interpf(k) / chi_1**2 / r(z1) return Cl
def crosscorr_squeezed_integral_y(ell, z_i, delta_z): n = n_points #number of points over which to integrate #y=np.geomspace(1.,3000.,n) #Kpar=y/uf.r(z) Kpar = np.geomspace(1.e-6, .15, n) U = np.linspace(-.9999, .9999, n) Kp = np.geomspace(1.e-6, .1, n) Z_min = z_i - delta_z Z_max = z_i + delta_z z = np.geomspace(Z_min, Z_max, n) u, kp, kpar = np.meshgrid(U, Kp, Kpar) T_mean_zi = uf.T_mean(z_i) chi_zi = chi(z_i) chi_z = chi(z) f_zi = uf.f(z_i) f_z = uf.f(z) D_zi = uf.D_1(z_i) r_zi = uf.r(z_i) D_z = uf.D_1(z) H_zi = uf.H(z_i) tau_z = uf.tau_inst(z) const = 1.e6 / ( 8. * np.pi**3 ) * T_rad * T_mean_zi**2 / cc.c_light_Mpc_s * f_zi * D_zi**2 * H_zi / ( chi_zi**2) / (1. + z_i) * x * (sigma_T * rho_g0 / (mu_e * m_p)) #Cl=np.array([]) kp_perp = kp * np.sqrt(1 - u**2) kp_par = kp * u k_perp = ell / chi_zi k = np.sqrt(k_perp**2 + kpar**2) rsd = 1. + f_zi * kpar**2 / k**2 zeta = (kpar / k * u + k_perp / k * np.sqrt(1 - u**2)) k_dot_kp = k_perp * kp_perp + kpar * kp_par * zeta K = np.sqrt(k**2 + kp**2 - 2 * k_dot_kp) #theta_kp=kpar*zeta/k+k_perp*np.sqrt(np.abs(1-zeta**2))/k theta_K = kpar / K / k**2 * ( k**2 - k_dot_kp) - kp * k_perp * np.sqrt(1 - zeta**2) / k / K theta_kp = u #theta_K=np.where(theta_K > 0, theta_K, 0) I = theta_kp * (theta_kp / kp**2 + theta_K / K / kp) z_dep_integ = sp.integrate.trapz(f_z * D_z**2 * (1 + z) * np.exp(-tau_z), z) integrand = Mps_interpf(kp) * Mps_interpf( k ) * rsd**2 * kp**2 * I #+theta_K/K/kp)#-mu*kp*np.gradient(Mps_interpf(k),axis=0)) integral_sing = const * z_dep_integ * sp.integrate.trapz( sp.integrate.trapz( sp.integrate.trapz(integrand, U, axis=0), Kp, axis=0), Kpar, axis=0) #Cl=np.append(Cl,integral) return integral_sing
def Integrand_doppler_21cm(ell, y): z1 = 1. z2 = z1 r_1 = r(z1) chi_1 = chi(z1) f_1 = f(z1) D1 = D(z1) tau_1 = tau(z1) H_1 = H(z1) H_2 = H(z2) f_2 = f(z2) D2 = D(z2) chi_2 = chi(z2) tau_2 = tau(z2) kpar = y / r_1 k = np.sqrt(kpar**2 + ell**2 / chi_1**2) const = uf.T_mean(z1) * uf.T_mean(z2) / cc.c_light_Mpc_s**2 mu_k = kpar / k rsd = 1 + f_1 * mu_k**2 integrand = D1 * D2 * H_1 * H_2 * f_1 * f_2 * Mps_interpf(k) * np.cos( kpar * (chi_1 - chi_2)) * rsd**2 / (1 + z1) / ( 1 + z2) * mu_k**2 / k**2 / chi_1**2 / r_1 return const * integrand
def Cl_21_lksz(ell,y,z): #Cl=[] Cl=np.array([]) for i in ell: a=uf.b_HI+uf.f(z)*mu_k(i,y,z)**2 #print (a) delta_tcm=(uf.T_mean(z)*a*uf.D_1(z))/(uf.chi(z)**2*uf.r(z)) #print (delta_tcm) delta_lksz=const*u(z_r)*np.abs(np.cos(uf.kpar(y,z_r)*chi_r))/k(i,y,z_r)**2*lksz.Mps_interpf(k(i,y,z_r)) #print (delta_lksz) Cl_one=delta_tcm*delta_lksz Cl=np.append(Cl,Cl_one) return Cl
def Cl_21(ell, z1): y = np.linspace(1, 3000, n_points) kpar = np.geomspace(1e-10, 1e-2, n_points) kpar = y / r(z1) Cl = np.array([]) for i in ell: #integral=sp.integrate.quadrature(lambda kpar:Cl_21_func_of_y(z1,kpar,i),1e-4,1e-1)[0] chi_1 = uf.chi(z1) f_1 = uf.f(z1) D_1 = uf.D_1(z1) k = np.sqrt(kpar**2 + (i / chi_1)**2) mu_k_sq = kpar**2 / k**2 a = uf.b_HI + f_1 * mu_k_sq integral = sp.integrate.trapz((uf.T_mean(z1) * a * D_1)**2 * uf.Mps_interpf(k) / chi_1**2 / r(z1), y, axis=0) Cl = np.append(Cl, integral) return Cl
def crosscorr_squeezedlim(ell, y): #with the assumption that zi=z so no cos factor z_i = 1. delta_z = 0.3 n = 100 Mu = np.linspace(-0.9999, 0.9999, n) Kp = np.linspace(1.e-4, 10., n) mu, kp = np.meshgrid(Mu, Kp) z = z_i T_mean_zi = uf.T_mean(z_i) chi_zi = chi(z_i) chi_z = chi(z) f_zi = uf.f(z_i) f_z = uf.f(z) D_zi = uf.D_1(z_i) r_zi = uf.r(z_i) D_z = uf.D_1(z) H_zi = uf.H(z_i) tau_z = uf.tau_inst(z) const = 1.e6 / ( 2. * np.pi )**2 * T_rad * T_mean_zi / cc.c_light_Mpc_s * f_zi * D_zi**2 * H_zi / ( chi_zi**2 * r_zi) / (1. + z_i) * x * ( sigma_T * rho_g0 / (mu_e * m_p)) * delta_z * f_z * D_z**2 * (1 + z) * np.exp(-tau_z) #Cl=np.array([]) kpar = y / r_zi k_perp = ell / chi_zi k = np.sqrt(k_perp**2 + kpar**2) rsd = 1. + f_zi * kpar**2 / k**2 theta_kp = kpar * mu / k + k_perp * np.sqrt(1. - mu**2) / k integrand = Mps_interpf(kp) * rsd * theta_kp**2 * ( Mps_interpf(k)) #-mu*kp*np.gradient(Mps_interpf(k),axis=0)) integral_sing = const * sp.integrate.trapz( sp.integrate.trapz(integrand, Mu, axis=0), Kp, axis=0) #Cl=np.append(Cl,integral) return integral_sing