Ejemplo n.º 1
0
def psvariance(R, W='th',low = 1e-7,high=100,z=0):
    """
    Variance of the linear power spectrum. Use the
    power spectrum from COMPOS (Ziang Yen). Numerically
    and obtains the variance.
    Parameters
    ----------
    R: float
        Smoothing radius
    W: string, optional
        Form of the normalised window function.
        'th' for top-hat profile and 'ga' for
        gaussian.
    low: float, optional
        Lower integration limit to get the variance
    high: float, optional
        Upper integration limit
    z: float, optional
        Redshift. Defualt value is 0.
    Returns
    -------
    variance: float
        Variance of the smoothed ps.
    error: float
        Error incurred in variance from numerical integration
    """
    import numpy as np
    from scipy.integrate import quad
    from compos import const, matterps

    const.initializecosmo(z=z)
    integrand = lambda k: (k*window_th(k,R))**2*matterps.normalizedmp(k)
    integral = quad(integrand,low,high)
    variance = integral[0]/(2*np.pi)**2
    error = integral[1]/(2*np.pi)**2
    return variance, error
Ejemplo n.º 2
0
# This script calculates linear matter power spectrum at
# z = 0 with a given set of cosmologycal parameters#

import numpy as np
import matplotlib.pyplot as mp

from compos import const, matterps

const.initializecosmo()

k = np.linspace(-4, np.log10(6.71600e+02), 10000)
k = 10**k * const.cosmo['h']
p = matterps.normalizedmp(k)

# p_nw = matterps.normalizedmpnw(k)

mp.loglog(k / const.cosmo['h'], p * const.cosmo['h']**3)
plottextl = mp.xlim()[0] * 2
plottextd = mp.ylim()[0] * 2
mp.text(plottextl,
        plottextd,
        r'$h = $' + str(const.cosmo['h']) + ', $\Omega_mh^2$ = ' +
        str(const.cosmo['omega_0'] * const.cosmo['h']**2) +
        ', $\Omega_bh^2$ = ' +
        str(const.cosmo['omega_b'] * const.cosmo['h']**2),
        fontsize=15)
mp.ylabel('P(k)(h$^{-3}$Mpc$^{-3}$)')
mp.xlabel('k (h Mpc$^{-1}$)')
mp.savefig('../../results/matterps/mps.jpg')
mp.savefig('../../results/matterps/mps.pdf')
mp.show()
Ejemplo n.º 3
0
const.initializecosmo()

x = np.linspace(-4, 1, 1000)
k = 10 ** x
d2 = growthfactor.growfunc_z(10)
d1 = growthfactor.growfunc_z(5)
pyhalofit.supparams(growthf=d2)
np2 = pyhalofit.nlpowerspec(k, 10)
pyhalofit.supparams(growthf=d1)
np1 = pyhalofit.nlpowerspec(k, 5)
pyhalofit.supparams()
np0 = pyhalofit.nlpowerspec(k, 0)
t = np.zeros((2, np.size(k)))

p2 = matterps.normalizedmp(k, 10)
p1 = matterps.normalizedmp(k, 5)
p0 = matterps.normalizedmp(k, 0)

mp.loglog(k/const.cosmo['h'], np0, label='nonlinear, z=0')
mp.loglog(k/const.cosmo['h'], p0, label='linear, z=0')
mp.loglog(k/const.cosmo['h'], np1, label='nonlinear,z=5')
mp.loglog(k/const.cosmo['h'], p1, label='linear,z=5')
mp.loglog(k/const.cosmo['h'], np2, label='nonlinear,z=10')
mp.loglog(k/const.cosmo['h'], p2, label='linear,z=10')
mp.text(0.001, 0.1, '$h = 0.7, \Omega_mh^2$=' +
        str(const.cosmo['omega_0']*const.cosmo['h']**2) +
        ',$ \Omega_qh^2 = $' + str(const.cosmo['omega_q'] *
                                   const.cosmo['h']**2)+',', fontsize=15)
mp.text(0.001, 0.01, '$w_0 = -1,w_1 = 0$', fontsize=15)
mp.legend(fontsize=10)
Ejemplo n.º 4
0
# This script calculates linear matter power spectrum at
# z = 0 with a given set of cosmologycal parameters#

import numpy as np
import matplotlib.pyplot as mp

from compos import const, matterps

const.initializecosmo()

k = np.linspace(-4, np.log10(6.71600e+02), 10000)
k = 10 ** k * const.cosmo['h']
p = matterps.normalizedmp(k)

# p_nw = matterps.normalizedmpnw(k)

mp.loglog(k / const.cosmo['h'], p * const.cosmo['h'] ** 3)
plottextl = mp.xlim()[0] * 2
plottextd = mp.ylim()[0] * 2
mp.text(plottextl, plottextd, r'$h = $' + str(const.cosmo['h']) +
        ', $\Omega_mh^2$ = '+str(const.cosmo['omega_0'] *
                                 const.cosmo['h'] ** 2) +
        ', $\Omega_bh^2$ = '+str(const.cosmo['omega_b'] *
                                 const.cosmo['h'] ** 2), fontsize=15)
mp.ylabel('P(k)(h$^{-3}$Mpc$^{-3}$)')
mp.xlabel('k (h Mpc$^{-1}$)')
mp.savefig('../../results/matterps/mps.jpg')
mp.savefig('../../results/matterps/mps.pdf')
mp.show()
Ejemplo n.º 5
0
const.initializecosmo()

x = np.linspace(-4, 1, 1000)
k = 10**x
d2 = growthfactor.growfunc_z(10)
d1 = growthfactor.growfunc_z(5)
pyhalofit.supparams(growthf=d2)
np2 = pyhalofit.nlpowerspec(k, 10)
pyhalofit.supparams(growthf=d1)
np1 = pyhalofit.nlpowerspec(k, 5)
pyhalofit.supparams()
np0 = pyhalofit.nlpowerspec(k, 0)
t = np.zeros((2, np.size(k)))

p2 = matterps.normalizedmp(k, 10)
p1 = matterps.normalizedmp(k, 5)
p0 = matterps.normalizedmp(k, 0)

mp.loglog(k / const.cosmo['h'], np0, label='nonlinear, z=0')
mp.loglog(k / const.cosmo['h'], p0, label='linear, z=0')
mp.loglog(k / const.cosmo['h'], np1, label='nonlinear,z=5')
mp.loglog(k / const.cosmo['h'], p1, label='linear,z=5')
mp.loglog(k / const.cosmo['h'], np2, label='nonlinear,z=10')
mp.loglog(k / const.cosmo['h'], p2, label='linear,z=10')
mp.text(0.001,
        0.1,
        '$h = 0.7, \Omega_mh^2$=' +
        str(const.cosmo['omega_0'] * const.cosmo['h']**2) +
        ',$ \Omega_qh^2 = $' +
        str(const.cosmo['omega_q'] * const.cosmo['h']**2) + ',',