CosmoWAP 0.5.0__tar.gz → 0.5.2__tar.gz

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.
Files changed (66) hide show
  1. {cosmowap-0.5.0 → cosmowap-0.5.2}/PKG-INFO +2 -2
  2. {cosmowap-0.5.0 → cosmowap-0.5.2}/pyproject.toml +2 -2
  3. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/PNG.py +18 -6
  4. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/combined.py +7 -7
  5. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/forecast/core.py +46 -22
  6. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/forecast/covariances.py +57 -3
  7. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/forecast/forecast.py +12 -7
  8. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/forecast/posterior.py +177 -23
  9. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/integrated.py +13 -5
  10. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/lib/bk_plots.py +1 -0
  11. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/lib/utils.py +6 -2
  12. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/main.py +21 -52
  13. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/peak_background_bias.py +3 -4
  14. cosmowap-0.5.2/src/cosmo_wap/pk/IxS_components.py +576 -0
  15. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/pk/PNG.py +32 -9
  16. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/pk/combined.py +33 -10
  17. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/pk/cov.py +4 -0
  18. cosmowap-0.5.2/src/cosmo_wap/pk/covWS.py +68 -0
  19. cosmowap-0.5.2/src/cosmo_wap/pk/covWSGR.py +67 -0
  20. cosmowap-0.5.2/src/cosmo_wap/pk/int.py +436 -0
  21. cosmowap-0.5.2/src/cosmo_wap/pk/int_components.py +1124 -0
  22. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/survey_params.py +4 -4
  23. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmowap.egg-info/PKG-INFO +2 -2
  24. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmowap.egg-info/SOURCES.txt +3 -0
  25. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmowap.egg-info/requires.txt +1 -1
  26. cosmowap-0.5.0/src/cosmo_wap/pk/int.py +0 -370
  27. cosmowap-0.5.0/src/cosmo_wap/pk/int_components.py +0 -832
  28. {cosmowap-0.5.0 → cosmowap-0.5.2}/LICENSE.txt +0 -0
  29. {cosmowap-0.5.0 → cosmowap-0.5.2}/README.md +0 -0
  30. {cosmowap-0.5.0 → cosmowap-0.5.2}/setup.cfg +0 -0
  31. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/__init__.py +0 -0
  32. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/GR0.py +0 -0
  33. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/GR1.py +0 -0
  34. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/GR2.py +0 -0
  35. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/GR_0.py +0 -0
  36. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/GR_1.py +0 -0
  37. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/GR_2.py +0 -0
  38. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/PNG_.py +0 -0
  39. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/RR1.py +0 -0
  40. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/RR2.py +0 -0
  41. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/RR_1.py +0 -0
  42. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/WA1.py +0 -0
  43. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/WA2.py +0 -0
  44. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/WARR.py +0 -0
  45. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/WA_1.py +0 -0
  46. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/WA_2.py +0 -0
  47. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/WSGR.py +0 -0
  48. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/__init__.py +0 -0
  49. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/bk/cov.py +0 -0
  50. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/data_library/SKAO1Data.txt +0 -0
  51. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/data_library/SKAO2Data.txt +0 -0
  52. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/data_library/k_modes.txt +0 -0
  53. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/data_library/snr_surveyparams.txt +0 -0
  54. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/forecast/__init__.py +0 -0
  55. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/forecast/mpi_mcmc.py +0 -0
  56. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/lib/__init__.py +0 -0
  57. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/lib/betas.py +0 -0
  58. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/lib/integrate.py +0 -0
  59. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/lib/luminosity_funcs.py +0 -0
  60. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/pk/Pk_0.py +0 -0
  61. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/pk/Pk_WS.py +0 -0
  62. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/pk/Pk_WSGR.py +0 -0
  63. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmo_wap/pk/__init__.py +0 -0
  64. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmowap.egg-info/dependency_links.txt +0 -0
  65. {cosmowap-0.5.0 → cosmowap-0.5.2}/src/cosmowap.egg-info/top_level.txt +0 -0
  66. {cosmowap-0.5.0 → cosmowap-0.5.2}/tests/test-cosmowap.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cosmowap
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Summary: package for computing power spectra and bispectra
5
5
  Author-email: Chris Addis <c.l.j.addis@qmul.ac.uk>
6
6
  License: MIT
@@ -16,7 +16,7 @@ Requires-Dist: scipy
16
16
  Requires-Dist: matplotlib
17
17
  Requires-Dist: tqdm
18
18
  Requires-Dist: cython
