Example #1
0
def diff_comoving_volume(z):
    cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Tcmb0=2.725)
    H0 = cosmo.H(0).value  # km / s / Mpc
    dl = cosmo.luminosity_distance(z).value
    lightspeed = c * 0.001  # convert from m/s to km/s
    ez = np.sqrt(cosmo.Om(0) * ((1 + z)**3) + (1 - cosmo.Om(0)))
    dv = 4 * np.pi * (lightspeed / H0) * (dl**2) / ((1 + z)**2) / ez
    dv = dv * ((0.001)**3)  # Mpc^3 to Gpc^3
    # Test case
    #dv_new = cosmo.differential_comoving_volume(3)
    #print (4 * np.pi * dv_new.value)
    return dv
Example #2
0
def Sigmabar_NFW_r(r, z, Mvir, cvir, Delta_C=None, cosmo=None):
    """
    %%%%%%%%%
    % sigma=Sigmabar_NFW(r,z,Mvir,cvir)
    % NFW Sigma in Msun/Mpc^2 in shells of theta
    % (using Shimizu etal 2003?; Wright & Brainerd)
    %%%%%%%%%
    """
    if cosmo is None:
        cosmo = FlatLambdaCDM(
            H0=70,
            Om0=0.3,
        )
    if Delta_C is None:
        Delta_C = c.Delta_vir(z, cosmo) * cosmo.Om(z)

    rho_cz = cosmo.critical_density(z).to(u.M_sun / u.Mpc**3.0)
    delta_cvir = c.delta_c(cvir, Delta_C)
    rvir = (Mvir / (4. * np.pi / 3. * rho_cz * Delta_C))**(
        1. / 3)  # wrt critical density
    rs = rvir / cvir
    x = r / rs

    cscale = 2 * rs * delta_cvir * rho_cz

    kappabar = kappabar_NFW(x)
    sigmabar = kappabar * cscale
    return sigmabar
Example #3
0
def Delta_vir(z, cosmo=None):
    if cosmo is None:
        cosmo = FlatLambdaCDM(
            H0=70,
            Om0=0.3,
        )
    wf = (1 / cosmo.Om(z) - 1)
    Delta_vir = 18. * np.pi**2. * (1 + 0.40929 * wf**0.90524)
    return Delta_vir
Example #4
0
def rvir_NFW(z, Mvir, Delta_C=None, cosmo=None):
    if cosmo is None:
        cosmo = FlatLambdaCDM(
            H0=70,
            Om0=0.3,
        )
    if Delta_C is None:
        Delta_C = c.Delta_vir(z, cosmo) * cosmo.Om(z)
    rho_cz = cosmo.critical_density(z).to(u.M_sun / u.Mpc**3.)
    rvir = (Mvir / (4. * np.pi / 3. * rho_cz * Delta_C))**(1. / 3.)
    return rvir
Example #5
0
def ks_gnfw(r, z, zs, Mvir, cvir, Delta_C=None, cosmo=None):
    if cosmo is None:
        cosmo = FlatLambdaCDM(
            H0=70,
            Om0=0.3,
        )
    if Delta_C is None:
        Delta_C = c.Delta_vir(z, cosmo) * cosmo.Om(z)
    rho_cz = cosmo.critical_density(z).to(u.M_sun / u.Mpc**3)
    delta_cvir = c.delta_c(cvir, Delta_C)
    rvir = rvir_NFW(z, Mvir, Delta_C, cosmo)
    rs = rvir / cvir
    ks_gnfw = 2 * rs * delta_cvir * rho_cz / c.Sigma_crit(z, zs, cosmo)
    return ks_gnfw
