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.
File without changes
cosmo_wap/bk/cov.py ADDED
@@ -0,0 +1,60 @@
1
+ import numpy as np
2
+
3
+ # get newtonian tree level covariances...
4
+
5
+ class COV:
6
+ def N00(params,nbar,Ntri):
7
+ k1,k2,k3,theta,Pk1,Pk2,Pk3,Pkd1,Pkd2,Pkd3,Pkdd1,Pkdd2,Pkdd3,d,K,C,f,D1,b1,b2,g2 = params
8
+
9
+ cos = lambda x: np.cos(x)
10
+ sin = lambda x: np.sin(x)
11
+
12
+ expr = 4*np.pi*D1**6*Pk1*Pk2*Pk3*(45045*b1**6*k3**4 + 30030*b1**5*f*k1**2*k3**2 + 30030*b1**5*f*k2**2*k3**2 + 60060*b1**5*f*k3**4 + 9009*b1**4*f**2*k1**4 + 36036*b1**4*f**2*k1**2*k2**2 + 60060*b1**4*f**2*k1**2*k3**2 + 9009*b1**4*f**2*k2**4 + 60060*b1**4*f**2*k2**2*k3**2 + 42042*b1**4*f**2*k3**4 + 20592*b1**3*f**3*k1**4 + 5148*b1**3*f**3*k1**3*k2*cos(3*theta) + 92664*b1**3*f**3*k1**2*k2**2 + 51480*b1**3*f**3*k1**2*k3**2 + 5148*b1**3*f**3*k1*k2**3*cos(3*theta) + 10296*b1**3*f**3*k1*k2*k3**2*cos(3*theta) + 20592*b1**3*f**3*k2**4 + 51480*b1**3*f**3*k2**2*k3**2 + 15444*b1**3*f**3*k3**4 + 143*b1**2*f**4*k1**4*cos(4*theta) + 19019*b1**2*f**4*k1**4 + 14300*b1**2*f**4*k1**3*k2*cos(3*theta) + 3432*b1**2*f**4*k1**2*k2**2*cos(4*theta) + 96096*b1**2*f**4*k1**2*k2**2 + 572*b1**2*f**4*k1**2*k3**2*cos(4*theta) + 21736*b1**2*f**4*k1**2*k3**2 + 14300*b1**2*f**4*k1*k2**3*cos(3*theta) + 11440*b1**2*f**4*k1*k2*k3**2*cos(3*theta) + 143*b1**2*f**4*k2**4*cos(4*theta) + 19019*b1**2*f**4*k2**4 + 572*b1**2*f**4*k2**2*k3**2*cos(4*theta) + 21736*b1**2*f**4*k2**2*k3**2 + 143*b1**2*f**4*k3**4*cos(4*theta) + 2574*b1**2*f**4*k3**4 + 390*b1*f**5*k1**4*cos(4*theta) + 8450*b1*f**5*k1**4 + 11960*b1*f**5*k1**3*k2*cos(3*theta) + 260*b1*f**5*k1**3*k2*cos(5*theta) + 4680*b1*f**5*k1**2*k2**2*cos(4*theta) + 46800*b1*f**5*k1**2*k2**2 + 390*b1*f**5*k1**2*k3**2*cos(4*theta) + 3900*b1*f**5*k1**2*k3**2 + 11960*b1*f**5*k1*k2**3*cos(3*theta) + 260*b1*f**5*k1*k2**3*cos(5*theta) + 3250*b1*f**5*k1*k2*k3**2*cos(3*theta) + 130*b1*f**5*k1*k2*k3**2*cos(5*theta) + 390*b1*f**5*k2**4*cos(4*theta) + 8450*b1*f**5*k2**4 + 390*b1*f**5*k2**2*k3**2*cos(4*theta) + 3900*b1*f**5*k2**2*k3**2 + 210*f**6*k1**4*cos(4*theta) + 1575*f**6*k1**4 + 3150*f**6*k1**3*k2*cos(3*theta) + 210*f**6*k1**3*k2*cos(5*theta) + 1620*f**6*k1**2*k2**2*cos(4*theta) + 45*f**6*k1**2*k2**2*cos(6*theta) + 9000*f**6*k1**2*k2**2 + 3150*f**6*k1*k2**3*cos(3*theta) + 210*f**6*k1*k2**3*cos(5*theta) + 210*f**6*k2**4*cos(4*theta) + 1575*f**6*k2**4 + f**2*(6006*b1**4*(k1**2*(3*k2**2 + 2*k3**2) + 2*k3**2*(k2**2 + k3**2)) + 5148*b1**3*f*(k1**4 + k1**2*(12*k2**2 + 5*k3**2) + k2**4 + 5*k2**2*k3**2 + 2*k3**4) + 572*b1**2*f**2*(19*k1**4 + k1**2*(141*k2**2 + 31*k3**2) + 19*k2**4 + 31*k2**2*k3**2 + 4*k3**4) + 260*b1*f**3*(29*k1**4 + 15*k1**2*(12*k2**2 + k3**2) + 29*k2**4 + 15*k2**2*k3**2) + 15*f**4*(112*k1**4 + 675*k1**2*k2**2 + 112*k2**4))*cos(2*theta) + 4*f*k1*k2*(15015*b1**5*k3**2 + 9009*b1**4*f*(k1**2 + k2**2 + 4*k3**2) + 1287*b1**3*f**2*(19*k1**2 + 19*k2**2 + 28*k3**2) + 715*b1**2*f**3*(37*k1**2 + 37*k2**2 + 24*k3**2) + 325*b1*f**4*(41*k1**2 + 41*k2**2 + 10*k3**2) + 2625*f**5*(k1**2 + k2**2))*cos(theta))/(45045*Ntri*k3**4)
13
+ return expr
14
+
15
+ def N10(params,nbar,Ntri):
16
+ k1,k2,k3,theta,Pk1,Pk2,Pk3,Pkd1,Pkd2,Pkd3,Pkdd1,Pkdd2,Pkdd3,d,K,C,f,D1,b1,b2,g2 = params
17
+
18
+ cos = lambda x: np.cos(x)
19
+ sin = lambda x: np.sin(x)
20
+
21
+ expr = 4*np.pi*D1**6*Pk1*Pk2*Pk3*(15015*b1**6*k3**4 + 18018*b1**5*f*k1**2*k3**2 + 12012*b1**5*f*k2**2*k3**2 + 30030*b1**5*f*k3**4 + 6435*b1**4*f**2*k1**4 + 23166*b1**4*f**2*k1**2*k2**2 + 41184*b1**4*f**2*k1**2*k3**2 + 2574*b1**4*f**2*k1*k2**3*cos(3*theta) + 5148*b1**4*f**2*k1*k2*k3**2*cos(3*theta) + 3861*b1**4*f**2*k2**4 + 30888*b1**4*f**2*k2**2*k3**2 + 25740*b1**4*f**2*k3**4 + 15730*b1**3*f**3*k1**4 + 5720*b1**3*f**3*k1**3*k2*cos(3*theta) + 1716*b1**3*f**3*k1**2*k2**2*cos(4*theta) + 65208*b1**3*f**3*k1**2*k2**2 + 286*b1**3*f**3*k1**2*k3**2*cos(4*theta) + 38038*b1**3*f**3*k1**2*k3**2 + 11440*b1**3*f**3*k1*k2**3*cos(3*theta) + 14300*b1**3*f**3*k1*k2*k3**2*cos(3*theta) + 286*b1**3*f**3*k2**4*cos(4*theta) + 10868*b1**3*f**3*k2**4 + 1144*b1**3*f**3*k2**2*k3**2*cos(4*theta) + 32032*b1**3*f**3*k2**2*k3**2 + 286*b1**3*f**3*k3**4*cos(4*theta) + 10868*b1**3*f**3*k3**4 + 195*b1**2*f**4*k1**4*cos(4*theta) + 15145*b1**2*f**4*k1**4 + 14170*b1**2*f**4*k1**3*k2*cos(3*theta) + 130*b1**2*f**4*k1**3*k2*cos(5*theta) + 5850*b1**2*f**4*k1**2*k2**2*cos(4*theta) + 72150*b1**2*f**4*k1**2*k2**2 + 780*b1**2*f**4*k1**2*k3**2*cos(4*theta) + 16900*b1**2*f**4*k1**2*k3**2 + 18460*b1**2*f**4*k1*k2**3*cos(3*theta) + 520*b1**2*f**4*k1*k2**3*cos(5*theta) + 11960*b1**2*f**4*k1*k2*k3**2*cos(3*theta) + 260*b1**2*f**4*k1*k2*k3**2*cos(5*theta) + 975*b1**2*f**4*k2**4*cos(4*theta) + 12025*b1**2*f**4*k2**4 + 1560*b1**2*f**4*k2**2*k3**2*cos(4*theta) + 15600*b1**2*f**4*k2**2*k3**2 + 195*b1**2*f**4*k3**4*cos(4*theta) + 1950*b1**2*f**4*k3**4 + 420*b1*f**5*k1**4*cos(4*theta) + 6930*b1*f**5*k1**4 + 11340*b1*f**5*k1**3*k2*cos(3*theta) + 420*b1*f**5*k1**3*k2*cos(5*theta) + 5760*b1*f**5*k1**2*k2**2*cos(4*theta) + 90*b1*f**5*k1**2*k2**2*cos(6*theta) + 36900*b1*f**5*k1**2*k2**2 + 420*b1*f**5*k1**2*k3**2*cos(4*theta) + 3150*b1*f**5*k1**2*k3**2 + 12600*b1*f**5*k1*k2**3*cos(3*theta) + 840*b1*f**5*k1*k2**3*cos(5*theta) + 3150*b1*f**5*k1*k2*k3**2*cos(3*theta) + 210*b1*f**5*k1*k2*k3**2*cos(5*theta) + 960*b1*f**5*k2**4*cos(4*theta) + 15*b1*f**5*k2**4*cos(6*theta) + 6150*b1*f**5*k2**4 + 540*b1*f**5*k2**2*k3**2*cos(4*theta) + 15*b1*f**5*k2**2*k3**2*cos(6*theta) + 3000*b1*f**5*k2**2*k3**2 + 210*f**6*k1**4*cos(4*theta) + 1323*f**6*k1**4 + 2940*f**6*k1**3*k2*cos(3*theta) + 252*f**6*k1**3*k2*cos(5*theta) + 1764*f**6*k1**2*k2**2*cos(4*theta) + 84*f**6*k1**2*k2**2*cos(6*theta) + 7350*f**6*k1**2*k2**2 + 3087*f**6*k1*k2**3*cos(3*theta) + 343*f**6*k1*k2**3*cos(5*theta) + 7*f**6*k1*k2**3*cos(7*theta) + 294*f**6*k2**4*cos(4*theta) + 14*f**6*k2**4*cos(6*theta) + 1225*f**6*k2**4 + f*k1*k2*(36036*b1**5*k3**2 + 2574*b1**4*f*(10*k1**2 + 9*k2**2 + 38*k3**2) + 2860*b1**3*f**2*(26*k1**2 + 24*k2**2 + 37*k3**2) + 260*b1**2*f**3*(323*k1**2 + 305*k2**2 + 205*k3**2) + 420*b1*f**4*(104*k1**2 + 100*k2**2 + 25*k3**2) + 245*f**5*(36*k1**2 + 35*k2**2))*cos(theta) + f*(6006*b1**5*k3**2*(k2**2 + k3**2) + 2574*b1**4*f*(k1**2*(6*k2**2 + 4*k3**2) + k2**4 + 8*k2**2*k3**2 + 5*k3**4) + 286*b1**3*f**2*(15*k1**4 + 2*k1**2*(93*k2**2 + 38*k3**2) + 31*k2**4 + 94*k2**2*k3**2 + 31*k3**4) + 130*b1**2*f**3*(71*k1**4 + 2*k1**2*(267*k2**2 + 58*k3**2) + 89*k2**4 + 120*k2**2*k3**2 + 15*k3**4) + 15*b1*f**4*(434*k1**4 + k1**2*(2694*k2**2 + 224*k3**2) + 449*k2**4 + 225*k2**2*k3**2) + 1470*f**5*(k1**4 + 6*k1**2*k2**2 + k2**4))*cos(2*theta))/(15015*Ntri*k3**4)
22
+
23
+ return expr
24
+
25
+ def N11(params,nbar,Ntri):
26
+ k1,k2,k3,theta,Pk1,Pk2,Pk3,Pkd1,Pkd2,Pkd3,Pkdd1,Pkdd2,Pkdd3,d,K,C,f,D1,b1,b2,g2 = params
27
+
28
+ cos = lambda x: np.cos(x)
29
+ sin = lambda x: np.sin(x)
30
+
31
+ expr = 2*np.pi*(D1**2*Pk1*nbar*(D1**2*Pk2*nbar*(D1**2*Pk3*nbar*(30030*b1**6*k3**4 + 12012*b1**5*f*k1**2*k3**2 + 18018*b1**5*f*k2**2*k3**2 + 30030*b1**5*f*k3**4 + 2574*b1**4*f**2*k1**4 + 12870*b1**4*f**2*k1**2*k2**2 + 18876*b1**4*f**2*k1**2*k3**2 - 2574*b1**4*f**2*k1*k2**3*cos(3*theta) - 5148*b1**4*f**2*k1*k2*k3**2*cos(3*theta) + 5148*b1**4*f**2*k2**4 + 29172*b1**4*f**2*k2**2*k3**2 + 16302*b1**4*f**2*k3**4 + 4862*b1**3*f**3*k1**4 - 572*b1**3*f**3*k1**3*k2*cos(3*theta) - 1716*b1**3*f**3*k1**2*k2**2*cos(4*theta) + 27456*b1**3*f**3*k1**2*k2**2 - 286*b1**3*f**3*k1**2*k3**2*cos(4*theta) + 13442*b1**3*f**3*k1**2*k3**2 - 6292*b1**3*f**3*k1*k2**3*cos(3*theta) - 4004*b1**3*f**3*k1*k2*k3**2*cos(3*theta) - 286*b1**3*f**3*k2**4*cos(4*theta) + 9724*b1**3*f**3*k2**4 - 1144*b1**3*f**3*k2**2*k3**2*cos(4*theta) + 19448*b1**3*f**3*k2**2*k3**2 - 286*b1**3*f**3*k3**4*cos(4*theta) + 4576*b1**3*f**3*k3**4 - 52*b1**2*f**4*k1**4*cos(4*theta) + 3874*b1**2*f**4*k1**4 + 130*b1**2*f**4*k1**3*k2*cos(3*theta) - 130*b1**2*f**4*k1**3*k2*cos(5*theta) - 2418*b1**2*f**4*k1**2*k2**2*cos(4*theta) + 23946*b1**2*f**4*k1**2*k2**2 - 208*b1**2*f**4*k1**2*k3**2*cos(4*theta) + 4836*b1**2*f**4*k1**2*k3**2 - 4160*b1**2*f**4*k1*k2**3*cos(3*theta) - 520*b1**2*f**4*k1*k2**3*cos(5*theta) - 520*b1**2*f**4*k1*k2*k3**2*cos(3*theta) - 260*b1**2*f**4*k1*k2*k3**2*cos(5*theta) - 832*b1**2*f**4*k2**4*cos(4*theta) + 6994*b1**2*f**4*k2**4 - 988*b1**2*f**4*k2**2*k3**2*cos(4*theta) + 6136*b1**2*f**4*k2**2*k3**2 - 52*b1**2*f**4*k3**4*cos(4*theta) + 624*b1**2*f**4*k3**4 - 30*b1*f**5*k1**4*cos(4*theta) + 1520*b1*f**5*k1**4 + 620*b1*f**5*k1**3*k2*cos(3*theta) - 160*b1*f**5*k1**3*k2*cos(5*theta) - 1080*b1*f**5*k1**2*k2**2*cos(4*theta) - 90*b1*f**5*k1**2*k2**2*cos(6*theta) + 9900*b1*f**5*k1**2*k2**2 - 30*b1*f**5*k1**2*k3**2*cos(4*theta) + 750*b1*f**5*k1**2*k3**2 - 640*b1*f**5*k1*k2**3*cos(3*theta) - 580*b1*f**5*k1*k2**3*cos(5*theta) + 100*b1*f**5*k1*k2*k3**2*cos(3*theta) - 80*b1*f**5*k1*k2*k3**2*cos(5*theta) - 570*b1*f**5*k2**4*cos(4*theta) - 15*b1*f**5*k2**4*cos(6*theta) + 2300*b1*f**5*k2**4 - 150*b1*f**5*k2**2*k3**2*cos(4*theta) - 15*b1*f**5*k2**2*k3**2*cos(6*theta) + 900*b1*f**5*k2**2*k3**2 + 252*f**6*k1**4 + 210*f**6*k1**3*k2*cos(3*theta) - 42*f**6*k1**3*k2*cos(5*theta) - 144*f**6*k1**2*k2**2*cos(4*theta) - 39*f**6*k1**2*k2**2*cos(6*theta) + 1650*f**6*k1**2*k2**2 + 63*f**6*k1*k2**3*cos(3*theta) - 133*f**6*k1*k2**3*cos(5*theta) - 7*f**6*k1*k2**3*cos(7*theta) - 84*f**6*k2**4*cos(4*theta) - 14*f**6*k2**4*cos(6*theta) + 350*f**6*k2**4 + f*k1*k2*(24024*b1**5*k3**2 + 2574*b1**4*f*(4*k1**2 + 5*k2**2 + 18*k3**2) + 572*b1**3*f**2*(41*k1**2 + 51*k2**2 + 67*k3**2) + 260*b1**2*f**3*(84*k1**2 + 102*k2**2 + 59*k3**2) + 20*b1*f**4*(481*k1**2 + 565*k2**2 + 125*k3**2) + 35*f**5*(48*k1**2 + 55*k2**2))*cos(theta) + f*(-6006*b1**5*k3**2*(k2**2 + k3**2) - 858*b1**4*f*(-k1**2*(3*k2**2 + 2*k3**2) + 3*k2**4 + 10*k2**2*k3**2 + k3**4) + 286*b1**3*f**2*(3*k1**4 + 2*k1**2*(15*k2**2 + 7*k3**2) - 13*k2**4 - 4*k2**2*k3**2 + 5*k3**4) + 26*b1**2*f**3*(63*k1**4 + 6*k1**2*(72*k2**2 + 17*k3**2) - 27*k2**4 + 82*k2**2*k3**2 + 13*k3**4) + 5*b1*f**4*(206*k1**4 + 18*k1**2*(71*k2**2 + 6*k3**2) + 7*k2**2*(23*k2**2 + 15*k3**2)) + 15*f**5*(14*k1**4 + 87*k1**2*k2**2 + 14*k2**4))*cos(2*theta)) + 26*k3**4*(1155*b1**4 + 1155*b1**3*f + 627*b1**2*f**2 + 176*b1*f**3 + 24*f**4 - f**3*(11*b1 + 2*f)*cos(4*theta) + f*(-231*b1**3 - 33*b1**2*f + 55*b1*f**2 + 13*f**3)*cos(2*theta))) + 26*D1**2*Pk3*nbar*(1155*b1**4*k3**4 + 462*b1**3*f*k1**2*k3**2 + 693*b1**3*f*k2**2*k3**2 + 462*b1**3*f*k3**4 + 99*b1**2*f**2*k1**4 + 495*b1**2*f**2*k1**2*k2**2 + 396*b1**2*f**2*k1**2*k3**2 - 99*b1**2*f**2*k1*k2**3*cos(3*theta) + 198*b1**2*f**2*k2**4 + 330*b1**2*f**2*k2**2*k3**2 + 99*b1**2*f**2*k3**4 + 110*b1*f**3*k1**4 + 462*b1*f**3*k1**2*k2**2 + 110*b1*f**3*k1**2*k3**2 - 22*b1*f**3*k1*k2**3*cos(3*theta) - 11*b1*f**3*k2**4*cos(4*theta) + 99*b1*f**3*k2**4 + 77*b1*f**3*k2**2*k3**2 + 35*f**4*k1**4 + 135*f**4*k1**2*k2**2 + 5*f**4*k1*k2**3*cos(3*theta) - 2*f**4*k2**4*cos(4*theta) + 24*f**4*k2**4 + f*k1*k2*(924*b1**3*k3**2 + 99*b1**2*f*(4*k1**2 + 5*k2**2 + 8*k3**2) + 22*b1*f**2*(20*k1**2 + 21*k2**2 + 10*k3**2) + 5*f**3*(28*k1**2 + 27*k2**2))*cos(theta) + f*k2**2*(-231*b1**3*k3**2 + 33*b1**2*f*(3*k1**2 - 3*k2**2 + 2*k3**2) + 11*b1*f**2*(18*k1**2 + 2*k2**2 + 3*k3**2) + f**3*(75*k1**2 + 13*k2**2))*cos(2*theta)) + 26*k3**4*(1155*b1**2 + 462*b1*f + 99*f**2)) + 26*D1**2*Pk2*nbar*(D1**2*Pk3*nbar*(1155*b1**4*k3**4 + 462*b1**3*f*k1**2*k3**2 + 693*b1**3*f*k2**2*k3**2 + 693*b1**3*f*k3**4 + 99*b1**2*f**2*k1**4 + 495*b1**2*f**2*k1**2*k2**2 + 330*b1**2*f**2*k1**2*k3**2 - 99*b1**2*f**2*k1*k2**3*cos(3*theta) - 198*b1**2*f**2*k1*k2*k3**2*cos(3*theta) + 198*b1**2*f**2*k2**4 + 792*b1**2*f**2*k2**2*k3**2 + 198*b1**2*f**2*k3**4 + 77*b1*f**3*k1**4 - 22*b1*f**3*k1**3*k2*cos(3*theta) - 66*b1*f**3*k1**2*k2**2*cos(4*theta) + 594*b1*f**3*k1**2*k2**2 - 11*b1*f**3*k1**2*k3**2*cos(4*theta) + 99*b1*f**3*k1**2*k3**2 - 220*b1*f**3*k1*k2**3*cos(3*theta) - 110*b1*f**3*k1*k2*k3**2*cos(3*theta) + 275*b1*f**3*k2**4 + 275*b1*f**3*k2**2*k3**2 - 2*f**4*k1**4*cos(4*theta) + 24*f**4*k1**4 - 15*f**4*k1**3*k2*cos(3*theta) - 5*f**4*k1**3*k2*cos(5*theta) - 45*f**4*k1**2*k2**2*cos(4*theta) + 210*f**4*k1**2*k2**2 - 105*f**4*k1*k2**3*cos(3*theta) + 105*f**4*k2**4 + f*k1*k2*(924*b1**3*k3**2 + 99*b1**2*f*(4*k1**2 + 5*k2**2 + 10*k3**2) + 66*b1*f**2*(7*k1**2 + 10*k2**2 + 5*k3**2) + 5*f**3*(32*k1**2 + 49*k2**2))*cos(theta) + f*(-231*b1**3*k3**2*(k2**2 + k3**2) + 33*b1**2*f*(k1**2*(3*k2**2 + 2*k3**2) - 3*k2**4 - 12*k2**2*k3**2 - 3*k3**4) + 11*b1*f**2*(3*k1**4 + 2*k1**2*(6*k2**2 + k3**2) - 15*k2**2*(k2**2 + k3**2)) + f**3*(13*k1**4 + 45*k1**2*k2**2 - 70*k2**4))*cos(2*theta)) + 33*k3**4*(35*b1**2 + 21*b1*f + 6*f**2 - f*(7*b1 + 3*f)*cos(2*theta))) + 858*D1**2*Pk3*nbar*(35*b1**2*k3**4 + 14*b1*f*k1**2*k3**2 + 21*b1*f*k2**2*k3**2 + 3*f**2*k1**4 + 15*f**2*k1**2*k2**2 - 3*f**2*k1*k2**3*cos(3*theta) + 6*f**2*k2**4 + f*k1*k2*(28*b1*k3**2 + 3*f*(4*k1**2 + 5*k2**2))*cos(theta) + f*k2**2*(-7*b1*k3**2 + 3*f*k1**2 - 3*f*k2**2)*cos(2*theta)) + 30030*k3**4)/(15015*Ntri*k3**4*nbar**3)
32
+ return expr
33
+
34
+ def N30(params,nbar,Ntri):
35
+ k1,k2,k3,theta,Pk1,Pk2,Pk3,Pkd1,Pkd2,Pkd3,Pkdd1,Pkdd2,Pkdd3,d,K,C,f,D1,b1,b2,g2 = params
36
+
37
+ cos = lambda x: np.cos(x)
38
+ sin = lambda x: np.sin(x)
39
+
40
+ expr = np.pi*D1**6*Pk1*Pk2*Pk3*(8314020*b1**6*k3**4 + 8498776*b1**5*f*k1**2*k3**2 + 6281704*b1**5*f*k2**2*k3**2 + 14780480*b1**5*f*k3**4 + 3275220*b1**4*f**2*k1**4 + 11286912*b1**4*f**2*k1**2*k2**2 + 20625488*b1**4*f**2*k1**2*k3**2 + 1813968*b1**4*f**2*k1*k2**3*cos(3*theta) + 3627936*b1**4*f**2*k1*k2*k3**2*cos(3*theta) + 188955*b1**4*f**2*k2**4*cos(4*theta) + 2028117*b1**4*f**2*k2**4 + 755820*b1**4*f**2*k2**2*k3**2*cos(4*theta) + 15637076*b1**4*f**2*k2**2*k3**2 + 188955*b1**4*f**2*k3**4*cos(4*theta) + 12827945*b1**4*f**2*k3**4 + 8759760*b1**3*f**3*k1**4 + 4418640*b1**3*f**3*k1**3*k2*cos(3*theta) + 2662812*b1**3*f**3*k1**2*k2**2*cos(4*theta) + 34035156*b1**3*f**3*k1**2*k2**2 + 443802*b1**3*f**3*k1**2*k3**2*cos(4*theta) + 20556366*b1**3*f**3*k1**2*k3**2 + 8934180*b1**3*f**3*k1*k2**3*cos(3*theta) + 872100*b1**3*f**3*k1*k2**3*cos(5*theta) + 11095050*b1**3*f**3*k1*k2*k3**2*cos(3*theta) + 436050*b1**3*f**3*k1*k2*k3**2*cos(5*theta) + 1025202*b1**3*f**3*k2**4*cos(4*theta) + 121125*b1**3*f**3*k2**4*cos(6*theta) + 5672526*b1**3*f**3*k2**4 + 2356608*b1**3*f**3*k2**2*k3**2*cos(4*theta) + 121125*b1**3*f**3*k2**2*k3**2*cos(6*theta) + 16566024*b1**3*f**3*k2**2*k3**2 + 443802*b1**3*f**3*k3**4*cos(4*theta) + 5672526*b1**3*f**3*k3**4 + 227715*b1**2*f**4*k1**4*cos(4*theta) + 9094065*b1**2*f**4*k1**4 + 11346990*b1**2*f**4*k1**3*k2*cos(3*theta) + 377910*b1**2*f**4*k1**3*k2*cos(5*theta) + 7412850*b1**2*f**4*k1**2*k2**2*cos(4*theta) + 242250*b1**2*f**4*k1**2*k2**2*cos(6*theta) + 40455750*b1**2*f**4*k1**2*k2**2 + 910860*b1**2*f**4*k1**2*k3**2*cos(4*theta) + 9786900*b1**2*f**4*k1**2*k3**2 + 15169695*b1**2*f**4*k1*k2**3*cos(3*theta) + 2246465*b1**2*f**4*k1*k2**3*cos(5*theta) + 56525*b1**2*f**4*k1*k2**3*cos(7*theta) + 9670620*b1**2*f**4*k1*k2*k3**2*cos(3*theta) + 755820*b1**2*f**4*k1*k2*k3**2*cos(5*theta) + 1865325*b1**2*f**4*k2**4*cos(4*theta) + 274550*b1**2*f**4*k2**4*cos(6*theta) + 6435775*b1**2*f**4*k2**4 + 2209320*b1**2*f**4*k2**2*k3**2*cos(4*theta) + 161500*b1**2*f**4*k2**2*k3**2*cos(6*theta) + 8462600*b1**2*f**4*k2**2*k3**2 + 227715*b1**2*f**4*k3**4*cos(4*theta) + 1090125*b1**2*f**4*k3**4 + 442890*b1*f**5*k1**4*cos(4*theta) + 4424910*b1*f**5*k1**4 + 9344580*b1*f**5*k1**3*k2*cos(3*theta) + 726180*b1*f**5*k1**3*k2*cos(5*theta) + 6617700*b1*f**5*k1**2*k2**2*cos(4*theta) + 429210*b1*f**5*k1**2*k2**2*cos(6*theta) + 22137660*b1*f**5*k1**2*k2**2 + 442890*b1*f**5*k1**2*k3**2*cos(4*theta) + 1951110*b1*f**5*k1**2*k3**2 + 10637340*b1*f**5*k1*k2**3*cos(3*theta) + 2002980*b1*f**5*k1*k2**3*cos(5*theta) + 103740*b1*f**5*k1*k2**3*cos(7*theta) + 2613450*b1*f**5*k1*k2*k3**2*cos(3*theta) + 363090*b1*f**5*k1*k2*k3**2*cos(5*theta) + 1396880*b1*f**5*k2**4*cos(4*theta) + 225815*b1*f**5*k2**4*cos(6*theta) + 6650*b1*f**5*k2**4*cos(8*theta) + 3447550*b1*f**5*k2**4 + 660060*b1*f**5*k2**2*k3**2*cos(4*theta) + 71535*b1*f**5*k2**2*k3**2*cos(6*theta) + 1738500*b1*f**5*k2**2*k3**2 + 211995*f**6*k1**4*cos(4*theta) + 893781*f**6*k1**4 + 2482830*f**6*k1**3*k2*cos(3*theta) + 351414*f**6*k1**3*k2*cos(5*theta) + 1924398*f**6*k1**2*k2**2*cos(4*theta) + 206388*f**6*k1**2*k2**2*cos(6*theta) + 4696650*f**6*k1**2*k2**2 + 2649969*f**6*k1*k2**3*cos(3*theta) + 613431*f**6*k1*k2**3*cos(5*theta) + 49959*f**6*k1*k2**3*cos(7*theta) + 372498*f**6*k2**4*cos(4*theta) + 68838*f**6*k2**4*cos(6*theta) + 3885*f**6*k2**4*cos(8*theta) + 731325*f**6*k2**4 + f*k1*k2*(16997552*b1**5*k3**2 + 201552*b1**4*f*(65*k1**2 + 56*k2**2 + 242*k3**2) + 19380*b1**3*f**2*(2124*k1**2 + 1846*k2**2 + 2933*k3**2) + 1615*b1**2*f**3*(31044*k1**2 + 27485*k2**2 + 19080*k3**2) + 39900*b1*f**4*(698*k1**2 + 631*k2**2 + 163*k3**2) + 315*f**5*(18916*k1**2 + 17395*k2**2))*cos(theta) + f*(2217072*b1**5*k3**2*(k2**2 + k3**2) + 16796*b1**4*f*(166*k1**2*(3*k2**2 + 2*k3**2) + 63*k2**4 + 584*k2**2*k3**2 + 395*k3**4) + 969*b1**3*f**2*(2720*k1**4 + 72*k1**2*(454*k2**2 + 189*k3**2) + 4723*k2**4 + 15627*k2**2*k3**2 + 5448*k3**4) + 9690*b1**2*f**3*(634*k1**4 + k1**2*(4611*k2**2 + 1024*k3**2) + 711*k2**4 + 1010*k2**2*k3**2 + 130*k3**4) + 95*b1*f**4*(48552*k1**4 + 18*k1**2*(16197*k2**2 + 1372*k3**2) + 46351*k2**4 + 23895*k2**2*k3**2) + 210*f**5*(5202*k1**4 + 30294*k1**2*k2**2 + 4865*k2**4))*cos(2*theta))/(2078505*Ntri*k3**4)
41
+ return expr
42
+
43
+ def N31(params,nbar,Ntri):
44
+ k1,k2,k3,theta,Pk1,Pk2,Pk3,Pkd1,Pkd2,Pkd3,Pkdd1,Pkdd2,Pkdd3,d,K,C,f,D1,b1,b2,g2 = params
45
+
46
+ cos = lambda x: np.cos(x)
47
+ sin = lambda x: np.sin(x)
48
+
49
+ expr = np.pi*(D1**2*Pk1*nbar*(D1**2*Pk2*nbar*(D1**2*Pk3*nbar*(11085360*b1**6*k3**4 + 10346336*b1**5*f*k1**2*k3**2 + 8129264*b1**5*f*k2**2*k3**2 + 18475600*b1**5*f*k3**4 + 3560752*b1**4*f**2*k1**4 + 13100880*b1**4*f**2*k1**2*k2**2 + 22976928*b1**4*f**2*k1**2*k3**2 + 1142128*b1**4*f**2*k1*k2**3*cos(3*theta) + 2284256*b1**4*f**2*k1*k2*k3**2*cos(3*theta) + 41990*b1**4*f**2*k2**4*cos(4*theta) + 2544594*b1**4*f**2*k2**4 + 167960*b1**4*f**2*k2**2*k3**2*cos(4*theta) + 18912296*b1**4*f**2*k2**2*k3**2 + 41990*b1**4*f**2*k3**4*cos(4*theta) + 14839266*b1**4*f**2*k3**4 + 8304976*b1**3*f**3*k1**4 + 2366944*b1**3*f**3*k1**3*k2*cos(3*theta) + 7752*b1**3*f**3*k1**2*k2**2*cos(4*theta) + 35651448*b1**3*f**3*k1**2*k2**2 + 1292*b1**3*f**3*k1**2*k3**2*cos(4*theta) + 20417476*b1**3*f**3*k1**2*k3**2 + 4653784*b1**3*f**3*k1*k2**3*cos(3*theta) - 452200*b1**3*f**3*k1*k2**3*cos(5*theta) + 5877308*b1**3*f**3*k1*k2*k3**2*cos(3*theta) - 226100*b1**3*f**3*k1*k2*k3**2*cos(5*theta) + 49742*b1**3*f**3*k2**4*cos(4*theta) - 121125*b1**3*f**3*k2**4*cos(6*theta) + 6554962*b1**3*f**3*k2**4 + 53618*b1**3*f**3*k2**2*k3**2*cos(4*theta) - 121125*b1**3*f**3*k2**2*k3**2*cos(6*theta) + 18210094*b1**3*f**3*k2**2*k3**2 + 1292*b1**3*f**3*k3**4*cos(4*theta) + 5941908*b1**3*f**3*k3**4 + 31654*b1**2*f**4*k1**4*cos(4*theta) + 7614402*b1**2*f**4*k1**4 + 5484540*b1**2*f**4*k1**3*k2*cos(3*theta) - 122740*b1**2*f**4*k1**3*k2*cos(5*theta) + 672486*b1**2*f**4*k1**2*k2**2*cos(4*theta) - 169575*b1**2*f**4*k1**2*k2**2*cos(6*theta) + 37870458*b1**2*f**4*k1**2*k2**2 + 126616*b1**2*f**4*k1**2*k3**2*cos(4*theta) + 8700328*b1**2*f**4*k1**2*k3**2 + 7030095*b1**2*f**4*k1*k2**3*cos(3*theta) - 886635*b1**2*f**4*k1*k2**3*cos(5*theta) - 56525*b1**2*f**4*k1*k2**3*cos(7*theta) + 4612440*b1**2*f**4*k1*k2*k3**2*cos(3*theta) - 245480*b1**2*f**4*k1*k2*k3**2*cos(5*theta) - 26486*b1**2*f**4*k2**4*cos(4*theta) - 226100*b1**2*f**4*k2**4*cos(6*theta) + 6716462*b1**2*f**4*k2**4 + 68476*b1**2*f**4*k2**2*k3**2*cos(4*theta) - 113050*b1**2*f**4*k2**2*k3**2*cos(6*theta) + 8345028*b1**2*f**4*k2**2*k3**2 + 31654*b1**2*f**4*k3**4*cos(4*theta) + 1025202*b1**2*f**4*k3**4 + 90060*b1*f**5*k1**4*cos(4*theta) + 3323860*b1*f**5*k1**4 + 4150360*b1*f**5*k1**3*k2*cos(3*theta) - 99560*b1*f**5*k1**3*k2*cos(5*theta) + 940500*b1*f**5*k1**2*k2**2*cos(4*theta) - 216030*b1*f**5*k1**2*k2**2*cos(6*theta) + 18521580*b1*f**5*k1**2*k2**2 + 90060*b1*f**5*k1**2*k3**2*cos(4*theta) + 1546980*b1*f**5*k1**2*k3**2 + 4553350*b1*f**5*k1*k2**3*cos(3*theta) - 539790*b1*f**5*k1*k2**3*cos(5*theta) - 81130*b1*f**5*k1*k2**3*cos(7*theta) + 1149500*b1*f**5*k1*k2*k3**2*cos(3*theta) - 49780*b1*f**5*k1*k2*k3**2*cos(5*theta) + 8170*b1*f**5*k2**4*cos(4*theta) - 145065*b1*f**5*k2**4*cos(6*theta) - 6650*b1*f**5*k2**4*cos(8*theta) + 3222400*b1*f**5*k2**4 + 66690*b1*f**5*k2**2*k3**2*cos(4*theta) - 36005*b1*f**5*k2**2*k3**2*cos(6*theta) + 1539950*b1*f**5*k2**2*k3**2 + 49350*f**6*k1**4*cos(4*theta) + 603666*f**6*k1**4 + 1024380*f**6*k1**3*k2*cos(3*theta) - 7476*f**6*k1**3*k2*cos(5*theta) + 332118*f**6*k1**2*k2**2*cos(4*theta) - 66567*f**6*k1**2*k2**2*cos(6*theta) + 3517050*f**6*k1**2*k2**2 + 1065519*f**6*k1*k2**3*cos(3*theta) - 96859*f**6*k1*k2**3*cos(5*theta) - 30541*f**6*k1*k2**3*cos(7*theta) + 26768*f**6*k2**4*cos(4*theta) - 35322*f**6*k2**4*cos(6*theta) - 3220*f**6*k2**4*cos(8*theta) + 615300*f**6*k2**4 + f*k1*k2*(20692672*b1**5*k3**2 + 67184*b1**4*f*(212*k1**2 + 195*k2**2 + 814*k3**2) + 2584*b1**3*f**2*(15244*k1**2 + 14534*k2**2 + 22053*k3**2) + 1615*b1**2*f**3*(26248*k1**2 + 25799*k2**2 + 17008*k3**2) + 190*b1*f**4*(110392*k1**2 + 111015*k2**2 + 27140*k3**2) + 35*f**5*(114984*k1**2 + 117235*k2**2))*cos(theta) + f*(2217072*b1**5*k3**2*(k2**2 + k3**2) + 33592*b1**4*f*(82*k1**2*(3*k2**2 + 2*k3**2) + 29*k2**4 + 280*k2**2*k3**2 + 193*k3**4) + 323*b1**3*f**2*(6608*k1**4 + 48*k1**2*(1740*k2**2 + 703*k3**2) + 12247*k2**4 + 40791*k2**2*k3**2 + 13920*k3**4) + 323*b1**2*f**3*(13288*k1**4 + k1**2*(102957*k2**2 + 21952*k3**2) + 16948*k2**4 + 23582*k2**2*k3**2 + 2888*k3**4) + 95*b1*f**4*(29920*k1**4 + 18*k1**2*(10697*k2**2 + 872*k3**2) + 33447*k2**4 + 16395*k2**2*k3**2) + 5*f**5*(121464*k1**4 + 755883*k1**2*k2**2 + 131362*k2**4))*cos(2*theta)) + 646*k3**4*(17160*b1**4 + 28600*b1**3*f + 22971*b1**2*f**2 + 9198*b1*f**3 + 1587*f**4 + f**2*(65*b1**2 + 2*b1*f + 49*f**2)*cos(4*theta) + 4*f*(858*b1**3 + 2509*b1**2*f + 1740*b1*f**2 + 361*f**3)*cos(2*theta))) + 646*D1**2*Pk3*nbar*(17160*b1**4*k3**4 + 16016*b1**3*f*k1**2*k3**2 + 12584*b1**3*f*k2**2*k3**2 + 16016*b1**3*f*k3**4 + 5512*b1**2*f**2*k1**4 + 20280*b1**2*f**2*k1**2*k2**2 + 22048*b1**2*f**2*k1**2*k3**2 + 1768*b1**2*f**2*k1*k2**3*cos(3*theta) + 65*b1**2*f**2*k2**4*cos(4*theta) + 3939*b1**2*f**2*k2**4 + 13520*b1**2*f**2*k2**2*k3**2 + 5512*b1**2*f**2*k3**4 + 8080*b1*f**3*k1**4 + 28656*b1*f**3*k1**2*k2**2 + 8080*b1*f**3*k1**2*k3**2 + 3664*b1*f**3*k1*k2**3*cos(3*theta) + 2*b1*f**3*k2**4*cos(4*theta) + 4422*b1*f**3*k2**4 + 4776*b1*f**3*k2**2*k3**2 + 3080*f**4*k1**4 + 10680*f**4*k1**2*k2**2 + 1640*f**4*k1*k2**3*cos(3*theta) + 49*f**4*k2**4*cos(4*theta) + 1587*f**4*k2**4 + 8*f*k1*k2*(4004*b1**3*k3**2 + 13*b1**2*f*(212*k1**2 + 195*k2**2 + 424*k3**2) + 2*b1*f**2*(2020*k1**2 + 1791*k2**2 + 1010*k3**2) + 5*f**3*(308*k1**2 + 267*k2**2))*cos(theta) + 4*f*k2**2*(858*b1**3*k3**2 + 13*b1**2*f*(246*k1**2 + 29*k2**2 + 164*k3**2) + 2*b1*f**2*(2478*k1**2 + 457*k2**2 + 413*k3**2) + f**3*(1950*k1**2 + 361*k2**2))*cos(2*theta)) + 646*k3**4*(17160*b1**2 + 16016*b1*f + 5512*f**2)) + 323*D1**2*Pk2*nbar*(D1**2*Pk3*nbar*(34320*b1**4*k3**4 + 32032*b1**3*f*k1**2*k3**2 + 25168*b1**3*f*k2**2*k3**2 + 25168*b1**3*f*k3**4 + 11024*b1**2*f**2*k1**4 + 40560*b1**2*f**2*k1**2*k2**2 + 27040*b1**2*f**2*k1**2*k3**2 + 3536*b1**2*f**2*k1*k2**3*cos(3*theta) + 7072*b1**2*f**2*k1*k2*k3**2*cos(3*theta) + 130*b1**2*f**2*k2**4*cos(4*theta) + 7878*b1**2*f**2*k2**4 + 520*b1**2*f**2*k2**2*k3**2*cos(4*theta) + 31512*b1**2*f**2*k2**2*k3**2 + 130*b1**2*f**2*k3**4*cos(4*theta) + 7878*b1**2*f**2*k3**4 + 9552*b1*f**3*k1**4 + 7328*b1*f**3*k1**3*k2*cos(3*theta) + 24*b1*f**3*k1**2*k2**2*cos(4*theta) + 53064*b1*f**3*k1**2*k2**2 + 4*b1*f**3*k1**2*k3**2*cos(4*theta) + 8844*b1*f**3*k1**2*k3**2 + 7080*b1*f**3*k1*k2**3*cos(3*theta) - 1400*b1*f**3*k1*k2**3*cos(5*theta) + 3540*b1*f**3*k1*k2*k3**2*cos(3*theta) - 700*b1*f**3*k1*k2*k3**2*cos(5*theta) + 150*b1*f**3*k2**4*cos(4*theta) - 375*b1*f**3*k2**4*cos(6*theta) + 11450*b1*f**3*k2**4 + 150*b1*f**3*k2**2*k3**2*cos(4*theta) - 375*b1*f**3*k2**2*k3**2*cos(6*theta) + 11450*b1*f**3*k2**2*k3**2 + 98*f**4*k1**4*cos(4*theta) + 3174*f**4*k1**4 + 3860*f**4*k1**3*k2*cos(3*theta) - 380*f**4*k1**3*k2*cos(5*theta) - 270*f**4*k1**2*k2**2*cos(4*theta) - 525*f**4*k1**2*k2**2*cos(6*theta) + 19710*f**4*k1**2*k2**2 + 3045*f**4*k1*k2**3*cos(3*theta) - 1225*f**4*k1*k2**3*cos(5*theta) - 175*f**4*k1*k2**3*cos(7*theta) - 350*f**4*k2**4*cos(6*theta) + 4480*f**4*k2**4 + f*k1*k2*(64064*b1**3*k3**2 + 208*b1**2*f*(212*k1**2 + 195*k2**2 + 390*k3**2) + 8*b1*f**2*(7164*k1**2 + 7370*k2**2 + 3685*k3**2) + 5*f**3*(4232*k1**2 + 4599*k2**2))*cos(theta) + f*(6864*b1**3*k3**2*(k2**2 + k3**2) + 104*b1**2*f*(82*k1**2*(3*k2**2 + 2*k3**2) + 29*k2**4 + 116*k2**2*k3**2 + 29*k3**4) + b1*f**2*(6608*k1**4 + 7312*k1**2*(6*k2**2 + k3**2) + 4935*k2**2*(k2**2 + k3**2)) + f**3*(2888*k1**4 + 18045*k1**2*k2**2 + 2030*k2**4))*cos(2*theta)) + 26*k3**4*(1320*b1**2 + 968*b1*f + 5*f**2*cos(4*theta) + 303*f**2 + 4*f*(66*b1 + 29*f)*cos(2*theta))) + 8398*D1**2*Pk3*nbar*(1320*b1**2*k3**4 + 1232*b1*f*k1**2*k3**2 + 968*b1*f*k2**2*k3**2 + 424*f**2*k1**4 + 1560*f**2*k1**2*k2**2 + 136*f**2*k1*k2**3*cos(3*theta) + 5*f**2*k2**4*cos(4*theta) + 303*f**2*k2**4 + 8*f*k1*k2*(308*b1*k3**2 + 212*f*k1**2 + 195*f*k2**2)*cos(theta) + 4*f*k2**2*(66*b1*k3**2 + 246*f*k1**2 + 29*f*k2**2)*cos(2*theta)) + 11085360*k3**4)/(2771340*Ntri*k3**4*nbar**3)
50
+ return expr
51
+
52
+
53
+ def N32(params,nbar,Ntri):
54
+ k1,k2,k3,theta,Pk1,Pk2,Pk3,Pkd1,Pkd2,Pkd3,Pkdd1,Pkdd2,Pkdd3,d,K,C,f,D1,b1,b2,g2 = params
55
+
56
+ cos = lambda x: np.cos(x)
57
+ sin = lambda x: np.sin(x)
58
+
59
+ expr = np.pi*(D1**2*Pk1*nbar*(D1**2*Pk2*nbar*(D1**2*Pk3*nbar*(1108536*b1**6*k3**4 + 739024*b1**5*f*k1**2*k3**2 + 739024*b1**5*f*k2**2*k3**2 + 1478048*b1**5*f*k3**4 + 167960*b1**4*f**2*k1**4 + 806208*b1**4*f**2*k1**2*k2**2 + 1209312*b1**4*f**2*k1**2*k3**2 - 134368*b1**4*f**2*k1*k2**3*cos(3*theta) - 268736*b1**4*f**2*k1*k2*k3**2*cos(3*theta) - 29393*b1**4*f**2*k2**4*cos(4*theta) + 214149*b1**4*f**2*k2**4 - 117572*b1**4*f**2*k2**2*k3**2*cos(4*theta) + 1394068*b1**4*f**2*k2**2*k3**2 - 29393*b1**4*f**2*k3**4*cos(4*theta) + 919581*b1**4*f**2*k3**4 + 310080*b1**3*f**3*k1**4 - 51680*b1**3*f**3*k1**3*k2*cos(3*theta) - 143412*b1**3*f**3*k1**2*k2**2*cos(4*theta) + 1740324*b1**3*f**3*k1**2*k2**2 - 23902*b1**3*f**3*k1**2*k3**2*cos(4*theta) + 858534*b1**3*f**3*k1**2*k3**2 - 368220*b1**3*f**3*k1*k2**3*cos(3*theta) - 32300*b1**3*f**3*k1*k2**3*cos(5*theta) - 261630*b1**3*f**3*k1*k2*k3**2*cos(3*theta) - 16150*b1**3*f**3*k1*k2*k3**2*cos(5*theta) - 101422*b1**3*f**3*k2**4*cos(4*theta) + 4845*b1**3*f**3*k2**4*cos(6*theta) + 458014*b1**3*f**3*k2**4 - 173128*b1**3*f**3*k2**2*k3**2*cos(4*theta) + 4845*b1**3*f**3*k2**2*k3**2*cos(6*theta) + 1069776*b1**3*f**3*k2**2*k3**2 - 23902*b1**3*f**3*k3**4*cos(4*theta) + 290054*b1**3*f**3*k3**4 - 4845*b1**2*f**4*k1**4*cos(4*theta) + 238697*b1**2*f**4*k1**4 - 35530*b1**2*f**4*k1**3*k2*cos(3*theta) - 12274*b1**2*f**4*k1**3*k2*cos(5*theta) - 215118*b1**2*f**4*k1**2*k2**2*cos(4*theta) - 1938*b1**2*f**4*k1**2*k2**2*cos(6*theta) + 1509702*b1**2*f**4*k1**2*k2**2 - 19380*b1**2*f**4*k1**2*k3**2*cos(4*theta) + 303620*b1**2*f**4*k1**2*k3**2 - 298129*b1**2*f**4*k1*k2**3*cos(3*theta) - 73967*b1**2*f**4*k1*k2**3*cos(5*theta) + 2261*b1**2*f**4*k1*k2**3*cos(7*theta) - 71060*b1**2*f**4*k1*k2*k3**2*cos(3*theta) - 24548*b1**2*f**4*k1*k2*k3**2*cos(5*theta) - 111435*b1**2*f**4*k2**4*cos(4*theta) + 3230*b1**2*f**4*k2**4*cos(6*theta) + 378879*b1**2*f**4*k2**4 - 85272*b1**2*f**4*k2**2*k3**2*cos(4*theta) - 1292*b1**2*f**4*k2**2*k3**2*cos(6*theta) + 385016*b1**2*f**4*k2**2*k3**2 - 4845*b1**2*f**4*k3**4*cos(4*theta) + 39729*b1**2*f**4*k3**4 - 3990*b1*f**5*k1**4*cos(4*theta) + 90174*b1*f**5*k1**4 + 4788*b1*f**5*k1**3*k2*cos(3*theta) - 14364*b1*f**5*k1**3*k2*cos(5*theta) - 107388*b1*f**5*k1**2*k2**2*cos(4*theta) - 7638*b1*f**5*k1**2*k2**2*cos(6*theta) + 612636*b1*f**5*k1**2*k2**2 - 3990*b1*f**5*k1**2*k3**2*cos(4*theta) + 45486*b1*f**5*k1**2*k3**2 - 84588*b1*f**5*k1*k2**3*cos(3*theta) - 53732*b1*f**5*k1*k2**3*cos(5*theta) + 532*b1*f**5*k1*k2**3*cos(7*theta) - 3990*b1*f**5*k1*k2*k3**2*cos(3*theta) - 7182*b1*f**5*k1*k2*k3**2*cos(5*theta) - 49552*b1*f**5*k2**4*cos(4*theta) - 2337*b1*f**5*k2**4*cos(6*theta) + 266*b1*f**5*k2**4*cos(8*theta) + 143070*b1*f**5*k2**4 - 13908*b1*f**5*k2**2*k3**2*cos(4*theta) - 1273*b1*f**5*k2**2*k3**2*cos(6*theta) + 56620*b1*f**5*k2**2*k3**2 - 777*f**6*k1**4*cos(4*theta) + 14301*f**6*k1**4 + 4830*f**6*k1**3*k2*cos(3*theta) - 4074*f**6*k1**3*k2*cos(5*theta) - 18018*f**6*k1**2*k2**2*cos(4*theta) - 3108*f**6*k1**2*k2**2*cos(6*theta) + 98490*f**6*k1**2*k2**2 - 6615*f**6*k1*k2**3*cos(3*theta) - 11809*f**6*k1*k2**3*cos(5*theta) - 385*f**6*k1*k2**3*cos(7*theta) - 7742*f**6*k2**4*cos(4*theta) - 1162*f**6*k2**4*cos(6*theta) + 49*f**6*k2**4*cos(8*theta) + 21805*f**6*k2**4 + f**2*(16796*b1**4*(4*k1**2*(3*k2**2 + 2*k3**2) - k2**4 + 4*k2**2*k3**2 + 7*k3**4) + 323*b1**3*f*(160*k1**4 + 8*k1**2*(222*k2**2 + 97*k3**2) + k2**4 + 569*k2**2*k3**2 + 296*k3**4) + 646*b1**2*f**2*(142*k1**4 + k1**2*(1023*k2**2 + 232*k3**2) + 85*k2**4 + 210*k2**2*k3**2 + 30*k3**4) + 19*b1*f**3*(2856*k1**4 + 18*k1**2*(1009*k2**2 + 84*k3**2) + 2579*k2**4 + 1515*k2**2*k3**2) + 14*f**4*(750*k1**4 + 4770*k1**2*k2**2 + 791*k2**4))*cos(2*theta) + f*k1*k2*(1478048*b1**5*k3**2 + 134368*b1**4*f*(5*k1**2 + 6*k2**2 + 22*k3**2) + 6460*b1**3*f**2*(232*k1**2 + 286*k2**2 + 379*k3**2) + 323*b1**2*f**3*(4180*k1**2 + 5177*k2**2 + 2984*k3**2) + 532*b1*f**4*(1074*k1**2 + 1315*k2**2 + 285*k3**2) + 35*f**5*(2724*k1**2 + 3283*k2**2))*cos(theta)) + 323*k3**4*(3432*b1**4 + 4576*b1**3*f + 2847*b1**2*f**2 + 898*b1*f**3 + 123*f**4 + 4*f**2*(91*b1**2 + 74*b1*f + 15*f**2)*cos(2*theta) - f**2*(91*b1**2 + 74*b1*f + 15*f**2)*cos(4*theta))) + 323*D1**2*Pk3*nbar*(3432*b1**4*k3**4 + 2288*b1**3*f*k1**2*k3**2 + 2288*b1**3*f*k2**2*k3**2 + 2288*b1**3*f*k3**4 + 520*b1**2*f**2*k1**4 + 2496*b1**2*f**2*k1**2*k2**2 + 2080*b1**2*f**2*k1**2*k3**2 - 416*b1**2*f**2*k1*k2**3*cos(3*theta) - 91*b1**2*f**2*k2**4*cos(4*theta) + 663*b1**2*f**2*k2**4 + 1664*b1**2*f**2*k2**2*k3**2 + 520*b1**2*f**2*k3**4 + 560*b1*f**3*k1**4 + 2400*b1*f**3*k1**2*k2**2 + 560*b1*f**3*k1**2*k3**2 - 160*b1*f**3*k1*k2**3*cos(3*theta) - 74*b1*f**3*k2**4*cos(4*theta) + 498*b1*f**3*k2**4 + 400*b1*f**3*k2**2*k3**2 + 168*f**4*k1**4 + 672*f**4*k1**2*k2**2 - 15*f**4*k2**4*cos(4*theta) + 123*f**4*k2**4 + 4*f**2*k2**2*(13*b1**2*(12*k1**2 - k2**2 + 8*k3**2) + 2*b1*f*(120*k1**2 + 17*k2**2 + 20*k3**2) + 3*f**2*(28*k1**2 + 5*k2**2))*cos(2*theta) + 32*f*k1*k2*(143*b1**3*k3**2 + 13*b1**2*f*(5*k1**2 + 6*k2**2 + 10*k3**2) + 5*b1*f**2*(14*k1**2 + 15*k2**2 + 7*k3**2) + 21*f**3*(k1**2 + k2**2))*cos(theta)) + 323*k3**4*(3432*b1**2 + 2288*b1*f + 520*f**2)) + 323*D1**2*Pk2*nbar*(D1**2*Pk3*nbar*(3432*b1**4*k3**4 + 2288*b1**3*f*k1**2*k3**2 + 2288*b1**3*f*k2**2*k3**2 + 2288*b1**3*f*k3**4 + 520*b1**2*f**2*k1**4 + 2496*b1**2*f**2*k1**2*k2**2 + 1664*b1**2*f**2*k1**2*k3**2 - 416*b1**2*f**2*k1*k2**3*cos(3*theta) - 832*b1**2*f**2*k1*k2*k3**2*cos(3*theta) - 91*b1**2*f**2*k2**4*cos(4*theta) + 663*b1**2*f**2*k2**4 - 364*b1**2*f**2*k2**2*k3**2*cos(4*theta) + 2652*b1**2*f**2*k2**2*k3**2 - 91*b1**2*f**2*k3**4*cos(4*theta) + 663*b1**2*f**2*k3**4 + 400*b1*f**3*k1**4 - 160*b1*f**3*k1**3*k2*cos(3*theta) - 444*b1*f**3*k1**2*k2**2*cos(4*theta) + 2988*b1*f**3*k1**2*k2**2 - 74*b1*f**3*k1**2*k3**2*cos(4*theta) + 498*b1*f**3*k1**2*k3**2 - 980*b1*f**3*k1*k2**3*cos(3*theta) - 100*b1*f**3*k1*k2**3*cos(5*theta) - 490*b1*f**3*k1*k2*k3**2*cos(3*theta) - 50*b1*f**3*k1*k2*k3**2*cos(5*theta) - 240*b1*f**3*k2**4*cos(4*theta) + 15*b1*f**3*k2**4*cos(6*theta) + 920*b1*f**3*k2**4 - 240*b1*f**3*k2**2*k3**2*cos(4*theta) + 15*b1*f**3*k2**2*k3**2*cos(6*theta) + 920*b1*f**3*k2**2*k3**2 - 15*f**4*k1**4*cos(4*theta) + 123*f**4*k1**4 - 110*f**4*k1**3*k2*cos(3*theta) - 38*f**4*k1**3*k2*cos(5*theta) - 306*f**4*k1**2*k2**2*cos(4*theta) - 6*f**4*k1**2*k2**2*cos(6*theta) + 1050*f**4*k1**2*k2**2 - 483*f**4*k1*k2**3*cos(3*theta) - 77*f**4*k1*k2**3*cos(5*theta) + 7*f**4*k1*k2**3*cos(7*theta) - 126*f**4*k2**4*cos(4*theta) + 14*f**4*k2**4*cos(6*theta) + 350*f**4*k2**4 + f**2*(-52*b1**2*(-4*k1**2*(3*k2**2 + 2*k3**2) + k2**4 + 4*k2**2*k3**2 + k3**4) + b1*f*(160*k1**4 + 136*k1**2*(6*k2**2 + k3**2) - 135*k2**2*(k2**2 + k3**2)) + 10*f**2*(6*k1**4 + 27*k1**2*k2**2 - 7*k2**4))*cos(2*theta) + f*k1*k2*(4576*b1**3*k3**2 + 416*b1**2*f*(5*k1**2 + 6*k2**2 + 12*k3**2) + 20*b1*f**2*(120*k1**2 + 166*k2**2 + 83*k3**2) + 5*f**3*(164*k1**2 + 245*k2**2))*cos(theta)) + 13*k3**4*(264*b1**2 + 176*b1*f - 4*f**2*cos(2*theta) - 7*f**2*cos(4*theta) + 51*f**2)) + 4199*D1**2*Pk3*nbar*(264*b1**2*k3**4 + 176*b1*f*k1**2*k3**2 + 176*b1*f*k2**2*k3**2 + 40*f**2*k1**4 + 192*f**2*k1**2*k2**2 - 32*f**2*k1*k2**3*cos(3*theta) - 7*f**2*k2**4*cos(4*theta) + 51*f**2*k2**4 - 4*f**2*k2**2*(-12*k1**2 + k2**2)*cos(2*theta) + 32*f*k1*k2*(11*b1*k3**2 + 5*f*k1**2 + 6*f*k2**2)*cos(theta)) + 1108536*k3**4)/(277134*Ntri*k3**4*nbar**3)
60
+ return expr
@@ -0,0 +1,10 @@
1
+ 5.000000000000000278e-02 1.175799999999999983e+02 1.089999999999999997e-01 7.600000000000000089e-01 -5.950000000000000178e+00
2
+ 1.000000000000000056e-01 1.133299999999999983e+02 3.699999999999999817e-02 1.300000000000000044e+00 -8.150000000000000355e+00
3
+ 1.499999999999999944e-01 1.095300000000000011e+02 1.480000000000000066e-02 1.739999999999999991e+00 -7.849999999999999645e+00
4
+ 2.000000000000000111e-01 1.061400000000000006e+02 6.420000000000000359e-03 2.140000000000000124e+00 -7.620000000000000107e+00
5
+ 2.500000000000000000e-01 1.031099999999999994e+02 2.909999999999999826e-03 2.529999999999999805e+00 -7.629999999999999893e+00
6
+ 2.999999999999999889e-01 1.003900000000000006e+02 1.360000000000000098e-03 2.919999999999999929e+00 -7.839999999999999858e+00
7
+ 3.499999999999999778e-01 9.795999999999999375e+01 6.560000000000000076e-04 3.290000000000000036e+00 -8.029999999999999361e+00
8
+ 4.000000000000000222e-01 9.579000000000000625e+01 3.220000000000000206e-04 3.629999999999999893e+00 -7.990000000000000213e+00
9
+ 4.500000000000000111e-01 9.384999999999999432e+01 1.600000000000000131e-04 3.939999999999999947e+00 -7.879999999999999893e+00
10
+ 5.000000000000000000e-01 9.210999999999999943e+01 8.059999999999999402e-05 4.240000000000000213e+00 -7.759999999999999787e+00
@@ -0,0 +1,20 @@
1
+ 1.000000000000000056e-01 6.240000000000000213e+00 2.919999999999999818e-01 1.600000000000000033e-01 3.089999999999999858e+00
2
+ 2.000000000000000111e-01 5.849999999999999645e+00 1.620000000000000051e-01 3.400000000000000244e-01 2.490000000000000213e+00
3
+ 2.999999999999999889e-01 5.540000000000000036e+00 9.400000000000000022e-02 5.100000000000000089e-01 2.149999999999999911e+00
4
+ 4.000000000000000222e-01 5.280000000000000249e+00 5.589999999999999830e-02 7.299999999999999822e-01 1.540000000000000036e+00
5
+ 5.000000000000000000e-01 5.080000000000000071e+00 3.400000000000000244e-02 9.799999999999999822e-01 8.499999999999999778e-01
6
+ 5.999999999999999778e-01 4.919999999999999929e+00 2.100000000000000130e-02 1.239999999999999991e+00 2.200000000000000011e-01
7
+ 6.999999999999999556e-01 4.790000000000000036e+00 1.310000000000000053e-02 1.489999999999999991e+00 -2.600000000000000089e-01
8
+ 8.000000000000000444e-01 4.679999999999999716e+00 8.179999999999999771e-03 1.739999999999999991e+00 -6.099999999999999867e-01
9
+ 9.000000000000000222e-01 4.610000000000000320e+00 5.130000000000000011e-03 1.979999999999999982e+00 -8.699999999999999956e-01
10
+ 1.000000000000000000e+00 4.549999999999999822e+00 3.210000000000000180e-03 2.220000000000000195e+00 -1.060000000000000053e+00
11
+ 1.100000000000000089e+00 4.509999999999999787e+00 2.000000000000000042e-03 2.450000000000000178e+00 -1.219999999999999973e+00
12
+ 1.199999999999999956e+00 4.490000000000000213e+00 1.240000000000000000e-03 2.689999999999999947e+00 -1.340000000000000080e+00
13
+ 1.300000000000000044e+00 4.480000000000000426e+00 7.619999999999999820e-04 2.930000000000000160e+00 -1.449999999999999956e+00
14
+ 1.399999999999999911e+00 4.490000000000000213e+00 4.629999999999999784e-04 3.180000000000000160e+00 -1.550000000000000044e+00
15
+ 1.500000000000000000e+00 4.500000000000000000e+00 2.790000000000000054e-04 3.439999999999999947e+00 -1.639999999999999902e+00
16
+ 1.600000000000000089e+00 4.530000000000000249e+00 1.659999999999999963e-04 3.700000000000000178e+00 -1.729999999999999982e+00
17
+ 1.699999999999999956e+00 4.559999999999999609e+00 9.710000000000000206e-05 3.970000000000000195e+00 -1.810000000000000053e+00
18
+ 1.800000000000000044e+00 4.610000000000000320e+00 5.610000000000000159e-05 4.240000000000000213e+00 -1.889999999999999902e+00
19
+ 1.899999999999999911e+00 4.660000000000000142e+00 3.199999999999999855e-05 4.519999999999999574e+00 -1.949999999999999956e+00
20
+ 2.000000000000000000e+00 4.719999999999999751e+00 1.800000000000000046e-05 4.799999999999999822e+00 -1.979999999999999982e+00
@@ -0,0 +1,14 @@
1
+ 0.7 -4.31 1.66 2.76 2.82 4.81
2
+ 0.8 -4.74 1.87 2.04 3.38 4.72
3
+ 0.9 -5.17 2.08 1.53 3.70 4.62
4
+ 1.0 -5.60 2.30 1.16 4.08 4.51
5
+ 1.1 -6.02 2.51 0.880 4.42 4.39
6
+ 1.2 -6.45 2.72 0.680 4.72 4.27
7
+ 1.3 -6.76 2.94 0.520 4.98 4.15
8
+ 1.4 -5.29 3.14 0.380 5.20 4.03
9
+ 1.5 -5.70 3.35 0.260 5.38 3.92
10
+ 1.6 -6.10 3.55 0.200 5.54 3.81
11
+ 1.7 -6.50 3.75 0.150 5.67 3.70
12
+ 1.8 -6.89 3.94 0.110 5.77 3.61
13
+ 1.9 -7.27 4.13 0.0900 5.85 3.49
14
+ 2.0 -7.64 4.32 0.0700 6.92 3.40
cosmo_wap/integrate.py ADDED
@@ -0,0 +1,43 @@
1
+ #for numerical angular derivates - usfule for FOG and consistency otherwise precompute analytic are quicker
2
+ def bk_ylm(func,l,m,params,derivs,betas,r=0,s=0,sigma=None,paramsPNG=[]):
3
+ """
4
+ does numerical integration with double legendre gauss integration implemented in int_gl_dbl()
5
+ is vectorised just last two axes need to be dimension 1
6
+ """
7
+
8
+ def int_gl_dbl(func,*args):
9
+ """
10
+ implements double legendre guass integral for mu and phi integrals - extension and specialiation
11
+ of integrate.fixed_quad()
12
+ """
13
+ n=16
14
+
15
+ nodes, weights = np.polynomial.legendre.leggauss(n)#legendre gauss - get nodes and weights for given n
16
+ nodes = np.real(nodes)
17
+ mesh_nodes1,mesh_nodes2 = np.meshgrid(nodes,nodes,indexing ='ij') #mesh gridding as 2d
18
+ mesh_weights1,mesh_weights2 = np.meshgrid(weights,weights,indexing ='ij')
19
+
20
+ phi_nodes = (2*np.pi)*(mesh_nodes1+1)/2.0 #sample phi range [0,2*np.pi]
21
+ mu_nodes = (2)*(mesh_nodes2+1)/2.0 - 1 # sample mu range [-1,1] - so this is the natural gauss legendre range!
22
+
23
+ return (2*np.pi)/2.0 * np.sum(mesh_weights1*mesh_weights2*func(phi_nodes, mu_nodes, *args), axis=(-2,-1)) #sum over last two axes (mu and phi)
24
+
25
+ k1,k2,k3,theta,Pk1,Pk2,Pk3,Pkd1,Pkd2,Pkd3,Pkdd1,Pkdd2,Pkdd3,d,K,C,f,D1,b1,b2,g2 = params
26
+ def integrand(phi,mu,*args):
27
+ ylm = scipy.special.sph_harm(m, l, phi, np.arccos(mu))
28
+ expression = func(*args,mu,phi)
29
+
30
+ if sigma is None: #no FOG
31
+ dfog_val = 1
32
+ else:
33
+ mu2 = mu*np.cos(theta)+ (1-mu**2)**(1/2) *np.sin(theta)*np.cos(phi)
34
+ mu3 = -(mu*k1+mu2*k2)/k3
35
+ dfog_val = np.exp(-(1/2)*((k1*mu)**2+(k2 *mu2)**2+(k3 *mu3)**2)*sigma**2)
36
+
37
+ return np.conjugate(ylm)*expression*dfog_val
38
+
39
+ args = get_args(func,params,derivs,betas,r,s,paramsPNG=paramsPNG) # get necessary args for the func
40
+
41
+ result = int_gl_dbl(integrand,*args)
42
+
43
+ return result
cosmo_wap/main.py ADDED
@@ -0,0 +1,379 @@
1
+ import numpy as np
2
+ import scipy
3
+ from scipy.interpolate import interp1d
4
+ from scipy.integrate import odeint
5
+
6
+ from cosmo_wap.peak_background_bias import *
7
+ from cosmo_wap.survey_params import *
8
+
9
+ #from useful_funcs import *
10
+
11
+ class CosmoWAP:
12
+ """
13
+ Main functions - takes in cosmology from CLASS and bias models and then can called to generate cosmology (f,P(k),P'(k),D(z) etc) and all other biases including relativstic parts
14
+
15
+ """
16
+ def __init__(self,cosmo,survey_params={},compute_bias=True):
17
+ """
18
+ Inputs CLASS and bias dict to return all bias and cosmological parameters defined within the class object
19
+
20
+ """
21
+ self.cosmo = cosmo
22
+ baLCDM = cosmo.get_background()
23
+
24
+ D_cl = baLCDM['gr.fac. D']
25
+ z_cl = baLCDM['z']
26
+ self.D_intp = interp1d(z_cl,D_cl,kind='cubic')
27
+
28
+ f_cl = baLCDM['gr.fac. f']
29
+ D_cl = baLCDM['gr.fac. D']
30
+ z_cl = baLCDM['z']
31
+ H_cl = baLCDM['H [1/Mpc]']
32
+ xi_cl = baLCDM['comov. dist.']
33
+ t_cl = baLCDM['conf. time [Mpc]']
34
+
35
+ self.z_cl = z_cl#save for later
36
+ self.Om_0 = cosmo.get_current_derived_parameters(['Omega_m'])['Omega_m']
37
+ self.h = cosmo.get_current_derived_parameters(['h'])['h']
38
+
39
+ #define functions and add in h
40
+ self.H_c = interp1d(z_cl,H_cl*(1/(1+z_cl))/self.h,kind='cubic') # now in h/Mpc!#is conformal
41
+ self.dH_c = interp1d(z_cl,np.gradient(H_cl*(1/(1+z_cl))/self.h,z_cl),kind='cubic') # derivative wrt z
42
+ self.ddH_c = interp1d(z_cl,np.gradient(self.dH_c(z_cl),z_cl),kind='cubic') # second derivative wrt z
43
+ self.comoving_dist = interp1d(z_cl,xi_cl*self.h,kind='cubic') # just use class background as quick
44
+ self.d_to_z = interp1d(xi_cl*self.h,z_cl,kind='cubic') # useful to map other way
45
+ self.f_intp = interp1d(z_cl,f_cl,kind='cubic')#get f #omega_mz = Omega_m *(1+zt)**3 /(Omega_m *(1+zt)**3 + Omega_l)
46
+ self.D_intp = interp1d(z_cl,D_cl,kind='cubic')
47
+ self.dD_dz = interp1d(z_cl,np.gradient(D_cl,z_cl),kind='cubic')
48
+ self.conf_time = interp1d(z_cl,self.h*t_cl,kind='cubic')#convert between the two
49
+ #misc
50
+ self.c = 2.99792e+5 #km/s
51
+ self.H0 = 100/self.c #[h/Mpc]
52
+ self.Om = lambda xx: self.Om_0 * (self.H0**2 / self.H_c(xx)**2) * (1+xx)
53
+
54
+ #for critical density
55
+ GG = 4.300917e-3 #[pc SolarMass (km/s)^2]
56
+ self.G = GG/(1e+6*self.c**2)#gravitational constant
57
+ self.rho_crit = lambda xx: 3*self.H_c(xx)**2/(8*np.pi*self.G) #in units of h^3 Mo/ Mpc^3 where Mo is solar mass
58
+ self.rho_m = lambda xx: self.rho_crit(xx)*self.Om(xx) #in units of h^3 Mo/ Mpc^3
59
+
60
+ #######################################################################################################
61
+
62
+ #setup surveys and compute all bias params including for multi tracer case...
63
+ self = self.setup_survey(survey_params, compute_bias, cosmo_functions)
64
+
65
+ # get bias funcs for given surveys
66
+ if len(survey_params) == 1:
67
+ survey_params = survey_params[0]
68
+
69
+ if compute_bias:
70
+ print("Computing bias params...")
71
+ self.survey = PBBias(cosmo_functions)
72
+ self.survey = SurveyFunctions(survey_params,False)
73
+ else:
74
+ self.survey = SurveyFunctions(survey_params)
75
+
76
+ try survey1 = survey_params[1]:
77
+ if compute_bias:
78
+ print("Computing bias params...")
79
+ self.survey1 = PBBias(cosmo_functions,"survey1")
80
+ self.survey1 = SurveyFunctions(survey1,False)
81
+ else:
82
+ self.survey1 = SurveyFunctions(survey1)
83
+ except:
84
+ self.survey1 = self.survey
85
+
86
+ #get ranges of cross survey
87
+ z_min = max([self.survey.z_survey[0],self.survey1.z_survey[0]])
88
+ z_max = min([self.survey.z_survey[1],self.survey1.z_survey[1]])
89
+ if z_min > z_max:
90
+ raise ValueError("incompatible survey redshifts.")
91
+ self.z_survey = np.linspace(z_min,z_max,int(1e+5))
92
+ self.f_sky = min([self.survey.f_sky,self.survey1.f_sky])
93
+
94
+ ####################################################################################################
95
+ #get power spectras
96
+ def get_class_powerspectrum(kk,zz=0): #h are needed to convert to 1/Mpc for k then convert pk back to (Mpc/h)^3
97
+ return np.array([self.cosmo.pk_lin(ki, zz) for ki in kk*self.h])*self.h**3
98
+
99
+ def get_Pk_NL(k,z=0): # for halofit non-linear power spectrum
100
+ pk_nl = interp1d(k,np.array([self.cosmo.pk(ki, z) for ki in k*self.h])*self.h**3)
101
+ return pk_nl
102
+
103
+ def get_pkinfo_z(k,z):
104
+ """get Pk and its k derivatives"""
105
+ Plin = get_class_powerspectrum(k,0)#just always get present day power spectrum
106
+ Pk = interp1d(k,Plin)#get linear power spectrum
107
+ Pk_d = interp1d(k,np.gradient(Plin,k))
108
+ Pk_dd = interp1d(k,np.gradient(Pk_d(k),k))
109
+ return Pk,Pk_d,Pk_dd
110
+
111
+ K_MAX = 100
112
+ k = np.logspace(-5, np.log10(K_MAX), num=1000)
113
+ self.Pk,self.Pk_d,self.Pk_dd = get_pkinfo_z(k,0)
114
+ self.Pk_L = get_class_powerspectrum
115
+ self.Pk_NL = get_Pk_NL(k,0) #if you want HALOFIT P(k)
116
+
117
+ #getter functions and their requisites
118
+ ###########################################################
119
+ def _process_survey(self, survey, compute_bias, cosmo_functions, label="survey"):
120
+ if compute_bias:
121
+ print(f"Computing bias params for {label}...")
122
+ survey_bias = PBBias(cosmo_functions, label)
123
+ return SurveyFunctions(survey, False)
124
+ else:
125
+ return SurveyFunctions(survey)
126
+
127
+ # Get bias functions for given surveys allowing for two surveys...
128
+ def setup_survey(self, survey_params, compute_bias, cosmo_functions):
129
+ # If survey_params is a list
130
+ if len(survey_params) > 0:
131
+ survey = survey_params[0]
132
+ else:
133
+ survey = survey_params
134
+
135
+ # Process first survey (or only survey)
136
+ self.survey = self._process_survey(survey, compute_bias, cosmo_functions)
137
+
138
+ # Check for additional surveys
139
+ if len(survey_params) > 1:
140
+ self.survey1 = self._process_survey(survey_params[1], compute_bias, cosmo_functions, label="survey1")
141
+ else: #is same as first
142
+ self.survey1 = self.survey
143
+
144
+ return self
145
+
146
+ #######################################################################################################
147
+
148
+ def Pk_phi(self,k, k0=0.05, units=True):
149
+ """Power spectrum of the Bardeen potential Phi in the matter-dominated era - k in units of h/Mpc.
150
+ """
151
+ k_pivot = k0/self.h
152
+ resp = (9.0/25.0) * self.cosmo.get_current_derived_parameters(['A_s'])['A_s'] * (k/k_pivot)**(self.cosmo.get_current_derived_parameters(['n_s'])['n_s'] - 1.0)
153
+
154
+ if units:
155
+ resp *= 2*np.pi**2.0/k**3.0 #[Mpc/h]^3
156
+
157
+ return resp
158
+
159
+ def M(self,k, z):
160
+ """The scaling factor between the primordial scalar power spectrum and the late-time matter power spectrum
161
+ """
162
+ return np.sqrt(self.D_intp(z)**2 *self.Pk(k) / self.Pk_phi(k))
163
+
164
+ def solve_second_order_KC(self):
165
+ c = 2.99792*10**5 #km/s
166
+ def F_func(u,zz): # so variables are F and H and D
167
+ f,fd = u # unpack u vector
168
+ D_zz = self.D_intp(zz)
169
+ return [fd,(-self.H_c(zz)*self.dH_c(zz)*(1+zz)**2 *fd + ((3*(self.H0)**2 * self.Om_0 *(1+zz))/(2))*(f+D_zz**2))/(self.H_c(zz)**2 *(1+zz)**2)]
170
+
171
+ odeint_zz = np.linspace(20,0.05,int(1e+5))# so z=20 should be pretty much matter dominated
172
+
173
+ #set initial params for F
174
+ F0 = [(3/7)*self.D_intp(odeint_zz[0])**2,(3/7)*2*self.D_intp(odeint_zz[0])*self.dD_dz(odeint_zz[0])]
175
+ sol1 = odeint(F_func,F0,odeint_zz)
176
+ K = (sol1[:,0]/self.D_intp(odeint_zz)**2)
177
+ C = sol1[:,1]/(2*self.D_intp(odeint_zz)*self.dD_dz(odeint_zz))
178
+ self.K_intp = interp1d(odeint_zz,K,kind='cubic')
179
+ self.C_intp = interp1d(odeint_zz,C,kind='cubic')
180
+
181
+ def lnd_derivatives(self,functions_to_differentiate):
182
+ """
183
+ calculates derivatives of a list of functions wrt log comoving dist numerically
184
+ """
185
+
186
+ # Store first derivatives in a list
187
+ function_derivatives = []
188
+
189
+ for func in functions_to_differentiate:
190
+ # Calculate numerical derivatives of the function with respect to ln(d)
191
+ derivative_func = interp1d(self.z_survey, np.gradient(func(self.z_survey), np.log(self.comoving_dist(self.z_survey))))
192
+ function_derivatives.append(derivative_func)
193
+
194
+ return function_derivatives
195
+
196
+ def get_params(self,k1,k2,k3=None,theta=None,zz=0,tracer = None,nonlin=False,growth2=False):
197
+ """
198
+ return arrays of redshift and k dependent parameters
199
+ """
200
+ if theta is None:
201
+ if k3 is None:
202
+ raise ValueError('Define either theta or k3')
203
+ else:
204
+ theta = np.arccos((k3**2 - k1**2 - k2**2)/(2*k1*k2))
205
+
206
+ if tracer is None:
207
+ tracer = self.survey
208
+
209
+ k3 = np.sqrt(k1**2 + k2**2 + 2*k1*k2*np.cos(theta))#get k3 from triangle condition
210
+ k3 = np.where(k3==0,1e-4,k3)
211
+
212
+ Pk1 = self.Pk(k1)
213
+ Pk2 = self.Pk(k2)
214
+ Pk3 = self.Pk(k3)
215
+
216
+ Pkd1 = self.Pk_d(k1)
217
+ Pkd2 = self.Pk_d(k2)
218
+ Pkd3 = self.Pk_d(k3)
219
+
220
+ Pkdd1= self.Pk_dd(k1)
221
+ Pkdd2 = self.Pk_dd(k2)
222
+ Pkdd3 = self.Pk_dd(k3)
223
+
224
+ if nonlin:
225
+ Pk1 = Pk_NL(k1)
226
+ Pk2 = Pk_NL(k2)
227
+ Pk3 = Pk_NL(k3)
228
+
229
+ #redshift dependendent terms
230
+ d = self.comoving_dist(zz)
231
+
232
+ K = 3/7 # from einstein-de-sitter
233
+ C = 3/7
234
+ if growth2:
235
+ self.solve_second_order_KC()#get K and C
236
+ K = self.K_intp(zz)
237
+ C = self.C_intp(zz)
238
+
239
+ f = self.f_intp(zz)
240
+ D1 = self.D_intp(zz)
241
+
242
+ #survey stuff
243
+ b1 = tracer.b_1(zz)
244
+ b2 = tracer.b_2(zz)
245
+ g2 = tracer.g_2(zz)
246
+ return k1,k2,k3,theta,Pk1,Pk2,Pk3,Pkd1,Pkd2,Pkd3,Pkdd1,Pkdd2,Pkdd3,d,K,C,f,D1,b1,b2,g2
247
+
248
+ def get_params_pk(self,k1,zz,nonlinear=False):
249
+ """
250
+ return arrays of redshift and k dependent parameters but just for single knitting vector
251
+ """
252
+
253
+ Pk1 = self.Pk(k1)
254
+ Pkd1 = self.Pk_d(k1)
255
+ Pkdd1= self.Pk_dd(k1)
256
+
257
+ if nonlinear:
258
+ Pk1 = Pk_NL(k1)
259
+
260
+ #redshift dependendent terms
261
+ d = self.comoving_dist(zz)
262
+
263
+
264
+ f = self.f_intp(zz)
265
+ D1 = self.D_intp(zz)
266
+
267
+ return k1,Pk1,Pkd1,Pkdd1,d,f,D1
268
+
269
+ def get_derivs(self,zz,tracer = None):
270
+ """
271
+ Derivatives of redshift dependent parameters for radial wide separation terms
272
+ """
273
+ if tracer is None:
274
+ tracer = self.survey
275
+
276
+ #get derivs of these redshift dependent functions
277
+ func_deriv_list = self.lnd_derivatives([tracer.b_1,tracer.b_2,tracer.g_2,self.f_intp,self.D_intp])
278
+ tracer.b1_d,tracer.b2_d,tracer.g2_d,self.f_d,self.D_d = func_deriv_list
279
+ func_second_deriv_list = self.lnd_derivatives(func_deriv_list)
280
+ tracer.b1_dd,tracer.b2_dd,tracer.g2_dd,self.f_dd,self.D_dd = func_second_deriv_list
281
+
282
+ #1st deriv
283
+ fd = self.f_d(zz)
284
+ Dd = self.D_d(zz)
285
+ gd2 = tracer.g2_d(zz)
286
+ bd2 = tracer.b2_d(zz)
287
+ bd1 = tracer.b1_d(zz)
288
+ #2nd deriv
289
+ fdd = self.f_dd(zz)
290
+ Ddd = self.D_dd(zz)
291
+ gdd2 = tracer.g2_dd(zz)
292
+ bdd2 = tracer.b2_dd(zz)
293
+ bdd1 = tracer.b1_dd(zz)
294
+ return fd,Dd,gd2,bd2,bd1,fdd,Ddd,gdd2,bdd2,bdd1
295
+
296
+ def get_PNGparams(self,fNL,zz,k1,k2,k3,tracer = None):
297
+ """
298
+ returns terms needed for local type fnl including scale dependent bias
299
+ """
300
+ if tracer is None:
301
+ tracer = self.survey
302
+
303
+ delta_c = 1.686
304
+ bL10 = lambda xx: tracer.b_1(xx) - 1
305
+ bL20 = lambda xx: tracer.b_2(xx) - (8/21)*bL10(xx)
306
+
307
+ bL01 = lambda xx: 2*delta_c*fNL*bL10(xx)
308
+ bL11 = lambda xx: 2*fNL*(delta_c*bL20(xx)-bL10(xx))
309
+ bL02 = lambda xx: 4*fNL**2 * delta_c*(delta_c*bL20(xx)-2*bL10(xx))
310
+
311
+ bE01 = bL01
312
+ bE11 = lambda xx: bL01(xx) + bL11(xx)
313
+ bE02 = bL02
314
+
315
+ alphak1 = self.M(k1, 0)
316
+ alphak2 = self.M(k2, 0)
317
+ alphak3 = self.M(k3, 0)
318
+ return fNL,1*bE01(zz),1*bE11(zz),1*bE02(zz),alphak1,alphak2,alphak3
319
+
320
+ def get_beta_funcs(self,zz,tracer = None):
321
+ """
322
+ Function that relies on biases and functions defined above to return beta coefficients (beta expressions adapted from Eline de Weerd GitHub) from paper 1711.01812v4
323
+ """
324
+ if tracer is None:
325
+ tracer = self.survey
326
+
327
+ #these derivs here are wrt to conformal time so we convert to derivs wrt to z
328
+ #d/dt = da/dt d/da = a H dz/da d/dz = -(1+z) H d/dz # everything here is conformal both t and H
329
+ #d^2/d^2 t = (1+z)^2 H^2 d^2/d z^2 + H(1+z)(H+(1+z)H')d/dz
330
+
331
+ dQ_dz = interp1d(self.z_survey,np.gradient(tracer.Q_survey(self.z_survey),self.z_survey))
332
+ dbe_dz = interp1d(self.z_survey,np.gradient(tracer.be_survey(self.z_survey),self.z_survey))
333
+ db1_dz = interp1d(self.z_survey,np.gradient(tracer.b_1(self.z_survey),self.z_survey))
334
+
335
+ dH_dt = lambda xx: -(1+xx)*self.H_c(xx)*self.dH_c(xx)
336
+ dH_dt2 = lambda xx: (1+xx)**2 *self.H_c(xx)**2 *self.ddH_c(xx)+self.H_c(xx)*(1+xx)*(self.H_c(xx)+(1+xx)*self.dH_c(xx))*self.dH_c(xx)#should just check with doing it numerically as is easier
337
+ #self.dH22 = interp1d(self.z_cl,np.gradient(dH_dt(self.z_cl),self.conf_time(self.z_cl)))
338
+ self.dH_dt = dH_dt
339
+ dQ_dt = lambda xx: -(1+xx)*self.H_c(xx)*dQ_dz(xx)
340
+ dbe_dt = lambda xx: -(1+xx)*self.H_c(xx)*dbe_dz(xx)#0*xx-1.6*1e-4
341
+ db1_dt = lambda xx: -(1+xx)*self.H_c(xx)*db1_dz(xx)
342
+
343
+ self.Q = tracer.Q_survey # bit silly but whatever
344
+ self.b_e = tracer.be_survey
345
+
346
+ partdQ=0
347
+ partdb1=0
348
+
349
+ #from 1st order petrubation theory
350
+ tracer.gr1 = lambda xx: self.H_c(xx)*self.f_intp(xx)*(self.b_e(xx)-2*self.Q(xx)-2*(1-self.Q(xx))/(self.comoving_dist(xx)*self.H_c(xx))-dH_dt(xx)/self.H_c(xx)**2)
351
+ tracer.gr2 = lambda xx: self.H_c(xx)**2 *(self.f_intp(xx)*(3-self.b_e(xx))+ (3/2)*self.Om(xx)*(2+self.b_e(xx)-self.f_intp(xx)-4*self.Q(xx)-2*self.Q(xx)-2*(1-self.Q(xx))/(self.comoving_dist(xx)*self.H_c(xx))-dH_dt(xx)/self.H_c(xx)**2))
352
+ tracer.grd1 = self.lnd_derivatives([tracer.gr1])[0]#get derivative for 1st order coef
353
+
354
+ beta = np.empty(20,dtype=object)
355
+ beta[6] = lambda xx: self.H_c(xx)**2 * ((3 / 2) * self.Om(xx) * (2 - 2 * self.f_intp(xx)+ self.b_e(xx) - 4 * self.Q(xx) - ((2 * (1 - self.Q(xx))) / (self.comoving_dist(xx) * self.H_c(xx))) - (dH_dt(xx)/ self.H_c(xx)**2)))
356
+ beta[7] = lambda xx: self.H_c(xx)**2 * (self.f_intp(xx)* (3 - self.b_e(xx)))
357
+ beta[8] = lambda xx: self.H_c(xx)**2 * (3 * self.Om(xx) * self.f_intp(xx) * (2 - self.f_intp(xx) - 2 * self.Q(xx)) + self.f_intp(xx)**2 * (4 + self.b_e(xx) - self.b_e(xx)**2 + 4 * self.b_e(xx) * self.Q(xx) - 6 * self.Q(xx) - 4 * self.Q(xx)**2 + 4 * partdQ + 4 * (dQ_dt(xx) / self.H_c(xx)) -(dbe_dt(xx) / self.H_c(xx)) - (2 / (self.comoving_dist(xx)**2 * self.H_c(xx)**2)) * (1 - self.Q(xx) + 2 * self.Q(xx)**2 - 2 * partdQ) - (2 / (self.comoving_dist(xx) * self.H_c(xx))) * (3 - 2 * self.b_e(xx) + 2 * self.b_e(xx) * self.Q(xx) - self.Q(xx) - 4 * self.Q(xx)**2 + ((3 * dH_dt(xx)) / (self.H_c(xx)**2)) * (1 - self.Q(xx)) + 4 * partdQ + 2 * (dQ_dt(xx) / self.H_c(xx))) - (dH_dt(xx)/ self.H_c(xx)**2) * (3 - 2 * self.b_e(xx) + 4 * self.Q(xx) + ((3 * dH_dt(xx)) / (self.H_c(xx)**2))) + (dH_dt2(xx) / self.H_c(xx)**3)))
358
+ beta[9] = lambda xx: self.H_c(xx)**2 * ( -(9 / 2) * self.Om(xx) * self.f_intp(xx))
359
+ beta[10] = lambda xx: self.H_c(xx)**2 * (3 * self.Om(xx) * self.f_intp(xx))
360
+ beta[11] = lambda xx: self.H_c(xx)**2 * ( (3/2 ) * self.Om(xx) * (1 + 2 * self.f_intp(xx)/ (3 * self.Om(xx))) + 3 * self.Om(xx) * self.f_intp(xx)- self.f_intp(xx)**2 * (-1 + self.b_e(xx) - 2 * self.Q(xx) - ((2 * (1 + self.Q(xx))) / (self.comoving_dist(xx) * self.H_c(xx))) - (dH_dt(xx)/ self.H_c(xx)**2)))
361
+ beta[12] = lambda xx: self.H_c(xx)**2 * ( -3 * self.Om(xx) * (1 + 2 * self.f_intp(xx)/ (3 * self.Om(xx))) - self.f_intp(xx)* ( tracer.b_1(xx) * (self.f_intp(xx)- 3 + self.b_e(xx)) + (db1_dt(xx) / self.H_c(xx)) ) + (3 / 2) * self.Om(xx) * (tracer.b_1(xx) * (2 + self.b_e(xx) - 4 * self.Q(xx) - 2 * ((1 - self.Q(xx))/(self.comoving_dist(xx) * self.H_c(xx))) - (dH_dt(xx)/ self.H_c(xx)**2) ) + db1_dt(xx) /self.H_c(xx) + 2 * (2 - (1 / (self.comoving_dist(xx) * self.H_c(xx))) ) * partdb1 ) )
362
+ beta[13] = lambda xx: self.H_c(xx)**2 * (( (9 / 4) * self.Om(xx)**2 + (3 / 2) * self.Om(xx) * self.f_intp(xx)* (1 - (2 * self.f_intp(xx)) + 2 * self.b_e(xx) - 6 * self.Q(xx) - ((4 * (1 - self.Q(xx)))/(self.comoving_dist(xx) * self.H_c(xx))) - ((3 * dH_dt(xx)) / self.H_c(xx)**2) ) ) + ( self.f_intp(xx)**2 * (3 - self.b_e(xx)) ) )
363
+ beta[14] = lambda xx: self.H_c(xx) * ( - (3 / 2) * self.Om(xx) * tracer.b_1(xx))
364
+ beta[15] = lambda xx: self.H_c(xx) * 2 * self.f_intp(xx)**2
365
+ beta[16] = lambda xx: self.H_c(xx) * (self.f_intp(xx)* (tracer.b_1(xx) * (self.f_intp(xx)+ self.b_e(xx) - 2 * self.Q(xx) - ((2 * (1 - self.Q(xx))) / (self.comoving_dist(xx) * self.H_c(xx))) - (dH_dt(xx)/ self.H_c(xx)**2)) + (db1_dt(xx) / self.H_c(xx)) + 2 * (1 - (1 / (self.comoving_dist(xx) * self.H_c(xx)))) * partdb1 ))
366
+ beta[17] = lambda xx: self.H_c(xx) * (- (3 / 2) * self.Om(xx) * self.f_intp(xx))
367
+ beta[18] = lambda xx: self.H_c(xx) * ( (3 / 2) * self.Om(xx) * self.f_intp(xx) - self.f_intp(xx)**2 * (3 - 2 * self.b_e(xx) + 4 * self.Q(xx) + ((4 * (1 - self.Q(xx))) / (self.comoving_dist(xx) * self.H_c(xx))) + (3 * dH_dt(xx)/ self.H_c(xx)**2)) )
368
+ beta[19] = lambda xx: self.H_c(xx) * (self.f_intp(xx)* (self.b_e(xx) - 2 * self.Q(xx) - ((2 * (1 - self.Q(xx))) / (self.comoving_dist(xx) * self.H_c(xx))) - (dH_dt(xx)/ self.H_c(xx)**2)))
369
+
370
+
371
+ #get betad - derivatives wrt to ln(d)
372
+ betad = np.empty(20,dtype=object)
373
+ betad[14:20] = np.array(self.lnd_derivatives(beta[14:20]),dtype=object)#14-19
374
+
375
+ tracer.beta = beta
376
+ tracer.betad = betad
377
+ all_betas = np.concatenate((np.array([tracer.gr1,tracer.gr2,tracer.grd1]),beta[6:],betad[14:20]))
378
+ return [all_betas[i](zz) for i in range(len(all_betas))]
379
+