19
- Requires-Dist: classy
19
+ Requires-Dist: classy<3.3.2.0
20
20
  Requires-Dist: chainconsumer
21
21
  Requires-Dist: cobaya
22
22
  Dynamic: license-file
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cosmowap"
7
- version = "0.5.0"
7
+ version = "0.5.2"
8
8
  authors = [
9
9
  { name="Chris Addis", email="c.l.j.addis@qmul.ac.uk" },
10
10
  ]
@@ -24,7 +24,7 @@ dependencies = [
24
24
  "matplotlib",
25
25
  "tqdm",
26
26
  "cython",
27
- "classy",
27
+ "classy < 3.3.2.0",
28
28
  "chainconsumer",
29
29
  "cobaya"
30
30
  ]
@@ -6,7 +6,9 @@ class Loc:
6
6
  def ylm(l,m,cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,sigma=None):
7
7
  return ylm(bk.Loc_,l,m,cosmo_funcs,k1,k2,k3=k3,theta=theta,zz=zz,r=r,s=s,sigma=sigma)
8
8
 
9
- def l0(cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,fNL=1):
9
+ def l0(cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,fNL=1,fNL_loc=None,**kwargs):
10
+ if fNL_loc:
11
+ fNL = fNL_loc # if defined use as fNL
10
12
 
11
13
  #get generic cosmology parameters
12
14
  k1,k2,k3,theta,Pk1,Pk2,Pk3,_,_,_,_,_,_,_,K,C,f,D1,b1,b2,g2 = cosmo_funcs.get_params(k1,k2,k3,theta,zz)
@@ -20,7 +22,9 @@ class Loc:
20
22
 
21
23
  return tmp_expr
22
24
 
23
- def l2(cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,fNL=1):
25
+ def l2(cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,fNL=1,fNL_loc=None,**kwargs):
26
+ if fNL_loc:
27
+ fNL = fNL_loc # if defined use as fNL
24
28
 
25
29
  #get generic cosmology parameters
26
30
  k1,k2,k3,theta,Pk1,Pk2,Pk3,_,_,_,_,_,_,_,K,C,f,D1,b1,b2,g2 = cosmo_funcs.get_params(k1,k2,k3,theta,zz)
@@ -39,7 +43,9 @@ class Eq:
39
43
  def ylm(l,m,cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,sigma=None):
40
44
  return ylm(bk.Eq_,l,m,cosmo_funcs,k1,k2,k3=k3,theta=theta,zz=zz,r=r,s=s,sigma=sigma)
41
45
 
42
- def l0(cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,fNL=1):
46
+ def l0(cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,fNL=1,fNL_eq=None,**kwargs):
47
+ if fNL_eq:
48
+ fNL = fNL_eq # if defined use as fNL
43
49
 
44
50
  #get generic cosmology parameters
45
51
  k1,k2,k3,theta,Pk1,Pk2,Pk3,_,_,_,_,_,_,_,K,C,f,D1,b1,b2,g2 = cosmo_funcs.get_params(k1,k2,k3,theta,zz)
@@ -53,7 +59,9 @@ class Eq:
53
59
 
54
60
  return tmp_expr
55
61
 
56
- def l2(cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,fNL=1):
62
+ def l2(cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,fNL=1,fNL_eq=None,**kwargs):
63
+ if fNL_eq:
64
+ fNL = fNL_eq # if defined use as fNL
57
65
 
58
66
  #get generic cosmology parameters
59
67
  k1,k2,k3,theta,Pk1,Pk2,Pk3,_,_,_,_,_,_,_,K,C,f,D1,b1,b2,g2 = cosmo_funcs.get_params(k1,k2,k3,theta,zz)
@@ -72,7 +80,9 @@ class Orth:
72
80
  def ylm(l,m,cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,sigma=None):
73
81
  return ylm(bk.Orth_,l,m,cosmo_funcs,k1,k2,k3=k3,theta=theta,zz=zz,r=r,s=s,sigma=sigma)
74
82
 
75
- def l0(cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,fNL=1):
83
+ def l0(cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,fNL=1,fNL_orth=None,**kwargs):
84
+ if fNL_orth:
85
+ fNL = fNL_orth # if defined use as fNL
76
86
 
77
87
  #get generic cosmology parameters
78
88
  k1,k2,k3,theta,Pk1,Pk2,Pk3,_,_,_,_,_,_,_,K,C,f,D1,b1,b2,g2 = cosmo_funcs.get_params(k1,k2,k3,theta,zz)