class Growth(object):
    """ """
    gamma_fid = 0.55
    
    def __init__(self, om=0.307115, omb=0.048206, sig8=0.8228, zmax=5, amax=4):
        """ """
        self.om = om
        self.omb = omb
        self.sig8 = sig8
        self.zmax = zmax
        self.amax = amax
        self.zmin = 1./amax - 1
        self.cosmo = FlatLambdaCDM(100, self.om, Ob0=self.omb)
        
        logamin = - np.log(1+zmax)
        loga = np.linspace(np.log10(amax), logamin, 1000)
        z = 1./np.exp(loga) - 1
        self._omz = self.cosmo.Om(z)
        self._z = z
        self._zmid = (z[1:]+z[:-1])/2.
        self._logastep = loga[1] - loga[0]
        
        f = self._omz**self.gamma_fid
        logdelta = integrate.cumtrapz(f, dx=self._logastep)
        g = np.exp(logdelta)
        

        fid = interpolate.interp1d(self._zmid, g, bounds_error=False, fill_value=(g[0],g[-1]))
        g0 = fid(0)
        g = sig8 * g / g0
        
        self.fid = interpolate.interp1d(self._zmid, g, bounds_error=False, fill_value=(g[0],g[-1]))

        self.fid_inv = interpolate.interp1d(g, self._zmid,bounds_error=False, fill_value=(z[0],z[-1]))
        logging.info("growth range %f %f", z[0],z[-1])
        logging.info("growth sig8 %f", self.fid(0))


    def init_from_class(self):
        """ """
        class_params = {
            'output': 'mPk',
            'non linear': '',
            'z_max_pk': self.zmax,
            'Omega_b': self.omb,
            'Omega_cdm': self.om-self.omb,
        }
        self.cosmo_class = Class()
        self.cosmo_class.set(class_params)
        self.cosmo_class.compute()
        zz = np.linspace(0,self.zmax,100)
        s8z = []
        for z in zz:
            s8z.append(self.sig8 * self.cosmo_class.scale_independent_growth_factor(z))
        self.fid = interpolate.interp1d(zz, s8z)
        self.fid_inv = interpolate.interp1d(s8z,zz)
        
    def __call__(self, z, sig8_0=None, gamma=None):
        """ """
        if np.any(z > self.zmax):
            raise ValueError
        if np.any(z < self.zmin):
            raise ValueError
        if sig8_0 is None:
            sig8_0 = self.sig8
        if gamma is None:
            gamma = self.gamma_fid
        
        f = self._omz**gamma
        if not np.all(np.isfinite(f)):
            raise ValueError

        logdelta = integrate.cumtrapz(f, dx=self._logastep)
        g = np.exp(logdelta)

        if not np.all(np.isfinite(g)):
            raise ValueError

        func = interpolate.interp1d(self._zmid, g, bounds_error=False, fill_value=(g[0],g[-1]))

        f0 = func(0)
        if f0 == 0:
            raise ValueError
        if not np.isfinite(f0):
            raise ValueError
            
        return func(z) / f0 * sig8_0
            (p)) * (delta_c * a**0.5 / sigma)**(q) * n.e**(-a * delta_c**2. /
                                                           (2. * sigma**2.))

X = n.arange(-0.6, 0.5, 0.01)  #n.log10(1./sigma)
sigma = 10**-X

hz = cosmo.H(boxRedshift).value / 100.
# m sigma relation using the sigma8 corrected power spectrum
m2sigma = interp1d(hf.M, hf.sigma)
# m nu relation: nu = (delta_c / sigma_m)**2
m2nu = interp1d(hf.M, hf.nu)
# jacobian
toderive = interp1d(n.log(hf.M), n.log(hf.sigma))
mass = hf.M[100:-100]
dlnsigmadlnm = derivative(toderive, n.log(mass))
rhom_units = cosmo.Om(boxRedshift) * cosmo.critical_density(boxRedshift).to(
    u.solMass / (u.Mpc)**3.)  #/(cosmo.h)**2.
# in units (Msun/h) / (Mpc/h)**3
rhom = rhom_units.value  # hf.mean_density#/(hz)**2.

ftC16 = f_BH(hf.sigma[100:-100], 0.279, 0.908, 0.671, 1.737)

MF_MD = interp1d(mass, ftC16 * rhom * abs(dlnsigmadlnm) / mass)

NpartMin = 50.
p_init = (-1.85, -2.3)

env = os.environ['MD10']
sat_in_cen_d1 = join(env, "substructure",
                     "out_0.74980_subH_inDistinct_d1.fits")
