예제 #1
0
def shot_noise(nfn, nu, zs, mhalos, stellarmasses):
    chis = remote_spectra.chifromz(zs)

    Lcuts = Luminosity_from_flux(
        Scut(nu),
        zs)  #Scut is in mJy=1e-29W/m**2/Hz. This Lcut will be in mJy Mpc**2
    Lcuts = Lcuts * (3.086e22)**2  #now in mJy m**2 = 1e-29 W/Hz
    Lcuts = Lcuts * 1e-29  #in W/Hz
    Lcuts = Lcuts / 3.8e26  #insolarluminosities per hz
    integrand = 1 / remote_spectra.chifromz(zs)**2 * 1 / (
        1 + zs)**2 * shot_noise_chi_integral(nfn, nu, zs, Lcuts, mhalos,
                                             stellarmasses)
    #in 1/MPc**2*[shot_noise_chi_integral]=1/MPc**2*[stellar_mass_function]*L**2 = Mpc**-5*[L]**2=
    #=Mpc**-5* [solar luminosity/Hz]**2

    shot_noise = np.trapz(
        integrand, chis
    )  #in MPc*[integrand]=1/Mpc*[shot_noise_chi_integral]=Mpc**-4*[L]**2=

    if nu == 353:

        changetomicrokelvinfactor = 1 * 1 / (287.45)

    elif nu == 545:

        changetomicrokelvinfactor = 1 * 1 / (58.04)

    elif nu == 857:
        changetomicrokelvinfactor = 1 * 1 / (2.27)

    return shot_noise * changetomicrokelvinfactor**2
예제 #2
0
def survey_volume_mpc3(surveyarea_sqdeg, zmin, zmax):
    chimax = remote_spectra.chifromz(zmax)
    chimin = remote_spectra.chifromz(zmin)
    svolume_mpc3 = 4. / 3. * np.pi * ((chimax)**3. - (chimin)**3.)
    svolume_mpc3 *= (surveyarea_sqdeg / allsky_squaredeg)
    print("Survey volume Gpc-3", svolume_mpc3 * 1e-9)
    return svolume_mpc3
예제 #3
0
def convert_n_arcmin2_mpc3(n_arcmin2, z):
    dz = 0.01
    zmax = z + dz / 2.
    zmin = z - dz / 2.
    chimax = remote_spectra.chifromz(zmax)
    chimin = remote_spectra.chifromz(zmin)
    dV_shell_comov = 4. / 3. * np.pi * ((chimax)**3. - (chimin)**3.)
    dV_dz = dV_shell_comov / dz
    dV_dZdOmega = dV_dz / allsky_arcmin2
    n_mpc3 = n_arcmin2 / dV_dZdOmega
    return n_mpc3
예제 #4
0
def Scentral(nu, z, Mstar):
    #flux from luminosity; eg eq 7 of 1611.04517
    chi = remote_spectra.chifromz(z)

    return Lnu(nu * (1 + z), z, Mstar) / (
        (4 * np.pi) * chi**2 *
        (1 + z))  # in units of [Lnu]/Mpc**2=solar_luminosity/Mpc**2/Hz
예제 #5
0
 def Scentral(self,nu,z,Mhalo):
 
     # flux from luminosity; eg eq 42 of https://arxiv.org/pdf/1309.0382.pdf
     chi=remote_spectra.chifromz(z)
     answer= self.Lnu(nu,z,Mhalo)/((4*np.pi)*chi**2*(1+z)) 
     if self.L0!=1:  # implementing Scut. 
                     # Note that if you are playing with L0 you should remove this as if L0 is too high this will set all fluxes to 0.
         answer[answer>self.Scut(nu)]=0
     return answer
