Example #1
0
File: mps.py Project: dyskun/C2SNR
def nonlin_ps(z, l_max):
    pars_nl = model.CAMBparams(NonLinear=1,
                               WantTransfer=True,
                               H0=h * 100,
                               omch2=omch2,
                               ombh2=ombh2,
                               YHe=YHe)
    pars_nl.DarkEnergy.set_params(w=-1.13)
    pars_nl.set_for_lmax(lmax=l_max)
    pars_nl.InitPower.set_params(ns=ns, As=2.196e-09)
    results = camb.get_background(pars_nl)
    PK_nl = get_matter_power_interpolator(pars_nl,
                                          nonlinear=True,
                                          kmax=k_max(z, l_max),
                                          k_hunit=True,
                                          hubble_units=True)
    return PK_nl.P(z, k)
Example #2
0
def nonlin_ps(z, l_max):
    pars_nl = model.CAMBparams(NonLinear=1,
                               WantTransfer=True,
                               H0=67.3,
                               omch2=0.1199,
                               ombh2=0.02205,
                               YHe=0.24770)
    pars_nl.DarkEnergy.set_params(w=-1.13)
    pars_nl.set_for_lmax(lmax=l_max)
    pars_nl.InitPower.set_params(ns=0.9603, As=2.196e-09)
    results = camb.get_background(pars_nl)
    k = 10**np.linspace(-6, k_lim(z, l_max), 1000)
    return get_matter_power_interpolator(pars_nl,
                                         nonlinear=True,
                                         kmax=k_max(z, l_max),
                                         k_hunit=True,
                                         hubble_units=True)
Example #3
0
def cps(z):
    pars = model.CAMBparams(NonLinear=1,
                            WantTransfer=True,
                            H0=67.3,
                            omch2=0.1199,
                            ombh2=0.02205,
                            YHe=0.24770)
    pars.DarkEnergy.set_params(w=-1.13)
    #pars.set_for_lmax(lmax = l_max)
    pars.InitPower.set_params(ns=0.9603, As=2.196e-09)
    results = camb.get_background(pars)
    PK = get_matter_power_interpolator(pars,
                                       nonlinear=True,
                                       kmax=10,
                                       k_hunit=True,
                                       hubble_units=True)
    PK.P(z, k)
    return PK.P(z, k)
Example #4
0
## Arrays
########################################################################

### angular power spectrum
#-- signal
C_l_array = np.zeros(int(2**0.5 * l_ul))
#------------------------------------------------------------------------

########################################################################
## CAMB
########################################################################
#print('********k_max**********{}'.format(k_max(l_ul, z_s)))

pars = model.CAMBparams(NonLinear=0,
                        WantTransfer=True,
                        H0=100 * h,
                        omch2=omegach2,
                        ombh2=omegabh2,
                        YHe=YHe)
pars.DarkEnergy.set_params(w=-1)
pars.set_for_lmax(lmax=l_ul)
pars.InitPower.set_params(ns=ns, As=As)
#results = camb.get_background(pars)
results = camb.get_results(pars)
#print(results.get_sigma8()) #-- 0.84166148
k = np.linspace(10**(-5), k_max(l_ul, z_s), 1000)
#print()
PK = get_matter_power_interpolator(pars,
                                   nonlinear=False,
                                   kmax=np.max(k),
                                   k_hunit=False,
                                   hubble_units=False)
Example #5
0
H0 = 67.3 * 1000
h = 0.673
cosmo = {
    'omega_M_0': omegam0,
    'omega_lambda_0': omegal,
    'omega_k_0': 0.0,
    'h': 0.673
}
l_plot_low_limit = 10
l_plot_upp_limit = 600
redshift = 2
l_max = 600

pars = model.CAMBparams(NonLinear=0,
                        WantTransfer=True,
                        H0=67.3,
                        omch2=0.1199,
                        ombh2=0.02205,
                        YHe=0.24770)
pars.DarkEnergy.set_params(w=-1.13)
pars.set_for_lmax(lmax=l_max)
pars.InitPower.set_params(ns=0.9603, As=2.196e-09)
results = camb.get_background(pars)
k = 10**np.linspace(-6, 1, 1000)
PK = get_matter_power_interpolator(pars,
                                   nonlinear=False,
                                   kmax=1,
                                   k_hunit=True,
                                   hubble_units=True)