@@ -86,7 +96,9 @@ class Orth:
86
96
 
87
97
  return tmp_expr
88
98
 
89
- def l2(cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,fNL=1):
99
+ def l2(cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,fNL=1,fNL_orth=None,**kwargs):
100
+ if fNL_orth:
101
+ fNL = fNL_orth # if defined use as fNL
90
102
 
91
103
  #get generic cosmology parameters
92
104
  k1,k2,k3,theta,Pk1,Pk2,Pk3,_,_,_,_,_,_,_,K,C,f,D1,b1,b2,g2 = cosmo_funcs.get_params(k1,k2,k3,theta,zz)
@@ -4,14 +4,14 @@ import cosmo_wap.lib.integrate as integrate
4
4
  import numpy as np
5
5
 
6
6
  #so we want create a general bispectrum function like COV.cov()
7
- def bk_func(term,l,cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,m=0,sigma=None,fNL=None):
7
+ def bk_func(term,l,cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,m=0,sigma=None,**kwargs):
8
8
  """Convenience function to call bispectrum terms in a standardised format including FoG."""
9
9
 
10
10
  if isinstance(term, list):# so we can pass term as a list of contribtuions
11
11
  # then call recursively for each term
12
12
  tot = []
13
13
  for x in term:
14
- tot.append(bk_func(x,l,cosmo_funcs,k1,k2,k3,theta,zz=zz,r=r,s=s,m=m,sigma=sigma,fNL=fNL))
14
+ tot.append(bk_func(x,l,cosmo_funcs,k1,k2,k3,theta,zz=zz,r=r,s=s,m=m,sigma=sigma,**kwargs))
15
15
 
16
16
  return np.sum(tot,axis=0)
17
17
 