예제 #6
0
 def Cl_1halo(self,nu1,nu2,intensities_nu1,intensities_nu2,satellites_nu1,satellites_nu2,ells):
     
     # equation 13 of 1611.04517
     
     chis=remote_spectra.chifromz(self.zs)
     mhalos=np.exp(self.halomodel.lnms)
     mhalos=mhalos[mhalos>self.Mmin]
     
     Cl1_integrand=np.array([chis**2*self.Gnu(self.zs,ell/chis,chis,intensities_nu1,intensities_nu2,satellites_nu1,satellites_nu2)for ell in ells]) #in units of Mpc**2 [Gnu]
     return np.trapz(Cl1_integrand[:,self.zs>0.1],chis[self.zs>0.1],axis=1)*conversion_factor
예제 #7
0
 def shot_noise(self,freqind,sigma):
     chis=remote_spectra.chifromz(self.zs)
     centrals=self.central_intensities[freqind]
     
     centrals[centrals==0]=1e-100
     logcentrals=np.log(centrals)
     dummylogs=np.linspace(np.min(logcentrals[logcentrals>-200])-0.5,self.Scut(self.frequencies[freqind]),200)
     dnds=self.dndlns(dummylogs,logcentrals,sigma)
    
      
     
     return np.trapz(chis**2*(np.trapz(dnds*np.exp(dummylogs[:,np.newaxis])**2,dummylogs,axis=0)),chis)
예제 #8
0
 def setup_fluxes(self):
     
     self.mhalos=np.exp(self.halomodel.lnms)
     self.mhalos=self.mhalos[self.mhalos>self.Mmin]
     self.central_intensities=[]
     
     self.satellite_intensities=[]
     self.chis=remote_spectra.chifromz(self.zs)
     for frequency in self.frequencies:
         self.central_intensities.append(self.Scentral(frequency,self.zs,self.mhalos[:,np.newaxis]))
         self.satellite_intensities.append(self.satellite_intensity(frequency,self.zs,self.mhalos))
         
     self.central_intensities.append(self.Scentral(frequency,self.zs,self.mhalos[:,np.newaxis]))
     self.satellite_intensities.append(self.satellite_intensity(frequency,self.zs,self.mhalos))
예제 #9
0
    def Cl_CIB_phi(self,nu,intensities,satellites,ells,Plin):
        
        
        plin=np.zeros((len(ells),len(self.zs)))
        
        chis=remote_spectra.chifromz(self.zs)
        cls_CIBkappa=np.zeros(len(ells))
        
        cls_CIBkappa_integrand=chis**2*self.Fnu(nu,intensities,satellites,chis,self.zs)*(self.lensing_kernel(chis))
      
   

        for ell_index,ell in enumerate(ells):
            plin[ell_index]=np.array([Plin(self.zs[i],ell/chis[i])for i in range(0,len(self.zs))] )
        
        
            cls_CIBkappa[ell_index]=np.trapz(cls_CIBkappa_integrand*plin[ell_index],chis)/ell**2

        return cls_CIBkappa*np.sqrt(conversion_factor)
예제 #10
0
    def Cl_2halo(self,nu1,nu2,intensities_nu1,intensities_nu2,satellites_nu1,satellites_nu2,ells,Plin):
        
        # equation 11 of 1611.04517
        
        plin=np.zeros((len(ells),len(self.zs)))
        
        chis=remote_spectra.chifromz(self.zs)
        cls_2halo=np.zeros(len(ells))
        if nu1==nu2:
            Cl2_integrand=chis**2*self.Fnu(nu1,intensities_nu1,satellites_nu1,chis,self.zs)**2
        else:
            Cl2_integrand=chis**2*self.Fnu(nu1,intensities_nu1,satellites_nu1,chis,self.zs)*self.Fnu(nu2,intensities_nu2,satellites_nu2,chis,self.zs)

   

        for ell_index,ell in enumerate(ells):
            plin[ell_index]=np.array([Plin(self.zs[i],ell/chis[i])for i in range(0,len(self.zs))] )
        
        
            cls_2halo[ell_index]=np.trapz(Cl2_integrand*(plin[ell_index]),chis)

        return cls_2halo*conversion_factor