pars_nl = model.CAMBparams(NonLinear=1,
                           WantTransfer=True,
Example #6
0
    'omega_lambda_0': omegal,
    'omega_k_0': 0.0,
    'h': 0.673
}
l_plot_low_limit = 10
l_plot_upp_limit = 550
two_pi_squared = 2 * 3.14 * 2 * 3.14
eta = 0
eta_D2_L = 5.94 * 10**12 / 10**eta
redshift = 1
l_max = l_plot_upp_limit

pars = model.CAMBparams(NonLinear=1,
                        WantTransfer=True,
                        H0=67.3,
                        omch2=0.1199,
                        ombh2=0.02205,
                        YHe=0.24770,
                        Do21cm=True,
                        transfer_21cm_cl=True)
pars.DarkEnergy.set_params(w=-1.13)
pars.set_for_lmax(lmax=2500)
pars.InitPower.set_params(ns=0.9603, As=2.196e-09)
results = camb.get_background(pars)
k = np.exp(np.log(10) * np.linspace(-6, 1, 1000))
PK = get_matter_power_interpolator(pars, nonlinear=True, kmax=2)
#------------------------------------------------------------------------------

###############################################################################
# Arrays
###############################################################################
Example #7
0
File: z-8.py Project: dyskun/C2SNR
#------------------------------------------------------------------------------

##############################################################################
# Constants
###############################################################################
omegam0 = 0.315
omegal = 0.685
c = 3 * 10**8
h = 0.673
H0 = 100 * h * 1000 # m s**(-1) / Mpc units
cosmo = {'omega_M_0': omegam0, 'omega_lambda_0': omegal, 'omega_k_0': 0.0, 'h': h}
redshift = 8.15

tz, k = np.loadtxt('/home/dyskun/Documents/Utility/Git/Msaharan/C2SNR/C2/data-files/tz_z8_fine.txt', unpack = True)

pars = model.CAMBparams(NonLinear = 1, WantTransfer = True, H0 = 100 * h, omch2=0.1199, ombh2=0.02205, YHe = 0.24770)
pars.DarkEnergy.set_params(w=-1.13)
#pars.set_for_lmax(lmax = l_max)
pars.InitPower.set_params(ns=0.9603, As = 2.196e-09)
results = camb.get_background(pars)
PK = get_matter_power_interpolator(pars, nonlinear=True, kmax = np.max(k), k_hunit = True, hubble_units = True)

l_min = int(np.min(k) * distance(redshift))
l_max = ellmax

delta_l = 36
f_sky = 0.2
l_plot_low_limit = l_min
l_plot_upp_limit = 1000
err_stepsize = errstep
n_err_points = 1 + int((l_plot_upp_limit - l_plot_low_limit)/err_stepsize)
Example #8
0
#-- that there will be big change in the results so I am proceeding with these values.
#--
#-- k_unit = True -> input of k will be in h/Mpc units
#-- hubble_units = True -> output power spectrum PK.P(k, z) will be in Mpc/h units.
#--
#-- The k/PK business is very confusing because ZZ_2006 or P_2014 might have used
#-- k and PK with or without the h units. I once tried to find it out but my tests were poorly 
#-- structured so I couldn't quite find out which one they have used. I was trying 
#-- different h, true, false combinations to see which combination gives the best match 
#-- with the plot from P_2014.
#-- See the tests in: 
#-- C2SNR/tree/master/archive/Pow_spec_test_code/All_tests/Comparison_angpowspec_with_pourtsidou
#-- or if you can't find them there, check the permanent location:
#-- C2SNR/tree/before_archive_20201002/Pow_spec_test_code/All_tests/Comparison_angpowspec_with_pourtsidou

pars = model.CAMBparams(NonLinear = 1, WantTransfer = True, H0 = 100 * h, omch2=omegach2, ombh2=omegabh2) #-- H0 in kms^-1/Mpc as per the documentation
pars.DarkEnergy.set_params(w=-1.13)
pars.set_for_lmax(lmax = l_max)
pars.InitPower.set_params(ns=ns) # ZZ_2006 took n = 1 and sigma_8 = 0.9
results = camb.get_background(pars)
k = 10**np.linspace(-5,k_max(l_max, z_s),1000)
PK = get_matter_power_interpolator(pars, nonlinear=True, kmax = k_max(l_max, z_s), k_hunit = False, hubble_units = False)

