CosmoWAP 0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cosmo_wap/__init__.py +1 -0
- cosmo_wap/bk/GR0.py +29 -0
- cosmo_wap/bk/GR1.py +85 -0
- cosmo_wap/bk/GR2.py +27 -0
- cosmo_wap/bk/GR_0.py +16 -0
- cosmo_wap/bk/GR_1.py +17 -0
- cosmo_wap/bk/GR_2.py +17 -0
- cosmo_wap/bk/PNG_terms.py +15 -0
- cosmo_wap/bk/RR1.py +100 -0
- cosmo_wap/bk/RR2.py +30 -0
- cosmo_wap/bk/RR_1.py +14 -0
- cosmo_wap/bk/WA1.py +108 -0
- cosmo_wap/bk/WA2.py +30 -0
- cosmo_wap/bk/WARR.py +33 -0
- cosmo_wap/bk/WA_1.py +19 -0
- cosmo_wap/bk/WA_2.py +16 -0
- cosmo_wap/bk/WSGR.py +61 -0
- cosmo_wap/bk/__init__.py +0 -0
- cosmo_wap/bk/cov.py +60 -0
- cosmo_wap/data_library/SKAO1Data.txt +10 -0
- cosmo_wap/data_library/SKAO2Data.txt +20 -0
- cosmo_wap/data_library/snr_surveyparams.txt +14 -0
- cosmo_wap/integrate.py +43 -0
- cosmo_wap/main.py +379 -0
- cosmo_wap/peak_background_bias.py +291 -0
- cosmo_wap/pk/Pk_0.py +109 -0
- cosmo_wap/pk/Pk_WS.py +172 -0
- cosmo_wap/pk/Pk_WSGR.py +82 -0
- cosmo_wap/pk/__init__.py +0 -0
- cosmo_wap/survey_params.py +133 -0
- cosmo_wap/useful_funcs.py +52 -0
- cosmowap-0.0.2.dist-info/LICENSE.txt +21 -0
- cosmowap-0.0.2.dist-info/METADATA +111 -0
- cosmowap-0.0.2.dist-info/RECORD +36 -0
- cosmowap-0.0.2.dist-info/WHEEL +5 -0
- cosmowap-0.0.2.dist-info/top_level.txt +1 -0
cosmo_wap/pk/Pk_WSGR.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import scipy
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#2nd order terms
|
|
6
|
+
class WAGR:
|
|
7
|
+
def l0(cosmo_functions,k1,zz=0,t=0,sigma=0,nonlin=False):
|
|
8
|
+
k1,Pk,Pkd,Pkdd,d,f,D1 = cosmo_functions.get_params_pk(k1,zz,nonlinear=nonlin)
|
|
9
|
+
|
|
10
|
+
b1 = cosmo_functions.survey.b_1(zz)
|
|
11
|
+
xb1 = cosmo_functions.survey1.b_1(zz)
|
|
12
|
+
|
|
13
|
+
gr1,gr2,grd1,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_ = cosmo_functions.get_beta_funcs(zz,tracer = cosmo_functions.survey)
|
|
14
|
+
xgr1,xgr2,xgrd1,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_ = cosmo_functions.get_beta_funcs(zz,tracer = cosmo_functions.survey1)
|
|
15
|
+
|
|
16
|
+
expr = -2*D1**2*(Pk + Pkd*k1)*(-5*b1*xgr1*(t - 1) + f*(gr1*(3*t - 2) - 3*t*xgr1 + xgr1) + 5*gr1*t*xb1)/(15*d*k1**2)
|
|
17
|
+
|
|
18
|
+
Erf = scipy.special.erf
|
|
19
|
+
if sigma != 0:
|
|
20
|
+
expr = D1**2*(2*f*sigma*(2*Pk*(sigma**2 + 6) - 3*Pkd*k1)*(gr1*(3*t - 2) - 3*t*xgr1 + xgr1) + 2*sigma**3*(2*Pk - Pkd*k1)*(-b1*xgr1*(t - 1) + gr1*t*xb1) + np.sqrt(2)*np.sqrt(np.pi)*(f*(2*Pk*(sigma**2 - 6) - Pkd*k1*(sigma**2 - 3))*(gr1*(3*t - 2) - 3*t*xgr1 + xgr1) - sigma**2*(2*Pk + Pkd*k1*(sigma**2 - 1))*(-b1*xgr1*(t - 1) + gr1*t*xb1))*Erf(np.sqrt(2)*sigma/2)*np.exp(sigma**2/2))*np.exp(-sigma**2/2)/(2*d*k1**2*sigma**5)
|
|
21
|
+
|
|
22
|
+
return expr
|
|
23
|
+
|
|
24
|
+
def l2(cosmo_functions,k1,zz=0,t=0,sigma=0,nonlin=False):
|
|
25
|
+
k1,Pk,Pkd,Pkdd,d,f,D1 = cosmo_functions.get_params_pk(k1,zz,nonlinear=nonlin)
|
|
26
|
+
|
|
27
|
+
b1 = cosmo_functions.survey.b_1(zz)
|
|
28
|
+
xb1 = cosmo_functions.survey1.b_1(zz)
|
|
29
|
+
|
|
30
|
+
gr1,gr2,grd1,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_ = cosmo_functions.get_beta_funcs(zz,tracer = cosmo_functions.survey)
|
|
31
|
+
xgr1,xgr2,xgrd1,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_ = cosmo_functions.get_beta_funcs(zz,tracer = cosmo_functions.survey1)
|
|
32
|
+
|
|
33
|
+
expr = -2*D1**2*(f*(10*Pk + Pkd*k1)*(gr1*(3*t - 2) - 3*t*xgr1 + xgr1) + 7*(2*Pk - Pkd*k1)*(-b1*xgr1*(t - 1) + gr1*t*xb1))/(21*d*k1**2)
|
|
34
|
+
|
|
35
|
+
Erf = scipy.special.erf
|
|
36
|
+
if sigma != 0:
|
|
37
|
+
expr = 5*D1**2*(2*sigma*(f*(2*Pk*(2*sigma**4 + 15*sigma**2 + 90) - 3*Pkd*k1*(sigma**2 + 15))*(gr1*(3*t - 2) - 3*t*xgr1 + xgr1) + sigma**2*(2*Pk*(2*sigma**2 + 9) + Pkd*k1*(sigma**2 - 9))*(-b1*xgr1*(t - 1) + gr1*t*xb1)) + np.sqrt(2)*np.sqrt(np.pi)*(-f*(2*Pk*(sigma**4 - 15*sigma**2 + 90) - Pkd*k1*(sigma**4 - 12*sigma**2 + 45))*(gr1*(3*t - 2) - 3*t*xgr1 + xgr1) + sigma**2*(2*Pk*(sigma**2 - 9) + Pkd*k1*(sigma**4 - 4*sigma**2 + 9))*(-b1*xgr1*(t - 1) + gr1*t*xb1))*Erf(np.sqrt(2)*sigma/2)*np.exp(sigma**2/2))*np.exp(-sigma**2/2)/(4*d*k1**2*sigma**7)
|
|
38
|
+
|
|
39
|
+
return expr
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class RRGR:
|
|
43
|
+
def l0(cosmo_functions,k1,zz=0,t=0,sigma=0,nonlin=False):
|
|
44
|
+
k1,Pk,Pkd,Pkdd,d,f,D1 = cosmo_functions.get_params_pk(k1,zz,nonlinear=nonlin)
|
|
45
|
+
|
|
46
|
+
b1 = cosmo_functions.survey.b_1(zz)
|
|
47
|
+
xb1 = cosmo_functions.survey1.b_1(zz)
|
|
48
|
+
|
|
49
|
+
gr1,gr2,grd1,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_ = cosmo_functions.get_beta_funcs(zz,tracer = cosmo_functions.survey)
|
|
50
|
+
xgr1,xgr2,xgrd1,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_ = cosmo_functions.get_beta_funcs(zz,tracer = cosmo_functions.survey1)
|
|
51
|
+
|
|
52
|
+
fd,Dd,_,_,bd1,fdd,Ddd,_,_,bdd1 = cosmo_functions.get_derivs(zz,tracer = cosmo_functions.survey)
|
|
53
|
+
fd,Dd,_,_,xbd1,fdd,Ddd,_,_,xbdd1 = cosmo_functions.get_derivs(zz,tracer = cosmo_functions.survey1)
|
|
54
|
+
|
|
55
|
+
expr = -D1*(Pk + Pkd*k1)*(D1*(-5*b1*t*xgrd1 + 5*b1*xgrd1 - 5*bd1*t*xgr1 + 3*f*(grd1*t - t*xgrd1 + xgrd1) + 3*fd*gr1*(t - 1) - 3*fd*t*xgr1 + 5*gr1*xbd1*(t - 1) + 5*grd1*t*xb1) + Dd*(2*t - 1)*(-5*b1*xgr1 + 3*f*(gr1 - xgr1) + 5*gr1*xb1))/(15*d*k1**2)
|
|
56
|
+
|
|
57
|
+
Erf = scipy.special.erf
|
|
58
|
+
if sigma != 0:
|
|
59
|
+
expr = D1*(-2*sigma*(D1*(f*(Pk*(sigma**2 + 12) - Pkd*k1*(sigma**2 + 3))*(grd1*t - t*xgrd1 + xgrd1) + fd*(Pk*(sigma**2 + 12) - Pkd*k1*(sigma**2 + 3))*(gr1*(t - 1) - t*xgr1) + sigma**2*(2*Pk - Pkd*k1)*(-b1*t*xgrd1 + b1*xgrd1 - bd1*t*xgr1 + gr1*xbd1*(t - 1) + grd1*t*xb1)) + Dd*(2*t - 1)*(f*(gr1 - xgr1)*(Pk*(sigma**2 + 12) - Pkd*k1*(sigma**2 + 3)) + sigma**2*(2*Pk - Pkd*k1)*(-b1*xgr1 + gr1*xb1))) + np.sqrt(2)*np.sqrt(np.pi)*(D1*(-3*f*(Pk*(sigma**2 - 4) + Pkd*k1)*(grd1*t - t*xgrd1 + xgrd1) - 3*fd*(Pk*(sigma**2 - 4) + Pkd*k1)*(gr1*(t - 1) - t*xgr1) - sigma**2*(Pk*(sigma**2 - 2) + Pkd*k1)*(-b1*t*xgrd1 + b1*xgrd1 - bd1*t*xgr1 + gr1*xbd1*(t - 1) + grd1*t*xb1)) - Dd*(2*t - 1)*(3*f*(gr1 - xgr1)*(Pk*(sigma**2 - 4) + Pkd*k1) + sigma**2*(Pk*(sigma**2 - 2) + Pkd*k1)*(-b1*xgr1 + gr1*xb1)))*Erf(np.sqrt(2)*sigma/2)*np.exp(sigma**2/2))*np.exp(-sigma**2/2)/(2*d*k1**2*sigma**5)
|
|
60
|
+
|
|
61
|
+
return expr
|
|
62
|
+
|
|
63
|
+
def l2(cosmo_functions,k1,zz=0,t=0,sigma=0,nonlin=False):
|
|
64
|
+
k1,Pk,Pkd,Pkdd,d,f,D1 = cosmo_functions.get_params_pk(k1,zz,nonlinear=nonlin)
|
|
65
|
+
|
|
66
|
+
b1 = cosmo_functions.survey.b_1(zz)
|
|
67
|
+
xb1 = cosmo_functions.survey1.b_1(zz)
|
|
68
|
+
|
|
69
|
+
gr1,gr2,grd1,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_ = cosmo_functions.get_beta_funcs(zz,tracer = cosmo_functions.survey)
|
|
70
|
+
xgr1,xgr2,xgrd1,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_ = cosmo_functions.get_beta_funcs(zz,tracer = cosmo_functions.survey1)
|
|
71
|
+
|
|
72
|
+
fd,Dd,_,_,bd1,fdd,Ddd,_,_,bdd1 = cosmo_functions.get_derivs(zz,tracer = cosmo_functions.survey)
|
|
73
|
+
fd,Dd,_,_,xbd1,fdd,Ddd,_,_,xbdd1 = cosmo_functions.get_derivs(zz,tracer = cosmo_functions.survey1)
|
|
74
|
+
|
|
75
|
+
expr = 2*D1*(D1*(3*f*(Pk - 2*Pkd*k1)*(grd1*t - t*xgrd1 + xgrd1) + 3*fd*(Pk - 2*Pkd*k1)*(gr1*(t - 1) - t*xgr1) + 7*(2*Pk - Pkd*k1)*(-b1*t*xgrd1 + b1*xgrd1 - bd1*t*xgr1 + gr1*xbd1*(t - 1) + grd1*t*xb1)) + Dd*(2*t - 1)*(3*f*(Pk - 2*Pkd*k1)*(gr1 - xgr1) + 7*(2*Pk - Pkd*k1)*(-b1*xgr1 + gr1*xb1)))/(21*d*k1**2)
|
|
76
|
+
|
|
77
|
+
Erf = scipy.special.erf
|
|
78
|
+
if sigma != 0:
|
|
79
|
+
expr = 5*D1*(-2*sigma*(D1*(f*(Pk*(2*sigma**4 + 21*sigma**2 + 180) - Pkd*k1*(2*sigma**4 + 12*sigma**2 + 45))*(grd1*t - t*xgrd1 + xgrd1) + fd*(Pk*(2*sigma**4 + 21*sigma**2 + 180) - Pkd*k1*(2*sigma**4 + 12*sigma**2 + 45))*(gr1*(t - 1) - t*xgr1) + sigma**2*(Pk*(sigma**2 + 18) - Pkd*k1*(2*sigma**2 + 9))*(-b1*t*xgrd1 + b1*xgrd1 - bd1*t*xgr1 + gr1*xbd1*(t - 1) + grd1*t*xb1)) + Dd*(2*t - 1)*(f*(gr1 - xgr1)*(Pk*(2*sigma**4 + 21*sigma**2 + 180) - Pkd*k1*(2*sigma**4 + 12*sigma**2 + 45)) + sigma**2*(Pk*(sigma**2 + 18) - Pkd*k1*(2*sigma**2 + 9))*(-b1*xgr1 + gr1*xb1))) + np.sqrt(2)*np.sqrt(np.pi)*(D1*(3*f*(Pk*(sigma**4 - 13*sigma**2 + 60) + Pkd*k1*(sigma**2 - 15))*(grd1*t - t*xgrd1 + xgrd1) + 3*fd*(Pk*(sigma**4 - 13*sigma**2 + 60) + Pkd*k1*(sigma**2 - 15))*(gr1*(t - 1) - t*xgr1) + sigma**2*(Pk*(sigma**4 - 5*sigma**2 + 18) + Pkd*k1*(sigma**2 - 9))*(-b1*t*xgrd1 + b1*xgrd1 - bd1*t*xgr1 + gr1*xbd1*(t - 1) + grd1*t*xb1)) + Dd*(2*t - 1)*(3*f*(gr1 - xgr1)*(Pk*(sigma**4 - 13*sigma**2 + 60) + Pkd*k1*(sigma**2 - 15)) + sigma**2*(Pk*(sigma**4 - 5*sigma**2 + 18) + Pkd*k1*(sigma**2 - 9))*(-b1*xgr1 + gr1*xb1)))*Erf(np.sqrt(2)*sigma/2)*np.exp(sigma**2/2))*np.exp(-sigma**2/2)/(4*d*k1**2*sigma**7)
|
|
80
|
+
|
|
81
|
+
return expr
|
|
82
|
+
|
cosmo_wap/pk/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from scipy.interpolate import interp1d
|
|
3
|
+
from scipy.integrate import odeint
|
|
4
|
+
|
|
5
|
+
# Define the path to the data file relative to the current script location
|
|
6
|
+
import os
|
|
7
|
+
module_dir = os.path.dirname(os.path.abspath(__file__))
|
|
8
|
+
SKAO1Data = np.loadtxt(os.path.join(module_dir, 'data_library/SKAO1Data.txt'))
|
|
9
|
+
SKAO2Data = np.loadtxt(os.path.join(module_dir, 'data_library/SKAO2Data.txt'))
|
|
10
|
+
|
|
11
|
+
class SurveyParams():
|
|
12
|
+
def __init__(self,cosmo):
|
|
13
|
+
"""
|
|
14
|
+
gets specifications for some saved surveys (namely linear bias and number density as well as evolution and
|
|
15
|
+
mangification biases
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
Euclid = {'b_1': lambda xx: 0.9 + 0.4*xx,
|
|
19
|
+
'f_sky': 15000/41253,
|
|
20
|
+
'z_survey': [0.9,1.8], #get zmin and zmax
|
|
21
|
+
'be_survey':lambda xx: -7.29 + 0.470*xx + 1.17*xx**2 - 0.290*xx**3,#euclid_data[:,2]
|
|
22
|
+
'Q_survey': lambda xx: 0.583 + 2.02*xx - 0.568*xx**2 + 0.0411*xx**3,
|
|
23
|
+
'n_g': lambda zz: 0.0193*zz**(-0.0282) *np.exp(-2.81*zz)}
|
|
24
|
+
|
|
25
|
+
#just need D(z)
|
|
26
|
+
baLCDM = cosmo.get_background()
|
|
27
|
+
D_cl = baLCDM['gr.fac. D']
|
|
28
|
+
z_cl = baLCDM['z']
|
|
29
|
+
D_intp = interp1d(z_cl,D_cl,kind='cubic')
|
|
30
|
+
|
|
31
|
+
BGS = {'b_1': lambda xx: 1.34/D_intp(xx),
|
|
32
|
+
'f_sky': 15000/41253,
|
|
33
|
+
'z_survey': [0.05,0.6],
|
|
34
|
+
'be_survey':lambda xx: -2.25 - 4.02*xx + 0.318*xx**2 - 14.6*xx**3,
|
|
35
|
+
'Q_survey': lambda xx: 0.282 + 2.36*xx + 2.27*xx**2 + 11.1*xx**3,
|
|
36
|
+
'n_g': lambda zz: 0.023*zz**(-0.471)*np.exp(-5.17*zz)-0.002} #fitting from Maartens
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
SKAO1= {'b_1': lambda xx: 0.616*np.exp(1.017*xx),
|
|
40
|
+
'f_sky': 5000/41253,
|
|
41
|
+
'z_survey': [SKAO1Data[:,0][0],SKAO1Data[:,0][-1]],
|
|
42
|
+
'be_survey': interp1d(SKAO1Data[:,0], SKAO1Data[:,4]),
|
|
43
|
+
'Q_survey': interp1d(SKAO1Data[:,0], SKAO1Data[:,3]),
|
|
44
|
+
'n_g': interp1d(SKAO1Data[:,0], SKAO1Data[:,2])} #fitting from Maartens
|
|
45
|
+
|
|
46
|
+
SKAO2= {'b_1': lambda xx: 0.554*np.exp(0.783*xx),
|
|
47
|
+
'f_sky': 30000/41253,
|
|
48
|
+
'z_survey': [SKAO2Data[:,0][0],SKAO2Data[:,0][-1]],
|
|
49
|
+
'be_survey': interp1d(SKAO2Data[:,0], SKAO2Data[:,4]),
|
|
50
|
+
'Q_survey': interp1d(SKAO2Data[:,0], SKAO2Data[:,3]),
|
|
51
|
+
'n_g': interp1d(SKAO2Data[:,0], SKAO2Data[:,2])} #fitting from Maartens
|
|
52
|
+
|
|
53
|
+
DM = {'b_1': lambda xx: 1 + 0*xx , # for dark matter particles
|
|
54
|
+
'b_2': lambda xx: 0*xx ,
|
|
55
|
+
'g_2': lambda xx: 0*xx ,
|
|
56
|
+
'f_sky': 1,
|
|
57
|
+
'z_survey': [0,3],
|
|
58
|
+
'be_survey':lambda xx: 0*xx ,
|
|
59
|
+
'Q_survey': lambda xx: 0*xx,
|
|
60
|
+
'n_g': lambda zz: 1e+5 + 0*xx}
|
|
61
|
+
|
|
62
|
+
self.survey_dict= {'Euclid':Euclid,
|
|
63
|
+
'BGS':BGS,
|
|
64
|
+
'SKAO1':SKAO1,
|
|
65
|
+
'SKAO2':SKAO2,
|
|
66
|
+
'DM':DM}
|
|
67
|
+
|
|
68
|
+
################################################################################
|
|
69
|
+
|
|
70
|
+
def get_surveybias(self,survey):
|
|
71
|
+
|
|
72
|
+
return self.survey_dict[survey]
|
|
73
|
+
|
|
74
|
+
class SurveyFunctions:
|
|
75
|
+
""" read in survey specific params from dict - if empty use default values """
|
|
76
|
+
def __init__(self,survey_params,all_bias=True):
|
|
77
|
+
# set evolution and magnification bias
|
|
78
|
+
if 'be_survey' in survey_params.keys():
|
|
79
|
+
self.be_survey = survey_params['be_survey']
|
|
80
|
+
else:
|
|
81
|
+
self.be_survey = lambda xx: 0*xx
|
|
82
|
+
|
|
83
|
+
if 'Q_survey' in survey_params.keys():
|
|
84
|
+
self.Q_survey = survey_params['Q_survey']
|
|
85
|
+
else:
|
|
86
|
+
self.Q_survey = lambda xx: 0*xx #=2/5
|
|
87
|
+
|
|
88
|
+
if all_bias:
|
|
89
|
+
# define other survey specific params not set by HOD and HMF
|
|
90
|
+
if 'n_g' in survey_params.keys():
|
|
91
|
+
self.n_g = survey_params['n_g']
|
|
92
|
+
else:
|
|
93
|
+
self.n_g = lambda xx: 1e+5 + 0*xx
|
|
94
|
+
|
|
95
|
+
#define default bias stuff
|
|
96
|
+
if 'b_1' in survey_params:
|
|
97
|
+
self.b_1 = survey_params['b_1']
|
|
98
|
+
else:
|
|
99
|
+
self.b_1 = lambda xx: np.sqrt(1+xx)
|
|
100
|
+
|
|
101
|
+
if 'be_survey' in survey_params.keys():
|
|
102
|
+
self.be_survey = survey_params['be_survey']
|
|
103
|
+
else:
|
|
104
|
+
self.be_survey = lambda xx: 0*xx
|
|
105
|
+
|
|
106
|
+
if 'Q_survey' in survey_params.keys():
|
|
107
|
+
self.Q_survey = survey_params['Q_survey']
|
|
108
|
+
else:
|
|
109
|
+
self.Q_survey = lambda xx: 0*xx #=2/5
|
|
110
|
+
|
|
111
|
+
#define second order biases from b_1 # or can define them in dict as above
|
|
112
|
+
|
|
113
|
+
if 'g_2' in survey_params.keys():
|
|
114
|
+
self.g_2 = survey_params['g_2']
|
|
115
|
+
else:
|
|
116
|
+
self.g_2 = lambda xx: -(4/7)*(self.b_1(xx)-1) # 0.524-0.547*self.b_1(xx)+0.046*self.b_1(xx)**2#
|
|
117
|
+
|
|
118
|
+
if 'b_2' in survey_params.keys():
|
|
119
|
+
self.b_2 = survey_params['b_2']
|
|
120
|
+
else:
|
|
121
|
+
self.b_2 = lambda xx: 0.412 - 2.143*self.b_1(xx) +0.929*self.b_1(xx)**2 + 0.008*self.b_1(xx)**3 + 4/3 * self.g_2(xx)
|
|
122
|
+
|
|
123
|
+
###########################################################
|
|
124
|
+
#for non tracer things
|
|
125
|
+
if 'f_sky' in survey_params.keys():
|
|
126
|
+
self.f_sky = survey_params['f_sky']
|
|
127
|
+
else:
|
|
128
|
+
self.f_sky = 1
|
|
129
|
+
|
|
130
|
+
if 'z_survey' in survey_params.keys():
|
|
131
|
+
self.z_survey = np.linspace(survey_params['z_survey'][0],survey_params['z_survey'][1],int(1e+5))
|
|
132
|
+
else:
|
|
133
|
+
self.z_survey = np.linspace(0,3,int(1e+5))
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def get_avg_dist(obs_pos):
|
|
5
|
+
"""create x_c to integrate over - lets say it's a 1000 MPc/h (128x128x128) grid situated at (x,y,z)"""
|
|
6
|
+
Nside_theory= 128
|
|
7
|
+
conf_space = np.linspace(0,1000,Nside_theory)
|
|
8
|
+
x_unorm , y_unorm , z_unorm = np.meshgrid(conf_space-obs_pos[0], conf_space-obs_pos[1], conf_space-obs_pos[2],indexing='ij')
|
|
9
|
+
conf_norm = np.sqrt(x_unorm**2 + y_unorm**2 + z_unorm**2) # make a unit vector - normalise
|
|
10
|
+
ds = np.where(conf_norm==0,1,conf_norm)
|
|
11
|
+
return 1/np.mean(1/ds**3)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def index_tuple(tup,index_cmd):
|
|
15
|
+
"""index the array in a tuple"""
|
|
16
|
+
indexed_list = []
|
|
17
|
+
for i,item in enumerate(tup):
|
|
18
|
+
if np.array(item).size>1:
|
|
19
|
+
indexed_list.append(item[index_cmd])
|
|
20
|
+
else:
|
|
21
|
+
indexed_list.append(item)
|
|
22
|
+
return indexed_list
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def tuple_bool(tup,bool_arr):
|
|
26
|
+
"""boolean the array in a tuple - when the array are n-dimensional with last two dimensions to 1 """
|
|
27
|
+
indexed_list = []
|
|
28
|
+
for i,item in enumerate(tup):
|
|
29
|
+
if np.array(item).size>1:
|
|
30
|
+
|
|
31
|
+
indexed_list.append(item.flatten()[bool_arr][...,None,None])
|
|
32
|
+
else:
|
|
33
|
+
indexed_list.append(item)
|
|
34
|
+
return indexed_list
|
|
35
|
+
|
|
36
|
+
def get_args(func,params,derivs,betas,r,s,paramsPNG = []):
|
|
37
|
+
"""
|
|
38
|
+
get appropiate args for each function type
|
|
39
|
+
"""
|
|
40
|
+
func_id = func.__name__ # get string name of func
|
|
41
|
+
|
|
42
|
+
args = [params]
|
|
43
|
+
if 'PNG' in func_id:
|
|
44
|
+
args.append(paramsPNG)
|
|
45
|
+
if 'RR' in func_id:
|
|
46
|
+
args.append(derivs)
|
|
47
|
+
if 'GR' in func_id:
|
|
48
|
+
args.append(betas)
|
|
49
|
+
if 'RR' in func_id or 'WA' in func_id:
|
|
50
|
+
args.append(r)
|
|
51
|
+
args.append(s)
|
|
52
|
+
return args
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Chris Addis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: cosmowap
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: package for computing power spectra and bispectra
|
|
5
|
+
Author-email: Chris Addis <c.l.j.addis@qmul.ac.uk>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: homepage, https://github.com/craddis1/CosmoWAP
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE.txt
|
|
14
|
+
|
|
15
|
+
# CosmoWAP
|
|
16
|
+
|
|
17
|
+
**Cosmo**logy with **W**ide-separation, rel**A**tivistic and **P**rimordial non-Gaussian contibutions.
|
|
18
|
+
|
|
19
|
+
CosmoWAP is an effort to provide a (hopefully) self consistent framwork to compute contribtuions to the fourier power spectrum and bispectrum from wide-separation and relatvisitic effects as well as contribution from Primordial non-Gaussianity (PNG).
|
|
20
|
+
These expression can be very cumbersome and it can be tricky to check for consistency in the community and so hopefully this code should be useful in that regard.
|
|
21
|
+
|
|
22
|
+
CosmoWAP is a *Python* package to analyse the power spectra and bispectra but the analytical expressions themselves are computed analytically in Mathematica using routines which are publicly avalable at [*MathWAP*](https://github.com/craddis1/MathWAP) and then exported as .py files. therefore the main functionality of CosmoWAP is to take these expressions and implement them for a given cosmology (from CLASS) and survey parameters.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Features
|
|
29
|
+
|
|
30
|
+
CosmoWAP computes redshift spadce expressions for the 3D Fourier *power spectrum* (and it's multipoles with multi-tracer capabilites) as well as the *bispectrum* (with Sccoccimarro spherical harmonic multipoles), it also can be used for:
|
|
31
|
+
|
|
32
|
+
- Wide separation (WS) effects (i.e. wide angle and radial redshift contributions) up to second order in the WS expansion
|
|
33
|
+
- Relativistic (GR) effects (inlding projection and dynamical effects - see ... for currently implemented kernels) up to $\left(\frac{\mathcal{H}}{k}\right)^2$
|
|
34
|
+
- Primordial non-Gaussian (PNG) contribution for local, equilateral and orthogonal types (in progress)
|
|
35
|
+
|
|
36
|
+
### additional features
|
|
37
|
+
|
|
38
|
+
- Gaussian covariances along with routines for Fisher and SNR analyses (in progress)
|
|
39
|
+
- Inclusion of Finger-of-God damping
|
|
40
|
+
|
|
41
|
+
## Documentation
|
|
42
|
+
|
|
43
|
+
see documentation .... (Add)
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
Based on work in [arXiv:2407.00168](https://arxiv.org/abs/2407.00168)
|
|
47
|
+
|
|
48
|
+
Also for PNG stuff please refer too: arXiv:24xx.xxxx
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
Updating documentiation - old stuff below...
|
|
52
|
+
|
|
53
|
+
## Overview
|
|
54
|
+
|
|
55
|
+
- \mathematica_routines\The_bispectrum.nb outputs expressions for each different in the bispectrum for different multipoles
|
|
56
|
+
|
|
57
|
+
- These are then stored in \bkterms as .py files
|
|
58
|
+
|
|
59
|
+
- \Library\WS_cosmo: takes in a cosmology from class and survey specifications and returns required parameters to use files in \bkterms - see example.py for usage
|
|
60
|
+
|
|
61
|
+
## quickstart
|
|
62
|
+
|
|
63
|
+
Download the repository...
|
|
64
|
+
|
|
65
|
+
To get started see example.ipynb or example_pk.ipynb for a quick guide on using the computed expressions...
|
|
66
|
+
|
|
67
|
+
CLASS, matplotlib, scipy and numpy are the only dependencies
|
|
68
|
+
|
|
69
|
+
## python functions
|
|
70
|
+
|
|
71
|
+
Outputs are converted to python format and stored in \bk_terms
|
|
72
|
+
|
|
73
|
+
### Notebooks
|
|
74
|
+
|
|
75
|
+
For an example notebook for using these expressions see:
|
|
76
|
+
|
|
77
|
+
- example.ipynb
|
|
78
|
+
|
|
79
|
+
- bk_SNR.ipynb includes code to compute and plot the SNR and fisher stuff for multipoles
|
|
80
|
+
|
|
81
|
+
- bk_plots.ipynb contains a bunch of functions that maybe be useful but is not clean
|
|
82
|
+
|
|
83
|
+
In these notebooks everything is designed to use \Library\WS_cosmo.py where cosmology and survey biases are defined and from that object all bispectrum terms can be computed.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## Multi-tracer Power spectrum multipoles
|
|
87
|
+
|
|
88
|
+
This includes relatvistic and wide separation effects up to second order. The format should be similar as to that of the bispectrum.
|
|
89
|
+
|
|
90
|
+
- The_powerspectrum.nb, Pk_funcsandrules.nb, Pk_expansions.nb: mathematica routines for power spectrum computation.
|
|
91
|
+
|
|
92
|
+
- Library/WS_cosmo.py: Again is the backend to get input parameters for a given survey and cosmology for the saved python functions.
|
|
93
|
+
|
|
94
|
+
- See example_pk.ipynb for example usage.
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
## Errors
|
|
98
|
+
|
|
99
|
+
Some syntax has been updated so there will inevitably be several errors lying around - particular in the bigger notebooks - please let me know!
|
|
100
|
+
|
|
101
|
+
## Usage
|
|
102
|
+
|
|
103
|
+
Feel free to edit or just take any part that may be useful but please refer to:
|
|
104
|
+
[arXiv:2407.00168](https://arxiv.org/abs/2407.00168)
|
|
105
|
+
|
|
106
|
+
## Contact
|
|
107
|
+
|
|
108
|
+
Stuff will be added as time goes by - I plan on adding PNG stuff with scale dependent biases for different shapes of PNG (therefore including HOD for bias modelling)
|
|
109
|
+
|
|
110
|
+
Feel free to drop me a line if you have any feedback!
|
|
111
|
+
If youre having any problems or have any ideas to make it better- Feel free to get in contact :) - c.l.j.addis@qmul.ac.uk
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
cosmo_wap/__init__.py,sha256=Ro6oTom2C72c7JogXcMMeyfldi7yVJiBXO7WokR3fmQ,26
|
|
2
|
+
cosmo_wap/integrate.py,sha256=x9Kbf1fHJOjSdOe4bkUmXjNkNPdXomAnh2Xmsj_okKk,2011
|
|
3
|
+
cosmo_wap/main.py,sha256=4E2wh3mMH_03OXu8RjtqMU5DsENwvlmeMKzmaUwvL5Q,18892
|
|
4
|
+
cosmo_wap/peak_background_bias.py,sha256=TO0ttT--nD6oMYDnlGyhqWzCSwvR5OUzCV14V2IgU7s,12271
|
|
5
|
+
cosmo_wap/survey_params.py,sha256=oCB-2XkyWz_gXSxbXI_We4Uns8IUx74aegvD5ks-wmE,5603
|
|
6
|
+
cosmo_wap/useful_funcs.py,sha256=5s_lVxW-dXmH-QQaCdSqNIezqxm7B3pRSD5esz7dJ24,1652
|
|
7
|
+
cosmo_wap/bk/GR0.py,sha256=BhkeW-pE1rOcCxzatl4N4-77a3EUq8-gzW6pXjGbG1M,26473
|
|
8
|
+
cosmo_wap/bk/GR1.py,sha256=YJIToKHHc0YRucksP6hDbwJhz7p71qd0-H7JmtfeW7M,85721
|
|
9
|
+
cosmo_wap/bk/GR2.py,sha256=M6K7T4wrKM5ICvy5BZuoy5cTuu7YEqwncG0tcilp6FY,79533
|
|
10
|
+
cosmo_wap/bk/GR_0.py,sha256=uB-QKyubLS9tfdgClVgOtGDu1M-Yr5X67x2upoB1V4Q,7885
|
|
11
|
+
cosmo_wap/bk/GR_1.py,sha256=0hgsFRCx5Q1buVbAnpaVjjxq8znkxy6iJtFdSHxcevs,12057
|
|
12
|
+
cosmo_wap/bk/GR_2.py,sha256=PHRYnbvX48zmUrnyxu8UWBWbCGdsBG0fmdgF5DbCMxs,22091
|
|
13
|
+
cosmo_wap/bk/PNG_terms.py,sha256=PG3z46_Mkiu2rh7yuCaiENpoJ1--N1ZIvebYZwE2e1k,26694
|
|
14
|
+
cosmo_wap/bk/RR1.py,sha256=Of2uVf9_slfGdOE2zy075cH20ooCL2nq8xmIXnqpWL8,1037283
|
|
15
|
+
cosmo_wap/bk/RR2.py,sha256=LHLinDP3LeNbrg0N0ufqTTlTBjcGQV_N3RPkKyf80Gc,16880239
|
|
16
|
+
cosmo_wap/bk/RR_1.py,sha256=g4rz8Ad4himhgQj6oa9i2DayTVx8jWzQb9s14lZvRAE,392
|
|
17
|
+
cosmo_wap/bk/WA1.py,sha256=M0caVTtY2TBXsQky85uw5yBwLXXOLHynsgNjkXEm2vk,491130
|
|
18
|
+
cosmo_wap/bk/WA2.py,sha256=m5TzfoRnwjGBhov_RH3sAC4ghw6U8Nx_yidwhq96YSM,1343322
|
|
19
|
+
cosmo_wap/bk/WARR.py,sha256=YgV8f9zQwr15Yfpw34zZ8uFhEWWwcombEJidEno6BkE,3383912
|
|
20
|
+
cosmo_wap/bk/WA_1.py,sha256=scovaKWVdTn15oSWnPiSxOCHVoFojH64aioXuYY3zBg,129753
|
|
21
|
+
cosmo_wap/bk/WA_2.py,sha256=qdG1UwV3QQ3eDqo7JoMXfgIIMGEvEeAL6mv_pjiDpqI,211646
|
|
22
|
+
cosmo_wap/bk/WSGR.py,sha256=4HFVRyTL6XCbtpSYAW6NY5tE7AQJQ5uH_q5-lY4TnCg,2503958
|
|
23
|
+
cosmo_wap/bk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
+
cosmo_wap/bk/cov.py,sha256=5VwXo_Fd65FbdDItJkfZuznmtM1_pEHYYhSYKDq63F8,32903
|
|
25
|
+
cosmo_wap/data_library/SKAO1Data.txt,sha256=jyG8U8HeTWVght4G9zIKiT4WkQVNDdhUQGvWAhHo6B0,1260
|
|
26
|
+
cosmo_wap/data_library/SKAO2Data.txt,sha256=hKkTff4IkiDZUgzJB-kd8DEKm7yGOrPCaUBh8G_EaQY,2514
|
|
27
|
+
cosmo_wap/data_library/snr_surveyparams.txt,sha256=17uUyqvQUgBlWl5D2NbirrSTKuLby28Zd0A8l51siQs,502
|
|
28
|
+
cosmo_wap/pk/Pk_0.py,sha256=kj9Vyq1F8A3x_SeP_EXjySb59PDwpMl8iHjCXg5Ag1I,5504
|
|
29
|
+
cosmo_wap/pk/Pk_WS.py,sha256=ZvPDo1BQo_JyOtMfYYKHUMXtVghVBOQkJ9knVHrBsCI,39423
|
|
30
|
+
cosmo_wap/pk/Pk_WSGR.py,sha256=6E72iFy0yGqOsbQUf95EJEBYQ6RcbfyoYYCfbZ8wfJU,6933
|
|
31
|
+
cosmo_wap/pk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
+
cosmowap-0.0.2.dist-info/LICENSE.txt,sha256=lv9mDkeA1smpAoJst9WzzcZ_s22ATgjDtG88H7FZYvg,1067
|
|
33
|
+
cosmowap-0.0.2.dist-info/METADATA,sha256=lUYijT4PEHCJd2zZbLEsIBmTRLP37ucu6JvIxQHLPgM,4697
|
|
34
|
+
cosmowap-0.0.2.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
35
|
+
cosmowap-0.0.2.dist-info/top_level.txt,sha256=3nupf3n_negqVZFP4RVPDgFnsMOQGb3ERIrPHzivdqo,10
|
|
36
|
+
cosmowap-0.0.2.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cosmo_wap
|