sat_in_cen_d2 = join(env, "substructure",
Example #8
0
class PowerTemplate:
    def __init__(self,
                 z=0.5,
                 ombhsq=0.02222,
                 omhsq=0.14212,
                 sigma8=0.830,
                 h=0.6726,
                 ns=0.9652,
                 Tcmb0=2.725):
        self.z = z
        self.h = h
        self.ombhsq = ombhsq  # Omega matter baryon
        self.omhsq = omhsq  # Omega matter (baryon + CDM)
        self.om = omhsq / np.square(h)
        self.omb = ombhsq / np.square(h)
        self.cosmology = FlatLambdaCDM(H0=100 * h,
                                       Om0=self.om,
                                       Tcmb0=Tcmb0,
                                       Ob0=self.omb)
        self.ol = 1 - self.omhsq / np.square(h)  # ignring radiation density
        self.sigma8 = sigma8
        self.ns = ns
        self.Tcmb0 = 2.725
        self.Rscale = 8
        self.P0smooth = 1  # initial value for the coefficient
        self.P0smooth = np.square(sigma8 / self.siglogsmooth())  # correction

    def T0(self, k):
        '''
        Zero-baryon transfer function shape from E&H98, input k in h/Mpc
        '''
        k = k * self.h  # convert unit of k from h/Mpc to 1/Mpc
        #  Eqn 26, approximate sound horizon in Mpc
        s = 44.5 * np.log(
            9.83 / self.omhsq) / np.sqrt(1 + 10 * np.power(self.ombhsq, 3 / 4))
        # Eqn 28, both dimensionless
        Theta = self.Tcmb0 / 2.7
        # Eqn 31, alpha_gamma, dimensionless
        agam = 1 - 0.328 * np.log(431*self.omhsq) * self.ombhsq/self.omhsq \
            + 0.38*np.log(22.3*self.omhsq) * np.square(self.ombhsq/self.omhsq)
        # Eqn 30, in unit of h
        gamma_eff = self.omhsq / self.h * (
            agam + (1 - agam) / np.power(1 + (0.43 * k * s), 4))
        q = k / self.h * np.square(Theta) / gamma_eff

        C0 = 14.2 + 731 / (1 + (62.5 * q))  # Eqn 29
        L0 = np.log(2 * np.e + 1.8 * q)
        T0 = L0 / (L0 + C0 * np.square(q))
        return T0

    def siglogsmooth(self, tol=1e-10):
        '''rms mass fluctuations (integrated in logspace) for sig8 etc.
        NOTES: formalism is all real-space distance in Mpc/h, all k in
        h/Mpc
        '''
        return np.sqrt(romberg(self.intefunclogsmooth, -10, 10, tol=tol))

    def intefunclogsmooth(self, logk):
        """
        Function to integrate to get rms mass fluctuations (logspace) base 10
        NOTES: Because the k's here are all expressed in h/Mpc the
        value of P0 that arises using this integration is in
        (Mpc**3)/(h**3.) and therefore values of P(k) derived from this
        integration are in (Mpc**3)/(h**3.), i.e. h^-3Mpc^3 and need
        divided by h^3 to get the 'absolute' P(k) in Mpc^3.
        v1.0 Adam D. Myers Jan 2007
        """
        k = np.power(10.0, logk)  # base 10
        kR = k * self.Rscale
        integrand = np.log(10) / (2*np.square(np.pi)) * np.power(k, 3) \
            * self.Psmooth(k) * np.square(W(kR))
        return integrand

    def Psmooth(self, k):
        """ Baryonic Linear power spectrum SHAPE, pass k in h/Mpc """
        om = self.om
        ol = self.ol
        omz = self.cosmology.Om(self.z)  # Omega matter at z
        olz = ol / np.square(self.cosmology.efunc(self.z))  # MBW Eqn 3.77
        g0 = 5 / 2 * om / (np.power(om, 4 / 7) - ol +
                           ((1 + om / 2) * (1 + ol / 70)))  # Eqn 4.76
        gz = 5 / 2 * omz / (np.power(omz, 4 / 7) - olz + ((1 + omz / 2) *
                                                          (1 + olz / 70)))
        Dlin_ratio = gz / (1 + self.z) / g0
        Psmooth = self.P0smooth * np.square(self.T0(k)) * \
            np.power(k, self.ns) * np.square(Dlin_ratio)
        return Psmooth

    def P(self,
          k_lin,
          P_lin,
          n_mu_bins,
          beta=0,
          Sigma_s=4,
          Sigma_r=15,
          Sigma_perp=0,
          Sigma_para=0):
        """
        This is the final power template from P_lin and P_nw
        including the C and exponential damping terms
        input k, P are 1D arrays from CAMB, n_mu_bins is an integer
        default beta = 0.4, dimensionless
        """
        self.k = k_lin  # 1D array
        self.P_lin = P_lin  # 1D array
        self.P_nw = self.Psmooth(k_lin)  # 1D array
        self.mu_bins = np.linspace(0, 1, num=n_mu_bins + 1)  # 1D bin edges
        self.mu = (self.mu_bins[1:] + self.mu_bins[:-1]) / 2  # 1D bin centres
        mu, k = np.meshgrid(self.mu, k_lin)  # 2D meshgrid
        P_lin = np.tile(P_lin, (n_mu_bins, 1)).T  # meshgrid
        P_nw = self.Psmooth(k)  # follows meshgrid shape of k_lin
        try:
            assert P_lin.size == P_nw.size
        except AssertionError:
            print('P shapes are', P_lin.shape, P_nw.shape)
        sigmavsq = (1 - np.square(mu))*np.square(Sigma_perp)/2 \
            + np.square(mu*Sigma_para)/2  # BAO peak smoothing due to nonlinear
        S = np.exp(-np.square(k * Sigma_r) / 2)
        C = (1 + np.square(mu) * beta * (1-S)) / \
            (1 + np.square(k*mu*Sigma_s)/2)
        self.P_k_mu = np.square(C) * (
            (P_lin - P_nw) * np.exp(-np.square(k) * sigmavsq) + P_nw)
        return self.P_k_mu

    def p_multipole(self, ell):

        Ln = legendre(ell)
        P_ell = (2 * ell + 1) / 2 * np.sum(
            self.P_k_mu * (Ln(-self.mu) + Ln(self.mu)) * np.diff(self.mu_bins),
            axis=1)
        return P_ell

    def xi_multipole(self, r_input, ell, a=0.34, r_damp=True):
        '''
        integrate in logk space using trapozoidal rule
        a is the exponential damping parameter to suppress high-k oscillations
        usually 0.3 to 1
        input r may be 2D of dim (n_r_bins, n_mu_bins)
        '''
        P_ell = self.p_multipole(ell)
        P_ell = (P_ell[1:] + P_ell[:-1]) / 2  # interpolate midpoint
        dk = np.diff(self.k)
        lnk_edges = np.log(self.k)
        lnk = (lnk_edges[1:] + lnk_edges[:-1]) / 2  # lnk value at midpoint
        k = np.exp(lnk)  # k value at midpoint
        # turn into 2D grids
        k = np.tile(k, (r_input.size, 1))
        P_ell = np.tile(P_ell, (r_input.size, 1))
        dk = np.tile(dk, (r_input.size, 1))
        r = np.tile(r_input.flatten(), (k.shape[1], 1)).T
        assert k.shape == P_ell.shape == dk.shape == r.shape
        if r_damp:
            damp = np.exp(-r * np.square(k * a))
        else:
            damp = np.exp(-np.square(k * a))
        xi_ell = np.power(1j, ell) / (2 * np.square(np.pi)) * np.sum(
            np.square(k) * P_ell * spherical_jn(ell, k * r) * damp * dk,
            axis=1)
        return np.real(xi_ell.reshape(r_input.shape))
Example #9
0
def main():

########################################################################
# Parameters.                                                          #
########################################################################

# Parameters for survey cone
  rmin = 0.          # Minimum R.A. of survey [deg]
  rmax = 90.         # Maximum R.A. of survey [deg]
  dmin = 30.         # Minimum Dec. of survey [deg]
  dmax = 90.         # Maximum Dec. of survey [deg]
  zmin = 0.2         # Minimum redshift of survey
  zmax = 0.6         # Maximum redshift of survey
# Parameters applied to intensity map
  nside = 128        # Healpix resolution for angular pixelization
  dzbin = 0.005      # Width of redshift bins
  ngrid = 256        # Grid size of FFT
  dobeam = True      # Convolve with telescope beam
  sigdeg = 1.        # Standard deviation of telescope beam [deg]
  donoise = True     # Include noise in temperature map
  signoise = 0.3     # Gaussian noise per cell
  dofg = False       # Read in data with foregrounds, and apply subtraction
# Parameters applied to galaxy map
  winfile = 'winx_MICEv2-ELGs.dat' # Window function
# Parameters for power spectrum estimation
  doconv = False     # Determine full convolution with window
  kmin = 0.          # Minimum wavenumber [h/Mpc]
  kmax = 0.3         # Maximum wavenumber [h/Mpc]
  nkbin = 30         # Number of Fourier bins
  binopt = 1         # 1) power spectrum multipoles
                     # 2) power spectrum wedges P(k,mu)
                     # 3) 2D power spectrum P(k_perp,k_par)
  nwedge = 4         # Number of wedges if binopt=2
  kmin2 = 0.         # Minimum wavenumber for 2D power if binopt=3
  kmax2 = 0.18       # Maximum wavenumber for 2D power if binopt=3
  nk2d = 9           # Number of bins for 2D power if binopt=3
# Parameters for cosmological model
  om = 0.25          # Matter density
  bgal = 1.17        # Bias of galaxy sample
  bdens = 1.09       # Bias of intensity sample
# RSD distortion parameters
  cosmo = FlatLambdaCDM(H0=100.,Om0=om)
  zeff = 0.5*(zmin+zmax)
  ffid = cosmo.Om(zeff)**0.55
  betagal = ffid/bgal  # RSD distortion parameter of galaxy sample
  betadens = ffid/bdens# RSD distortion parameter of intensity sample
  sigvgal = 260.       # Pairwise velocity dispersion of galaxies [km/s]
  sigvdens = 440.      # Pairwise velocity dispersion of HI [km/s]
  pkmodfile = 'pkcambhalofit_zeq0pt4_mice.dat' # Model power spectrum

########################################################################
# Initializations.                                                     #
########################################################################

  data = np.loadtxt(pkmodfile)
  kmod,pkmod = data[:,0],data[:,1]
  nx,ny,nz = ngrid,ngrid,ngrid
  dobound = False
  nzbin = int(np.rint((zmax-zmin)/dzbin))
  zlims = np.linspace(zmin,zmax,nzbin+1)

########################################################################
# Get angular healpix window function.                                 #
########################################################################

  data = np.loadtxt('pixwin_nside128.dat')
  lwin,pixwin = data[:,0],data[:,1]

########################################################################
# Dimensions of FFT cuboid for embedding the survey cone.              #
########################################################################

  lx,ly,lz,x0,y0,z0 = boxtools.boxsize(zmin,zmax,dobound,rmin,rmax,dmin,dmax,cosmo)
  vol,nc = lx*ly*lz,nx*ny*nz
  vpix = vol/nc

########################################################################
# Read in MICE intensity mapping data.                                 #
########################################################################

  denshpz,winhpz,ipixlst,npix = micetools.readmiceintmap(nzbin,nside,dzbin,zmin,zmax,dofg)

########################################################################
# Determine noise power spectrum.                                      #
########################################################################

  if (donoise):
    signoisez = sphertools.getsignoisez(nside,nzbin,zlims,signoise,vpix,cosmo)
    pknoise = sphertools.calcpknoisehpz(nside,nzbin,zlims,signoise,True,signoisez,npix,cosmo)
  else:
    pknoise = 0.

########################################################################
# Add noise to the field.                                              #
########################################################################

  if (donoise):
    denshpz += sphertools.getnoisehpz(nzbin,ipixlst,signoise,True,signoisez)

########################################################################
# Convolve the field with the telescope beam.                          #
########################################################################

  if (dobeam):
    denshpz = sphertools.convhpzbeam(nside,ipixlst,nzbin,denshpz,sigdeg)

########################################################################
# Run foreground subtraction.                                          #
########################################################################

  if (dofg):
    denshpz = micetools.cleanFG(denshpz,N_IC=4)

########################################################################
# Convert the field from the (redshift,healpix) map to the FFT grid.   #
########################################################################

  densgrid,wingriddens = hppixtogrid.hppixtogrid(nzbin,nside,denshpz,winhpz,ipixlst,zlims,dobound,rmin,rmax,dmin,dmax,nx,ny,nz,lx,ly,lz,x0,y0,z0,cosmo)

########################################################################
# Read in and grid MICE galaxy data and window function.               #
########################################################################

  ras,dec,red,ngal = micetools.readmicegalcat(zmin,zmax)
  dxpos,dypos,dzpos = boxtools.getxyz(dobound,rmin,rmax,dmin,dmax,ras,dec,red,cosmo)
  galgrid = boxtools.discret(dxpos,dypos,dzpos,nx,ny,nz,lx,ly,lz,x0,y0,z0)
  wingridgal = boxtools.readwin(winfile,nx,ny,nz,lx,ly,lz)

########################################################################
# Measure the auto- and cross-power spectrum multipoles.               #
########################################################################

  pk0gal,pk2gal,pk4gal,pk0dens,pk2dens,pk4dens,pk0cross,pk2cross,pk4cross,pk0errgal,pk2errgal,pk4errgal,pk0errdens,pk2errdens,pk4errdens,pk0errcross,pk2errcross,pk4errcross,pk0congal,pk2congal,pk4congal,pk0condens,pk2condens,pk4condens,pk0concross,pk2concross,pk4concross = measpk.measpk(doconv,galgrid,wingridgal,densgrid,wingriddens,nx,ny,nz,lx,ly,lz,x0,y0,z0,kmin,kmax,nkbin,kmod,pkmod,betagal,betadens,sigvgal,sigvdens,bgal,bdens,pknoise,dobeam,sigdeg,lwin,pixwin,dzbin,cosmo)

########################################################################
# Read in power spectrum dataset (if it has been written out).         #
########################################################################

#  pkfile = 'pkpole.dat'
#  kmin,kmax,nkbin,kbin,pk0gal,pk2gal,pk4gal,pk0dens,pk2dens,pk4dens,pk0cross,pk2cross,pk4cross,pk0errgal,pk2errgal,pk4errgal,pk0errdens,pk2errdens,pk4errdens,pk0errcross,pk2errcross,pk4errcross,pk0modgal,pk2modgal,pk4modgal,pk0moddens,pk2moddens,pk4moddens,pk0modcross,pk2modcross,pk4modcross,pk0congal,pk2congal,pk4congal,pk0condens,pk2condens,pk4condens,pk0concross,pk2concross,pk4concross = pktools.readpolecross(pkfile)

########################################################################
# Convert from multipoles to P(k,mu) or P(kperp,kpar).                 #
########################################################################

  if ((binopt == 2) or (binopt == 3)):
    if (binopt == 2):
      nmu = nwedge
    else:
      nmu = 10
    pkmugal,pkmuerrgal,pkmucongal = pktools.pkpoletopkmu(nmu,pk0gal,pk2gal,pk4gal,pk0errgal,pk2errgal,pk4errgal,pk0congal,pk2congal,pk4congal)
    pkmudens,pkmuerrdens,pkmucondens = pktools.pkpoletopkmu(nmu,pk0dens,pk2dens,pk4dens,pk0errdens,pk2errdens,pk4errdens,pk0condens,pk2condens,pk4condens)
    pkmucross,pkmuerrcross,pkmuconcross = pktools.pkpoletopkmu(nmu,pk0cross,pk2cross,pk4cross,pk0errcross,pk2errcross,pk4errcross,pk0concross,pk2concross,pk4concross)
    if (binopt == 3):
      pk2dgal,pk2derrgal,pk2dcongal = pktools.pkmutopk2(kmin2,kmax2,nk2d,kmin,kmax,nkbin,nmu,pkmugal,pkmuerrgal,pkmucongal)
      pk2ddens,pk2derrdens,pk2dcondens = pktools.pkmutopk2(kmin2,kmax2,nk2d,kmin,kmax,nkbin,nmu,pkmudens,pkmuerrdens,pkmucondens)
      pk2dcross,pk2derrcross,pk2dconcross = pktools.pkmutopk2(kmin2,kmax2,nk2d,kmin,kmax,nkbin,nmu,pkmucross,pkmuerrcross,pkmuconcross)

########################################################################
# Plot power spectra.                                                  #
########################################################################

  ncase = 3
  labelcase = ['$P_{gg}$','$P_{TT}$','$P_{gT}$']
  if (binopt == 1):
    pk0case,pk0errcase,pk0concase,pk2case,pk2errcase,pk2concase,pk4case,pk4errcase,pk4concase = np.empty((ncase,nkbin)),np.empty((ncase,nkbin)),np.empty((ncase,nkbin)),np.empty((ncase,nkbin)),np.empty((ncase,nkbin)),np.empty((ncase,nkbin)),np.empty((ncase,nkbin)),np.empty((ncase,nkbin)),np.empty((ncase,nkbin))
    pk0case[0,:],pk0errcase[0,:],pk0concase[0,:] = pk0gal,pk0errgal,pk0congal
    pk2case[0,:],pk2errcase[0,:],pk2concase[0,:] = pk2gal,pk2errgal,pk2congal
    pk4case[0,:],pk4errcase[0,:],pk4concase[0,:] = pk4gal,pk4errgal,pk4congal
    pk0case[1,:],pk0errcase[1,:],pk0concase[1,:] = pk0dens,pk0errdens,pk0condens
    pk2case[1,:],pk2errcase[1,:],pk2concase[1,:] = pk2dens,pk2errdens,pk2condens
    pk4case[1,:],pk4errcase[1,:],pk4concase[1,:] = pk4dens,pk4errdens,pk4condens
    pk0case[2,:],pk0errcase[2,:],pk0concase[2,:] = pk0cross,pk0errcross,pk0concross
    pk2case[2,:],pk2errcase[2,:],pk2concase[2,:] = pk2cross,pk2errcross,pk2concross
    pk4case[2,:],pk4errcase[2,:],pk4concase[2,:] = pk4cross,pk4errcross,pk4concross
    pktools.plotpkpole(kmin,kmax,nkbin,pk0case,pk0errcase,pk0concase,pk2case,pk2errcase,pk2concase,pk4case,pk4errcase,pk4concase,labelcase)
  elif (binopt == 2):
    pkmucase,pkmuerrcase,pkmuconcase = np.empty((ncase,nkbin,nwedge)),np.empty((ncase,nkbin,nwedge)),np.empty((ncase,nkbin,nwedge))
    pkmucase[0,:,:],pkmuerrcase[0,:,:],pkmuconcase[0,:,:] = pkmugal,pkmuerrgal,pkmucongal
    pkmucase[1,:,:],pkmuerrcase[1,:,:],pkmuconcase[1,:,:] = pkmudens,pkmuerrdens,pkmucondens
    pkmucase[2,:,:],pkmuerrcase[2,:,:],pkmuconcase[2,:,:] = pkmucross,pkmuerrcross,pkmuconcross
    pktools.plotpkwedge(nwedge,kmin,kmax,nkbin,pkmucase,pkmuerrcase,pkmuconcase,labelcase)
  elif (binopt == 3):
    pk2dcase,pk2derrcase,pk2dconcase = np.empty((ncase,nk2d,nk2d)),np.empty((ncase,nk2d,nk2d)),np.empty((ncase,nk2d,nk2d))
    pk2dcase[0,:,:],pk2derrcase[0,:,:],pk2dconcase[0,:,:] = pk2dgal,pk2derrgal,pk2dcongal
    pk2dcase[1,:,:],pk2derrcase[1,:,:],pk2dconcase[1,:,:] = pk2ddens,pk2derrdens,pk2dcondens
    pk2dcase[2,:,:],pk2derrcase[2,:,:],pk2dconcase[2,:,:] = pk2dcross,pk2derrcross,pk2dconcross
    pktools.plotpk2d(kmin2,kmax2,nk2d,pk2dcase,pk2derrcase,pk2dconcase,labelcase)
  return
Example #10
0
hz = cosmo.H( boxRedshift ).value / 100.

# m sigma relation using the sigma8 corrected power spectrum
m2sigma = interp1d(hf.M, hf.sigma )

# m nu relation: nu = (delta_c / sigma_m)**2
m2nu = interp1d(hf.M, hf.nu )

# jacobian
toderive = interp1d(n.log(hf.M), n.log(hf.sigma))
mass=hf.M[100:-100]
dlnsigmadlnm = derivative(toderive, n.log(mass) )
# in units (Msun/h) / (Mpc/h)**3

ftC16 = f_BH(hf.sigma[100:-100], 0.279, 0.908, 0.671, 1.737)
rhom_units = cosmo.Om(boxRedshift)*cosmo.critical_density(boxRedshift).to(u.solMass/(u.Mpc)**3.)#/(cosmo.h)**2.
rhom = rhom_units.value # hf.mean_density#/(hz)**2. 



MF_MD = interp1d(mass, ftC16*rhom*abs(dlnsigmadlnm)/mass)

NpartMin = 50.
p_init = (-1.85, 7., -2.3, 4.)

mp04 = n.log10(NpartMin*9.63 * 10**7)
mp10 = n.log10(NpartMin*1.51 * 10**9)
mp25 = n.log10(NpartMin*2.359 * 10**10)
mp40 = n.log10(NpartMin*9.6 * 10**10. )

# fitting function