예제 #11
0
def Luminosity_from_flux(S, z):
    #gives luminosity in [S] * Mpc**2
    return 4 * np.pi * remote_spectra.chifromz(z)**2 * (1 + z) * S
예제 #12
0
    def calc_Cl_CIBCIB(self):
        print("Calculation Cl_CIBCIB, Cl_CIBtau, Cl_tautau...")

        ell_sparse = np.arange(conf.estim_smallscale_lmin,
                               conf.estim_smallscale_lmax,
                               100)  #we interpolate these spectra

        integral_CIBCIB_1h = np.zeros(ell_sparse.shape[0])

        integral_CIBCIB_2h = np.zeros(ell_sparse.shape[0])

        zs = np.linspace(conf.z_min, conf.z_max, 100)  #change this.

        chi_sampling = remote_spectra.chifromz(zs)

        for frequency_index in range(0, len(self.frequencies)):
            zs = np.linspace(conf.z_min, conf.z_max, 100)  #change this.

            chi_sampling = remote_spectra.chifromz(zs)
            frequency = self.frequencies[frequency_index]

            for ell_id, ell in enumerate(ell_sparse):
                #version 1. correct.
                ks = (ell + (1. / 2.)) / chi_sampling
                # integrand_chi_CIBtau = np.zeros( chi_sampling.shape[0] )
                #limber approx
                PCIBCIB_1h, PCIBCIB_2h = self.get_PCIBCIB(
                    ks, zs, frequency_index)

                if frequency == 353:

                    changetomicrokelvinfactor = 1 / (287.45)

                elif frequency == 545:

                    changetomicrokelvinfactor = 1 / (58.04)

                elif frequency == 857:
                    changetomicrokelvinfactor = 1 / (2.27)

                else:
                    print("frequency not defined at", frequency)

                CIBfactor = changetomicrokelvinfactor  #self.solar_luminosity_per_Megaparsec2_to_Jansky*changetomicrokelvinfactor

                integrand_CIBCIB_1h = 1 / (
                    chi_sampling)**2 * CIBfactor**2 * PCIBCIB_1h
                integrand_CIBCIB_2h = 1 / (
                    chi_sampling)**2 * CIBfactor**2 * PCIBCIB_2h
                #                    integrand_CIBtau =   1/(chi_sampling)**2 * electronfactor * CIBfactor * PCIBe

                integral_CIBCIB_1h[ell_id] = np.trapz(integrand_CIBCIB_1h,
                                                      chi_sampling)
                integral_CIBCIB_2h[ell_id] = np.trapz(integrand_CIBCIB_2h,
                                                      chi_sampling)

            #now log interpolate to get all ell
            with np.errstate(divide='ignore'):
                # plt.loglog(ell_sparse,integral_CIBCIB_2h)
                #plt.loglog(ell_sparse,integral_CIBCIB_1h)
                #p#lt.show()
                lin_interp = scipy.interpolate.interp1d(
                    np.log10(ell_sparse),
                    np.log10(integral_CIBCIB_1h),
                    bounds_error=False,
                    fill_value="extrapolate")
                self.Cl_CIBCIB_1h[frequency_index, :] = np.power(
                    10.0, lin_interp(np.log10(self.ls)))
                self.Cl_CIBCIB_1h[
                    frequency_index, :conf.estim_smallscale_lmin] = 0.
                lin_interp = scipy.interpolate.interp1d(
                    np.log10(ell_sparse),
                    np.log10(integral_CIBCIB_2h),
                    bounds_error=False,
                    fill_value="extrapolate")
                self.Cl_CIBCIB_2h[frequency_index, :] = np.power(
                    10.0, lin_interp(np.log10(self.ls)))
                self.Cl_CIBCIB_2h[
                    frequency_index, :conf.estim_smallscale_lmin] = 0.
            #'''
            for zbin_id in range(conf.zbins_nr):

                chi_min = remote_spectra.zbins_chi[zbin_id]
                chi_max = remote_spectra.zbins_chi[zbin_id + 1]
                #  windownorm = 1./(chi_max-chi_min) #norm of the window function to make it 1 when integrating over chi
                chi_sampling = np.logspace(np.log10(chi_min),
                                           np.log10(chi_max),
                                           num=100)
                zs = remote_spectra.zfromchi(chi_sampling)

                for ell_id, ell in enumerate(ell_sparse):
                    #version 1. correct.
                    ks = (ell + (1. / 2.)) / chi_sampling
                    # integrand_chi_CIBtau = np.zeros( chi_sampling.shape[0] )
                    #limber approx
                    PCIBCIB_1h, PCIBCIB_2h = self.get_PCIBCIB(
                        ks, zs, frequency_index)

                    if frequency == 353:

                        changetomicrokelvinfactor = 1 / (287.45)

                    elif frequency == 545:

                        changetomicrokelvinfactor = 1 / (58.04)

                    elif frequency == 857:
                        changetomicrokelvinfactor = 1 / (2.27)

                    else:
                        print("frequency not defined at", frequency)

                    CIBfactor = changetomicrokelvinfactor  #self.solar_luminosity_per_Megaparsec2_to_Jansky*changetomicrokelvinfactor

                    integrand_CIBCIB_1h = 1 / (
                        chi_sampling)**2 * CIBfactor**2 * PCIBCIB_1h
                    integrand_CIBCIB_2h = 1 / (
                        chi_sampling)**2 * CIBfactor**2 * PCIBCIB_2h
                    #                    integrand_CIBtau =   1/(chi_sampling)**2 * electronfactor * CIBfactor * PCIBe

                    integral_CIBCIB_1h[ell_id] = np.trapz(
                        integrand_CIBCIB_1h, chi_sampling)
                    integral_CIBCIB_2h[ell_id] = np.trapz(
                        integrand_CIBCIB_2h, chi_sampling)

                with np.errstate(divide='ignore'):
                    # plt.loglog(ell_sparse,integral_CIBCIB_2h)
                    #plt.loglog(ell_sparse,integral_CIBCIB_1h)
                    #p#lt.show()
                    lin_interp = scipy.interpolate.interp1d(
                        np.log10(ell_sparse),
                        np.log10(integral_CIBCIB_1h),
                        bounds_error=False,
                        fill_value="extrapolate")
                    self.Cl_CIBCIB_1h_binned[frequency_index,
                                             zbin_id, :] = np.power(
                                                 10.0,
                                                 lin_interp(np.log10(self.ls)))
                    self.Cl_CIBCIB_1h_binned[
                        frequency_index,
                        zbin_id, :conf.estim_smallscale_lmin] = 0.
                    lin_interp = scipy.interpolate.interp1d(
                        np.log10(ell_sparse),
                        np.log10(integral_CIBCIB_2h),
                        bounds_error=False,
                        fill_value="extrapolate")
                    self.Cl_CIBCIB_2h_binned[frequency_index,
                                             zbin_id, :] = np.power(
                                                 10.0,
                                                 lin_interp(np.log10(self.ls)))
                    self.Cl_CIBCIB_2h_binned[
                        frequency_index,
                        zbin_id, :conf.estim_smallscale_lmin] = 0.

        print("Calculation Cl_CIBCIB done.")
예제 #13
0
 def lensing_kernel(self,chi):
     
     #possibly off by a factor of 2, check this.
     
     chi_s=remote_spectra.chifromz(1100)
     return 3/2*self.halomodel.omegam*self.halomodel.H0**2*(chi_s-chi)/(chi_s*chi)*1/(lightspeed/1000)**2*(1+remote_spectra.zfromchi(chi))
예제 #14
0
 def Luminosity_from_flux(self,S,z):
     
     #inverse of above
     
     return  4 * np.pi * remote_spectra.chifromz(z)**2*(1+z)*S