#------------------------ CAMB parameters end --------------------------------

########################################################################
## compute and store data
########################################################################

#-- dist_s = distance between the observer and the emitter (harmless => global parameter)
Example #9
0
l_array = np.zeros(l_max - l_min)
#------------------------------------------------------------------------------

###############################################################################
# CAMB
###############################################################################
# This works
# pars1 = model.CAMBparams(NonLinear = 1, WantTransfer = True, H0=67.3, omch2=0.1199, ombh2= 0.02205, YHe = 0.24770, Do21cm = True, transfer_21cm_cl = True)

# This also works
# pars1 = model.CAMBparams(NonLinear = 1, WantTransfer = True, H0=67.3, omch2=0.1199, ombh2= 0.02205, YHe = 0.24770, Do21cm = True)

# This also works
pars1 = model.CAMBparams(NonLinear=1,
                         WantTransfer=True,
                         H0=67.3,
                         omch2=0.1199,
                         ombh2=0.02205,
                         YHe=0.24770)

# All the three options (of pars1) give the same result.
# See: C2SNR/Pow_spec_test_code/All_tests/Camb_21cm_true_vs_false

pars1.DarkEnergy.set_params(w=-1.13)
pars1.set_for_lmax(lmax=2500)
pars1.InitPower.set_params(ns=0.9603, As=2.196e-09)
results = camb.get_background(pars1)
k = 10**np.linspace(-6, 1, 1000)
PK1 = get_matter_power_interpolator(pars1, nonlinear=True, kmax=2)

# This doesn't work
#pars2 = model.CAMBparams(NonLinear = 2, WantTransfer = True, H0=67.3, omch2=0.1199, ombh2= 0.02205, YHe = 0.24770, Do21cm = True, transfer_21cm_cl = True)
Example #10
0
h = 0.732
c = 3 * 10**8

cosmo = {
    'omega_M_0': omegam0,
    'omega_lambda_0': omegal,
    'omega_k_0': 0.0,
    'h': h
}
l_min = 10
l_max = 5172  # max value in Valageas's plot
redshift = 1

pars = model.CAMBparams(NonLinear=0,
                        WantTransfer=True,
                        H0=73.2,
                        omch2=0.1140,
                        ombh2=0.02415)
pars.DarkEnergy.set_params(w=-1.0)
pars.set_for_lmax(lmax=l_max)
pars.InitPower.set_params(ns=0.958, As=2.35e-09)
results = camb.get_background(pars)
k = 10**np.linspace(-6, 1, 1000)
PK = get_matter_power_interpolator(pars,
                                   nonlinear=False,
                                   kmax=4,
                                   k_hunit=False,
                                   hubble_units=False)

l_max_nl = 120000
pars_nl = model.CAMBparams(NonLinear=1,
Example #11
0
    k_lim = 1
elif k_max > 10 and k_max <= 100:
    k_lim = 2
elif k_max > 100 and k_max <= 1000:
    k_lim = 3
elif k_max > 1000 and k_max <= 10000:
    k_lim = 4
#------------------------------------------------------------------------------

##############################################################################
# Generate power spectrum using CAMB
###############################################################################
# Linear
pars = model.CAMBparams(NonLinear=0,
                        WantTransfer=True,
                        H0=h * 100,
                        omch2=omch2,
                        ombh2=ombh2,
                        YHe=YHe)
pars.DarkEnergy.set_params(w=-1.13)
pars.set_for_lmax(lmax=l_max)
pars.InitPower.set_params(ns=ns, As=2.196e-09)
results = camb.get_background(pars)
k = np.arange(10**(-2), k_max, 0.1)
PK = get_matter_power_interpolator(pars,
                                   nonlinear=False,
                                   kmax=k_max,
                                   k_hunit=True,
                                   hubble_units=True)

# Non-linear
pars_nl = model.CAMBparams(NonLinear=1,