@@ -21,14 +21,14 @@ def bk_func(term,l,cosmo_funcs,k1,k2,k3=None,theta=None,zz=0,r=0,s=0,m=0,sigma=N
21
21
  else:
22
22
  bk_class = term
23
23
 
24
- kwargs = {}
25
- if fNL is not None: # if fNL is provided, then pass it as an keyword argument
26
- kwargs['fNL'] = fNL
24
+ wargs = {}
25
+ if term in ['Loc','Eq','Orth']: # then pass fNL as keyword argument
26
+ wargs = kwargs
27
27
 
28
28
  if sigma is None:
29
- return getattr(bk_class, f'l{l}')(cosmo_funcs,k1,k2,k3,theta,zz,r,s,**kwargs)
29
+ return getattr(bk_class, f'l{l}')(cosmo_funcs,k1,k2,k3,theta,zz,r,s,**wargs)
30
30
  else:
31
- return bk.ylm(l,m,cosmo_funcs,k1,k2,k3,theta,zz,r,s,sigma=sigma,**kwargs)
31
+ return bk.ylm(l,m,cosmo_funcs,k1,k2,k3,theta,zz,r,s,sigma=sigma,**wargs)
32
32
 
33
33
  def ylm_picker(l,m,terms,*args,**kwargs):
34
34
  """Sums the contribution using ylm method from terms provided.
@@ -47,7 +47,7 @@ class Forecast(ABC):
47
47
  z_bin (List[float]): Redshift bin as [z_min, z_max].
48
48
  cosmo_funcs (Any): ClassWAP object has main functionality.
49
49
  k_max (float, optional): Maximum k value. Defaults to 0.1.
50
- s_k (float, optional): Scaling for k-bin width. Defaults to 1.
50
+ s_k (float, optional): Scaling for k-bin width in units of k_f. Defaults to 2.
51
51
  verbose (bool, optional): Verbosity flag. Defaults to False.
52
52
  """
53
53
 
@@ -149,38 +149,63 @@ class Forecast(ABC):
149
149
  # so X is survey1 bias, Y survey2 bias and A both
150
150
  h = dh
151
151
 
152
+ def deriv_bias(cf,param,h,tracers=['X','Y']):
153
+ """Set-up to compute derivate wrt to bias amplitudes - return cosmo_funcs objects for small changes in bias"""
154
+ if False: #'b_1' in param: # so this does not really effect anything and is much slower
155
+ """So linear bias set other biases - namely b_01 but potentially b_2 etc..."""
156
+ obj = [] # start as empty list and will fill with survey_params object(s)
157
+ for i,cf_survey in enumerate([cf.survey,cf.survey1]):
158
+ if cf.multi_tracer:
159
+ if cf_survey.t in tracers: # if we altering this tracer
160
+ obj.append(utils.modify_func(cf.survey_params[i], param, lambda f: f*(1+h)))
161
+ else:
162
+ obj.append(cf.survey_params[i]) # then is unchanged
163
+ else: # in single tracer
164
+ if cf_survey.t in tracers:
165
+ obj = utils.modify_func(cf.survey_params, param, lambda f: f*(1+h))
166
+ else:
167
+ obj = cf.survey_params # then is unchanged
168
+
169
+ cf = cf.update_survey(obj,verbose=False) # update cosmo_funcs with new survey_params
170
+
171
+ else:
172
+ # now for the case of working with Q and be
173
+ for cf_survey in [cf.survey,cf.survey1]:
174
+ if cf_survey.t in tracers:
175
+ cf_survey = utils.modify_func(cf_survey, param, lambda f: f*(1+h),copy=False)
176
+
177
+ return cf
178
+
152
179
  def get_func_h(h,l):
153
180
  cosmo_funcs_h = utils.create_copy(cosmo_funcs) # make copy is good
154
181
  tmp_param = param[2:] # i.e get b_1 from X_b_1
155
-
156
- if param[0] == 'X':
157
- if cosmo_funcs_h.survey.t1: # is tracer1?
158
- cosmo_funcs_h.survey = utils.modify_func(cosmo_funcs_h.survey, tmp_param, lambda f: f*(1+h))
159
- if cosmo_funcs_h.survey1.t1: # is tracer1?
160
- cosmo_funcs_h.survey1 = utils.modify_func(cosmo_funcs_h.survey1, tmp_param, lambda f: f*(1+h))
161
- elif param[0] == 'Y': # Y - so we affect tracer2
162
- if not cosmo_funcs_h.survey.t1:
163
- cosmo_funcs_h.survey = utils.modify_func(cosmo_funcs_h.survey, tmp_param, lambda f: f*(1+h))
164
- if not cosmo_funcs_h.survey1.t1:
165
- cosmo_funcs_h.survey1 = utils.modify_func(cosmo_funcs_h.survey1, tmp_param, lambda f: f*(1+h))
182
+
183
+ if param[0] in ['X','Y']:
184
+ cosmo_funcs_h = deriv_bias(cosmo_funcs_h,tmp_param,h,tracers=param[0])
166
185
  else: # so affects both tracers (affect or effect)
167
- cosmo_funcs_h.survey = utils.modify_func(cosmo_funcs_h.survey, tmp_param, lambda f: f*(1+h))
168
- cosmo_funcs_h.survey1 = utils.modify_func(cosmo_funcs_h.survey1, tmp_param, lambda f: f*(1+h))
186
+ cosmo_funcs_h = deriv_bias(cosmo_funcs_h,tmp_param,h,tracers=['X','Y'])
169
187
 
170
188
  if tmp_param in ['be','Q']: # reset betas - as they need to be recomputed with the new biases
171
189
  cosmo_funcs_h.survey.betas = None
172
190
  cosmo_funcs_h.survey1.betas = None
173
-
191
+
174
192
  return func(term,l,cosmo_funcs_h, *args[1:], **kwargs) # args normally contains cosmo_funcs
175
193
 
176
- elif param in ['fNL','t','r','s']:
194
+ elif param in ['fNL','fNL_loc','fNL_eq','fNL_orth','t','r','s']:
177
195
  # mainly for fnl but for any kwarg. fNL shape is determine by whats included in base terms...
178
196
  # also could make broadcastable....
179
- h = kwargs[param]*dh
180
- def get_func_h(h,l):
181
- wargs = copy.copy(kwargs)
182
- wargs[param] += h
183
- return func(term,l,*args, **wargs)
197
+ if param in kwargs:
198
+ h = kwargs[param]*dh
199
+ def get_func_h(h,l):
200
+ wargs = copy.copy(kwargs)
201
+ wargs[param] += h
202
+ return func(term,l,*args, **wargs)
203
+ else: # then assume parameter is 0
204
+ h = 0.1
205
+ def get_func_h(h,l):
206
+ wargs = copy.copy(kwargs)
207
+ wargs[param] = h
208
+ return func(term,l,*args, **wargs)
184
209
 
185
210
  elif param in ['Omega_m','Omega_cdm','Omega_b','A_s','sigma8','n_s','h']:
186
211
  # so for cosmology we recall ClassWAP with updated class cosmology
@@ -360,7 +385,6 @@ class PkForecast(Forecast):
360
385
 
361
386
  return np.array(d1)
362
387
 
363
-
364
388
  class BkForecast(Forecast):
365
389
  def __init__(self, z_bin, cosmo_funcs, k_max=0.1, s_k=1, cache=None,all_tracer=False):
366
390
  super().__init__(z_bin, cosmo_funcs, k_max, s_k, cache, all_tracer)
@@ -5,6 +5,9 @@ from scipy.special import eval_legendre
5
5
  import cosmo_wap.pk as pk
6
6
  from cosmo_wap.lib import utils
7
7
 
8
+ from matplotlib import pyplot as plt
9
+ from matplotlib.colors import LogNorm, SymLogNorm
10
+
8
11
  class FullCov:
9
12
  def __init__(self,fc,cosmo_funcs_list,cov_terms,sigma=None,n_mu=64,fast=False,nonlin=False):
10
13
  """
@@ -115,10 +118,10 @@ class FullCov:
115
118
 
116
119
  def get_tracer(self,a,b,c,d,terms,l1,l2):
117
120
  """Get C[P^ab_{l}, P^cd_{l2}](k)
118
- C[P^ab_{l1}, P^cd_{l2}](k) = ((2*l1 + 1)(2*l2 + 1) / N_k) ( Int (d(Omega_k) / 4*pi) * L_1(mu) *
121
+ C[P^ab_{l1}, P^cd_{l2}](k) = ((2*l1 + 1)(2*l2 + 1) / N_k) ( Int (d(Omega_k) / 4*pi) * L_1(mu) *
119
122
  [L_2(mu)*P^ac(k,mu)*P^bd(k,mu)^* + L_2(-mu)*P^ad(k,mu)*P^bc(k,mu)^*]"""
120
123
 
121
- return (self.integrate_mu(a,c,b,d,terms,l1,l2,self.mu) + self.integrate_mu(a,d,b,c,terms,l1,l2,-self.mu))
124
+ return (1/2)*(self.integrate_mu(a,c,b,d,terms,l1,l2,self.mu) + self.integrate_mu(a,d,b,c,terms,l1,l2,-self.mu))
122
125
 
123
126
  def get_single_tracer_ll(self,terms,l1,l2):
124
127
  """Get full single-tracer covariance for multipole pair"""
@@ -178,4 +181,55 @@ class FullCov:
178
181
  row += len(tracer)
179
182
  column = 0
180
183
 
181
- return cov_mt
184
+ return cov_mt
185
+
186
+ def plot_cov(self,ln,kn=0,real=True,log=True,vmin=None,vmax=None,cmap='RdBu',lnrwidth=None,**kwargs):
187
+ """Lets plot the covariance"""
188
+ cov = self.get_cov(ln)
189
+
190
+ labels = []
191
+ for l in ln:
192
+ if l & 1:
193
+ labels.append(rf"$P^{{BF}}_{l}$")
194
+ else: # If even
195
+ labels.extend([
196
+ rf"$P^{{BB}}_{{{l}}}$",
197
+ rf"$P^{{BF}}_{{{l}}}$",
198
+ rf"$P^{{FF}}_{{{l}}}$"
199
+ ])
200
+
201
+ plt.figure(figsize=(10,7))
202
+ if real:
203
+ if log:
204
+ if not vmin:
205
+ vmin = np.abs(cov[...,kn].real).min()
206
+ if not vmax:
207
+ vmax = np.abs(cov[...,kn].real).max()
208
+
209
+ if lnrwidth:
210
+ plt.pcolormesh(cov[...,kn].real, cmap=cmap,norm=SymLogNorm(linthresh=lnrwidth, linscale=1, vmin=-vmin, vmax=vmax))
211
+ else:
212
+ plt.pcolormesh(np.abs(cov[...,kn].real), cmap=cmap,norm=LogNorm(vmin, vmax=vmax))
213
+
214
+ else:
215
+ plt.pcolormesh(cov[...,kn].real, cmap=cmap)
216
+ else:
217
+ if log:
218
+ if not vmin:
219
+ vmin = np.abs(cov[...,kn].imag).min()
220
+ if not vmax:
221
+ vmax = np.abs(cov[...,kn].imag).max()
222
+
223
+ if lnrwidth:
224
+ plt.pcolormesh(cov[...,kn].imag, cmap=cmap,norm=SymLogNorm(linthresh=lnrwidth, linscale=1, vmin=-vmin, vmax=vmax))
225
+ else:
226
+ plt.pcolormesh(np.abs(cov[...,kn].imag), cmap=cmap,norm=LogNorm(vmin, vmax=vmax))
227
+
228
+ else:
229
+ plt.pcolormesh(cov[...,kn].imag, cmap=cmap)
230
+
231
+ plt.xticks(np.arange(0.5, len(labels) + 0.5), labels=labels)
232
+ plt.yticks(np.arange(0.5, len(labels) + 0.5), labels=labels)
233
+ cbar = plt.colorbar()
234
+ cbar.set_label(r'$|C[P^{ab}_{\ell_i},P^{cd}_{\ell_j}](k)|$', **kwargs)
235
+
@@ -10,7 +10,7 @@ from .posterior import FisherMat, Sampler
10
10
  from cosmo_wap.lib import utils
11
11
 
12
12
  class FullForecast:
13
- def __init__(self,cosmo_funcs,kmax_func=None,s_k=1,nonlin=True,N_bins=None):
13
+ def __init__(self,cosmo_funcs,kmax_func=None,s_k=1,nonlin=False,N_bins=None):
14
14
  """
15
15
  Do full survey forecast over redshift bins
16
16
  First get relevant redshifts and ks for each redshift bin
@@ -32,11 +32,16 @@ class FullForecast:
32
32
  self.k_max_list = kmax_func(self.z_mid)
33
33
  else:
34
34
  self.k_max_list = np.ones_like(self.z_mid)*kmax_func
35
-
36
- self.nonlin = nonlin # use Halofit Pk for covariance
37
- self.cosmo_funcs = cosmo_funcs
35
+
38
36
  self.s_k = s_k
39
37
 
38
+ # basically we dont have an amazing system of including nonlinear effects
39
+ # so now whether they use the halofit pk it is defined by the cosmo_funcs attribute so we just turn it off and on again if we need to
40
+ if nonlin:
41
+ cosmo_funcs = utils.create_copy(cosmo_funcs)
42
+ cosmo_funcs.nonlin = True
43
+ self.cosmo_funcs = cosmo_funcs
44
+
40
45
  # get args for each bin (basically just get k-vectors!)
41
46
  self.num_bins = len(self.z_bins)
42
47
 
@@ -49,7 +54,7 @@ class FullForecast:
49
54
  # we create 4 different cosmo_funcs objects for each tracer combination
50
55
  cosmo_funcsXX = utils.create_copy(cosmo_funcs) # XX
51
56
  cosmo_funcsXX.survey1 = cosmo_funcs.survey
52
- cosmo_funcsXX.survey_params = cosmo_funcs.survey_params[0]
57
+ cosmo_funcsXX.survey_params = cosmo_funcs.survey_params[0]
53
58
  cosmo_funcsXX.multi_tracer = False # now single tracer
54
59
  cosmo_funcsXX.n_g = cosmo_funcsXX.survey.n_g
55
60
 
@@ -168,7 +173,7 @@ class FullForecast:
168
173
  for i in tqdm(range(num_bins), disable=not verbose, desc="Bin Loop"):
169
174
  # --- Covariance Calculation (once per bin) ---New method to compute and cache all derivatives and inverse covariances once.
170
175
  if pkln:
171
- pk_fc = PkForecast(self.z_bins[i], self.cosmo_funcs, k_max=self.k_max_list[i], s_k=self.s_k, cache=cache, all_tracer=all_tracer, cov_terms=cov_terms,cosmo_funcs_list=cosmo_funcs_list)
176
+ pk_fc = PkForecast(self.z_bins[i], self.cosmo_funcs, k_max=self.k_max_list[i], s_k=self.s_k, cache=cache, all_tracer=all_tracer, cov_terms=cov_terms, cosmo_funcs_list=cosmo_funcs_list)
172
177
  if compute_cov:
173
178
  pk_cov_mat = pk_fc.get_cov_mat(pkln, sigma=sigma)
174
179
  inv_covs[i]['pk'] = pk_fc.invert_matrix(pk_cov_mat)
@@ -282,7 +287,7 @@ class FullForecast:
282
287
  fish_mat = self.get_fish(param,terms=terms, pkln=pkln, bkln=bkln, t=t, r=r, s=s, verbose=verbose, sigma=sigma, bias_list=bias_term)
283
288
 
284
289
  bfb = fish_mat.bias[-1] # is list containing a dictionary for each bias term
285
- fish = np.diag(fish_mat.fisher_matrix) # is array
290
+ fish = np.diag(fish_mat.fisher_matrix) # is array - ignore marginalisation
286
291
 
287
292
  return bfb,fish
288
293