flipcosmo 1.0.0__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.
Files changed (82) hide show
  1. flip/__init__.py +27 -0
  2. flip/config.py +1 -0
  3. flip/covariance/__init__.py +15 -0
  4. flip/covariance/adamsblake17/__init__.py +5 -0
  5. flip/covariance/adamsblake17/coefficients.py +27 -0
  6. flip/covariance/adamsblake17/fisher_terms.py +300 -0
  7. flip/covariance/adamsblake17/flip_terms.py +78 -0
  8. flip/covariance/adamsblake17plane/__init__.py +5 -0
  9. flip/covariance/adamsblake17plane/coefficients.py +27 -0
  10. flip/covariance/adamsblake17plane/fisher_terms.py +300 -0
  11. flip/covariance/adamsblake17plane/flip_terms.py +75 -0
  12. flip/covariance/adamsblake17plane/generator.py +263 -0
  13. flip/covariance/adamsblake20/__init__.py +10 -0
  14. flip/covariance/adamsblake20/coefficients.py +46 -0
  15. flip/covariance/adamsblake20/fisher_terms.py +813 -0
  16. flip/covariance/adamsblake20/flip_terms.py +346 -0
  17. flip/covariance/carreres23/__init__.py +8 -0
  18. flip/covariance/carreres23/coefficients.py +18 -0
  19. flip/covariance/carreres23/fisher_terms.py +48 -0
  20. flip/covariance/carreres23/flip_terms.py +46 -0
  21. flip/covariance/carreres23/generator.py +132 -0
  22. flip/covariance/contraction.py +345 -0
  23. flip/covariance/cov_utils.py +437 -0
  24. flip/covariance/covariance.py +825 -0
  25. flip/covariance/emulators/__init__.py +3 -0
  26. flip/covariance/emulators/generator.py +317 -0
  27. flip/covariance/emulators/gpmatrix.py +95 -0
  28. flip/covariance/emulators/nnmatrix.py +218 -0
  29. flip/covariance/generator.py +713 -0
  30. flip/covariance/lai22/__init__.py +11 -0
  31. flip/covariance/lai22/coefficients.py +83 -0
  32. flip/covariance/lai22/fisher_terms.py +3911 -0
  33. flip/covariance/lai22/flip_terms.py +16003 -0
  34. flip/covariance/lai22/generator.py +868 -0
  35. flip/covariance/lai22/h_terms.py +2202 -0
  36. flip/covariance/lai22/symbolic.py +148 -0
  37. flip/covariance/ravouxcarreres/__init__.py +10 -0
  38. flip/covariance/ravouxcarreres/coefficients.py +46 -0
  39. flip/covariance/ravouxcarreres/fisher_terms.py +813 -0
  40. flip/covariance/ravouxcarreres/flip_terms.py +884 -0
  41. flip/covariance/ravouxcarreres/flip_terms_lmax.py +3395 -0
  42. flip/covariance/ravouxnoanchor25/__init__.py +13 -0
  43. flip/covariance/ravouxnoanchor25/coefficients.py +49 -0
  44. flip/covariance/ravouxnoanchor25/fisher_terms.py +48 -0
  45. flip/covariance/ravouxnoanchor25/flip_terms.py +54 -0
  46. flip/covariance/rcrk24/__init__.py +10 -0
  47. flip/covariance/rcrk24/coefficients.py +251 -0
  48. flip/covariance/rcrk24/fisher_terms.py +126 -0
  49. flip/covariance/rcrk24/flip_terms.py +55 -0
  50. flip/covariance/symbolic.py +1274 -0
  51. flip/data/__init__.py +3 -0
  52. flip/data/density_data.parquet +0 -0
  53. flip/data/grid_window_m.parquet +0 -0
  54. flip/data/power_spectrum_mm.txt +3 -0
  55. flip/data/power_spectrum_mt.txt +3 -0
  56. flip/data/power_spectrum_tt.txt +3 -0
  57. flip/data/style.mplstyle +86 -0
  58. flip/data/velocity_data.parquet +0 -0
  59. flip/data_vector/__init__.py +4 -0
  60. flip/data_vector/basic.py +374 -0
  61. flip/data_vector/cosmo_utils.py +6 -0
  62. flip/data_vector/galaxypv_vectors.py +480 -0
  63. flip/data_vector/snia_vectors.py +172 -0
  64. flip/data_vector/vector_utils.py +148 -0
  65. flip/fisher.py +190 -0
  66. flip/fit_utils.py +882 -0
  67. flip/fitter.py +558 -0
  68. flip/gridding.py +999 -0
  69. flip/likelihood.py +610 -0
  70. flip/plot_utils.py +477 -0
  71. flip/power_spectra/__init__.py +4 -0
  72. flip/power_spectra/class_engine.py +165 -0
  73. flip/power_spectra/cosmoprimo_engine.py +73 -0
  74. flip/power_spectra/generator.py +190 -0
  75. flip/power_spectra/models.py +124 -0
  76. flip/power_spectra/pyccl_engine.py +96 -0
  77. flip/utils.py +228 -0
  78. flipcosmo-1.0.0.dist-info/METADATA +32 -0
  79. flipcosmo-1.0.0.dist-info/RECORD +82 -0
  80. flipcosmo-1.0.0.dist-info/WHEEL +5 -0
  81. flipcosmo-1.0.0.dist-info/licenses/LICENSE +21 -0
  82. flipcosmo-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,300 @@
1
+ import numpy as np
2
+
3
+
4
+ def get_partial_derivative_coefficients(
5
+ model_kind,
6
+ parameter_values_dict,
7
+ variant=None,
8
+ redshift_dict=None,
9
+ ):
10
+ if model_kind == "density":
11
+ return get_partial_derivative_coefficients_density(
12
+ parameter_values_dict,
13
+ variant=variant,
14
+ )
15
+ elif model_kind == "velocity":
16
+ return get_partial_derivative_coefficients_velocity(
17
+ parameter_values_dict,
18
+ variant=variant,
19
+ )
20
+ elif model_kind == "density_velocity":
21
+ return get_partial_derivative_coefficients_density_velocity(
22
+ parameter_values_dict,
23
+ variant=variant,
24
+ )
25
+ elif model_kind == "full":
26
+ return get_partial_derivative_coefficients_full(
27
+ parameter_values_dict,
28
+ variant=variant,
29
+ )
30
+
31
+
32
+ def get_partial_derivative_coefficients_velocity(
33
+ parameter_values_dict,
34
+ variant=None,
35
+ ):
36
+ if variant == "growth_index":
37
+ partial_coefficients_dict = {
38
+ "Omegam": {
39
+ "vv": [
40
+ 2
41
+ * parameter_values_dict["Omegam"]
42
+ ** (2 * parameter_values_dict["gamma"])
43
+ * parameter_values_dict["gamma"]
44
+ * parameter_values_dict["s8"] ** 2
45
+ / parameter_values_dict["Omegam"],
46
+ ],
47
+ },
48
+ "gamma": {
49
+ "vv": [
50
+ 2
51
+ * parameter_values_dict["Omegam"]
52
+ ** (2 * parameter_values_dict["gamma"])
53
+ * parameter_values_dict["s8"] ** 2
54
+ * np.log(parameter_values_dict["Omegam"]),
55
+ ],
56
+ },
57
+ "s8": {
58
+ "vv": [
59
+ 2
60
+ * parameter_values_dict["Omegam"]
61
+ ** (2 * parameter_values_dict["gamma"])
62
+ * parameter_values_dict["s8"],
63
+ ],
64
+ },
65
+ "bs8": {
66
+ "vv": [
67
+ 0,
68
+ ],
69
+ },
70
+ }
71
+ else:
72
+ partial_coefficients_dict = {
73
+ "fs8": {
74
+ "vv": [
75
+ 2 * parameter_values_dict["fs8"],
76
+ ],
77
+ },
78
+ "bs8": {
79
+ "vv": [
80
+ 0,
81
+ ],
82
+ },
83
+ }
84
+ return partial_coefficients_dict
85
+
86
+
87
+ def get_partial_derivative_coefficients_density(
88
+ parameter_values_dict,
89
+ variant=None,
90
+ ):
91
+ if variant == "growth_index":
92
+ partial_coefficients_dict = {
93
+ "Omegam": {
94
+ "gg": [
95
+ 0,
96
+ ],
97
+ },
98
+ "gamma": {
99
+ "gg": [
100
+ 0,
101
+ ],
102
+ },
103
+ "s8": {
104
+ "gg": [
105
+ 0,
106
+ ],
107
+ },
108
+ "bs8": {
109
+ "gg": [
110
+ 2 * parameter_values_dict["bs8"],
111
+ ],
112
+ },
113
+ }
114
+ else:
115
+ partial_coefficients_dict = {
116
+ "fs8": {
117
+ "gg": [
118
+ 0,
119
+ ],
120
+ },
121
+ "bs8": {
122
+ "gg": [
123
+ 2 * parameter_values_dict["bs8"],
124
+ ],
125
+ },
126
+ }
127
+ return partial_coefficients_dict
128
+
129
+
130
+ def get_partial_derivative_coefficients_density_velocity(
131
+ parameter_values_dict,
132
+ variant=None,
133
+ ):
134
+ if variant == "growth_index":
135
+ partial_coefficients_dict = {
136
+ "Omegam": {
137
+ "gg": [
138
+ 0,
139
+ ],
140
+ "vv": [
141
+ 2
142
+ * parameter_values_dict["Omegam"]
143
+ ** (2 * parameter_values_dict["gamma"])
144
+ * parameter_values_dict["gamma"]
145
+ * parameter_values_dict["s8"] ** 2
146
+ / parameter_values_dict["Omegam"],
147
+ ],
148
+ },
149
+ "gamma": {
150
+ "gg": [
151
+ 0,
152
+ ],
153
+ "vv": [
154
+ 2
155
+ * parameter_values_dict["Omegam"]
156
+ ** (2 * parameter_values_dict["gamma"])
157
+ * parameter_values_dict["s8"] ** 2
158
+ * np.log(parameter_values_dict["Omegam"]),
159
+ ],
160
+ },
161
+ "s8": {
162
+ "gg": [
163
+ 0,
164
+ ],
165
+ "vv": [
166
+ 2
167
+ * parameter_values_dict["Omegam"]
168
+ ** (2 * parameter_values_dict["gamma"])
169
+ * parameter_values_dict["s8"],
170
+ ],
171
+ },
172
+ "bs8": {
173
+ "gg": [
174
+ 2 * parameter_values_dict["bs8"],
175
+ ],
176
+ "vv": [
177
+ 0,
178
+ ],
179
+ },
180
+ }
181
+ else:
182
+ partial_coefficients_dict = {
183
+ "fs8": {
184
+ "gg": [
185
+ 0,
186
+ ],
187
+ "vv": [
188
+ 2 * parameter_values_dict["fs8"],
189
+ ],
190
+ },
191
+ "bs8": {
192
+ "gg": [
193
+ 2 * parameter_values_dict["bs8"],
194
+ ],
195
+ "vv": [
196
+ 0,
197
+ ],
198
+ },
199
+ }
200
+ return partial_coefficients_dict
201
+
202
+
203
+ def get_partial_derivative_coefficients_full(
204
+ parameter_values_dict,
205
+ variant=None,
206
+ ):
207
+ if variant == "growth_index":
208
+ partial_coefficients_dict = {
209
+ "Omegam": {
210
+ "gg": [
211
+ 0,
212
+ ],
213
+ "gv": [
214
+ parameter_values_dict["Omegam"] ** parameter_values_dict["gamma"]
215
+ * parameter_values_dict["bs8"]
216
+ * parameter_values_dict["gamma"]
217
+ * parameter_values_dict["s8"]
218
+ / parameter_values_dict["Omegam"],
219
+ ],
220
+ "vv": [
221
+ 2
222
+ * parameter_values_dict["Omegam"]
223
+ ** (2 * parameter_values_dict["gamma"])
224
+ * parameter_values_dict["gamma"]
225
+ * parameter_values_dict["s8"] ** 2
226
+ / parameter_values_dict["Omegam"],
227
+ ],
228
+ },
229
+ "gamma": {
230
+ "gg": [
231
+ 0,
232
+ ],
233
+ "gv": [
234
+ parameter_values_dict["Omegam"] ** parameter_values_dict["gamma"]
235
+ * parameter_values_dict["bs8"]
236
+ * parameter_values_dict["s8"]
237
+ * np.log(parameter_values_dict["Omegam"]),
238
+ ],
239
+ "vv": [
240
+ 2
241
+ * parameter_values_dict["Omegam"]
242
+ ** (2 * parameter_values_dict["gamma"])
243
+ * parameter_values_dict["s8"] ** 2
244
+ * np.log(parameter_values_dict["Omegam"]),
245
+ ],
246
+ },
247
+ "s8": {
248
+ "gg": [
249
+ 0,
250
+ ],
251
+ "gv": [
252
+ parameter_values_dict["Omegam"] ** parameter_values_dict["gamma"]
253
+ * parameter_values_dict["bs8"],
254
+ ],
255
+ "vv": [
256
+ 2
257
+ * parameter_values_dict["Omegam"]
258
+ ** (2 * parameter_values_dict["gamma"])
259
+ * parameter_values_dict["s8"],
260
+ ],
261
+ },
262
+ "bs8": {
263
+ "gg": [
264
+ 2 * parameter_values_dict["bs8"],
265
+ ],
266
+ "gv": [
267
+ parameter_values_dict["Omegam"] ** parameter_values_dict["gamma"]
268
+ * parameter_values_dict["s8"],
269
+ ],
270
+ "vv": [
271
+ 0,
272
+ ],
273
+ },
274
+ }
275
+ else:
276
+ partial_coefficients_dict = {
277
+ "fs8": {
278
+ "gg": [
279
+ 0,
280
+ ],
281
+ "gv": [
282
+ parameter_values_dict["bs8"],
283
+ ],
284
+ "vv": [
285
+ 2 * parameter_values_dict["fs8"],
286
+ ],
287
+ },
288
+ "bs8": {
289
+ "gg": [
290
+ 2 * parameter_values_dict["bs8"],
291
+ ],
292
+ "gv": [
293
+ parameter_values_dict["fs8"],
294
+ ],
295
+ "vv": [
296
+ 0,
297
+ ],
298
+ },
299
+ }
300
+ return partial_coefficients_dict
@@ -0,0 +1,75 @@
1
+ import mpmath
2
+ import numpy
3
+ import scipy
4
+
5
+
6
+ def set_backend(module):
7
+ global np, erf
8
+ if module == "numpy":
9
+ np = numpy
10
+ erf = scipy.special.erf
11
+ elif module == "mpmath":
12
+ np = mpmath.mp
13
+ erf = mpmath.erf
14
+
15
+
16
+ set_backend("numpy")
17
+
18
+
19
+ def M_gg_0_0_0():
20
+ def func(k):
21
+ return 1
22
+
23
+ return func
24
+
25
+
26
+ def N_gg_0_0_0(theta, phi):
27
+ return 1
28
+
29
+
30
+ def M_gv_0_1_0():
31
+ def func(k):
32
+ return (100 / 3) / k
33
+
34
+ return func
35
+
36
+
37
+ def N_gv_0_1_0(theta, phi):
38
+ return -3 * np.cos(phi)
39
+
40
+
41
+ def M_vv_0_0_0():
42
+ def func(k):
43
+ return (10000 / 3) / k**2
44
+
45
+ return func
46
+
47
+
48
+ def N_vv_0_0_0(theta, phi):
49
+ return 1
50
+
51
+
52
+ def M_vv_0_2_0():
53
+ def func(k):
54
+ return (4000 / 3) / k**2
55
+
56
+ return func
57
+
58
+
59
+ def N_vv_0_2_0(theta, phi):
60
+ return (15 / 4) * np.cos(2 * phi) + 5 / 4
61
+
62
+
63
+ dictionary_terms = {"gg": ["0"], "gv": ["0"], "vv": ["0"]}
64
+ dictionary_lmax = {"gg": [0], "gv": [1], "vv": [2]}
65
+ dictionary_subterms = {
66
+ "gg_0_0": 1,
67
+ "gv_0_0": 0,
68
+ "gv_0_1": 1,
69
+ "vv_0_0": 1,
70
+ "vv_0_1": 0,
71
+ "vv_0_2": 1,
72
+ }
73
+ multi_index_model = False
74
+ redshift_dependent_model = False
75
+ regularize_M_terms = None
@@ -0,0 +1,263 @@
1
+ import multiprocessing as mp
2
+ from functools import partial
3
+
4
+ import numpy as np
5
+ from scipy.special import spherical_jn
6
+
7
+ from flip.covariance import cov_utils
8
+
9
+
10
+ def angle_between(ra_0, ra_1, dec_0, dec_1):
11
+ """Compute cos of the angle between r0 and r1."""
12
+ cos_alpha = np.cos(ra_1 - ra_0) * np.cos(dec_0) * np.cos(dec_1) + np.sin(
13
+ dec_0
14
+ ) * np.sin(dec_1)
15
+ return cos_alpha
16
+
17
+
18
+ def separation(r_0, r_1, cos_alpha):
19
+ """Compute separation between r_0 and r_1."""
20
+ return np.sqrt(r_0**2 + r_1**2 - 2 * r_0 * r_1 * cos_alpha)
21
+
22
+
23
+ def window_vv(r_0, r_1, cos_alpha, sep, j0kr, j2kr):
24
+ """Note: here, the bisector angle definition is used to compute"""
25
+ win = 1 / 3 * (j0kr + j2kr)
26
+ alpha = np.arccos(np.clip(cos_alpha, -1.0, 1.0))
27
+ phi = cov_utils.compute_phi_bisector_theorem(sep, alpha, r_0, r_1)
28
+ win += -j2kr * np.cos(phi) ** 2
29
+ return win
30
+
31
+
32
+ def window_vg(r_0, r_1, cos_alpha, sep, j1kr):
33
+ """Note: here, the bisector angle definition is used to compute"""
34
+ alpha = np.arccos(np.clip(cos_alpha, -1.0, 1.0))
35
+ phi = cov_utils.compute_phi_bisector_theorem(sep, alpha, r_0, r_1)
36
+ win = j1kr * np.cos(phi)
37
+ return win
38
+
39
+
40
+ def intp(win, k, pk):
41
+ pint = win.T * pk
42
+ return np.trapz(pint, x=k)
43
+
44
+
45
+ def compute_coef_gg(k, pk, coord):
46
+ cos = angle_between(coord[0], coord[1], coord[2], coord[3])
47
+ sep = separation(coord[4], coord[5], cos)
48
+ ksep = np.outer(k, sep)
49
+ j0 = spherical_jn(0, ksep)
50
+ res = intp(j0, k, pk * k**2)
51
+ return res
52
+
53
+
54
+ def compute_coef_gv(k, pk, coord):
55
+ cos = angle_between(coord[0], coord[1], coord[2], coord[3])
56
+ sep = separation(coord[4], coord[5], cos)
57
+ ksep = np.outer(k, sep)
58
+ j1 = spherical_jn(1, ksep)
59
+ res = window_vg(coord[4], coord[5], cos, sep, j1)
60
+ res = intp(res, k, pk * k)
61
+ return res
62
+
63
+
64
+ def compute_coef_vv(k, pk, coord):
65
+ cos = angle_between(coord[0], coord[1], coord[2], coord[3])
66
+ sep = separation(coord[4], coord[5], cos)
67
+ ksep = np.outer(k, sep)
68
+ j0 = spherical_jn(0, ksep)
69
+ j2 = spherical_jn(2, ksep)
70
+ res = window_vv(coord[4], coord[5], cos, sep, j0, j2)
71
+ res = intp(res, k, pk)
72
+ return res
73
+
74
+
75
+ def covariance_vv(
76
+ ra_v,
77
+ dec_v,
78
+ rcomov_v,
79
+ wavenumber,
80
+ power_spectrum,
81
+ size_batch=100_000,
82
+ number_worker=8,
83
+ ):
84
+ N = len(ra_v)
85
+ n_task = int((N * (N + 1)) / 2) - N
86
+ batches = []
87
+ for n in range(0, n_task, size_batch):
88
+ brange = np.arange(n, np.min((n + size_batch, n_task)))
89
+ i_list, j_list = cov_utils.compute_i_j(N, brange)
90
+ r_comovi, rai, deci = rcomov_v[i_list], ra_v[i_list], dec_v[i_list]
91
+ r_comovj, raj, decj = rcomov_v[j_list], ra_v[j_list], dec_v[j_list]
92
+ batches.append([rai, raj, deci, decj, r_comovi, r_comovj])
93
+
94
+ with mp.Pool(number_worker) as pool:
95
+ func = partial(compute_coef_vv, wavenumber, power_spectrum)
96
+ pool_results = pool.map(func, batches)
97
+ values = np.concatenate(pool_results)
98
+
99
+ var_val = np.trapz(power_spectrum / 3, x=wavenumber)
100
+ cov = np.insert(values, 0, var_val)
101
+ cov = 100**2 / (2 * np.pi**2) * cov
102
+ return cov
103
+
104
+
105
+ def covariance_gv(
106
+ ra_g,
107
+ dec_g,
108
+ rcomov_g,
109
+ ra_v,
110
+ dec_v,
111
+ rcomov_v,
112
+ wavenumber,
113
+ power_spectrum,
114
+ size_batch=100_000,
115
+ number_worker=8,
116
+ ):
117
+ number_objects_g = len(ra_g)
118
+ number_objects_v = len(ra_v)
119
+
120
+ n_task = int(number_objects_g * number_objects_v)
121
+ batches = []
122
+ for n in range(0, n_task, size_batch):
123
+ brange = np.arange(n, np.min((n + size_batch, n_task)))
124
+ i_list, j_list = cov_utils.compute_i_j_cross_matrix(number_objects_v, brange)
125
+ r_comovi, rai, deci = rcomov_g[i_list], ra_g[i_list], dec_g[i_list]
126
+ r_comovj, raj, decj = rcomov_v[j_list], ra_v[j_list], dec_v[j_list]
127
+ batches.append([rai, raj, deci, decj, r_comovi, r_comovj])
128
+
129
+ with mp.Pool(number_worker) as pool:
130
+ func = partial(compute_coef_gv, wavenumber, power_spectrum)
131
+ pool_results = pool.map(func, batches)
132
+ values = np.concatenate(pool_results)
133
+ var_val = compute_coef_gv(
134
+ wavenumber, power_spectrum, [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
135
+ )
136
+ cov = np.insert(values, 0, var_val)
137
+ cov = 100 / (2 * np.pi**2) * cov
138
+ return cov
139
+
140
+
141
+ def covariance_gg(
142
+ ra_g,
143
+ dec_g,
144
+ rcomov_g,
145
+ wavenumber,
146
+ power_spectrum,
147
+ size_batch=100_000,
148
+ number_worker=8,
149
+ ):
150
+ N = len(ra_g)
151
+ n_task = int((N * (N + 1)) / 2) - N
152
+ batches = []
153
+ for n in range(0, n_task, size_batch):
154
+ brange = np.arange(n, np.min((n + size_batch, n_task)))
155
+ i_list, j_list = cov_utils.compute_i_j(N, brange)
156
+ r_comovi, rai, deci = rcomov_g[i_list], ra_g[i_list], dec_g[i_list]
157
+ r_comovj, raj, decj = rcomov_g[j_list], ra_g[j_list], dec_g[j_list]
158
+ batches.append([rai, raj, deci, decj, r_comovi, r_comovj])
159
+
160
+ with mp.Pool(number_worker) as pool:
161
+ func = partial(compute_coef_gg, wavenumber, power_spectrum)
162
+ pool_results = pool.map(func, batches)
163
+ values = np.concatenate(pool_results)
164
+ var_val = compute_coef_gg(
165
+ wavenumber, power_spectrum, [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
166
+ )
167
+ cov = np.insert(values, 0, var_val)
168
+ cov = 1 / (2 * np.pi**2) * cov
169
+ return cov
170
+
171
+
172
+ def generate_covariance(
173
+ model_kind,
174
+ power_spectrum_dict,
175
+ coordinates_velocity=None,
176
+ coordinates_density=None,
177
+ **kwargs,
178
+ ):
179
+ """
180
+ The generate_covariance function generates the covariance matrix for a given model type, power spectrum, and coordinates.
181
+
182
+ Args:
183
+ model_kind: Determine which covariance matrices are generated, and the coordinates_density and coordinates_velocity parameters are used to generate the covariance matrices
184
+ power_spectrum_dict: Pass the power spectrum to the function
185
+ coordinates_velocity: Define the coordinates of the velocity field
186
+ coordinates_density: Define the coordinates of the density field
187
+ **kwargs: Pass keyword arguments to the function
188
+ : Generate the covariance matrix for a given model
189
+ The wide angle definition is bisector.
190
+
191
+ Returns:
192
+ A dictionary of covariance matrices
193
+
194
+ Doc Author:
195
+ Trelent
196
+ """
197
+ cov_utils.check_generator_need(
198
+ model_kind,
199
+ coordinates_density,
200
+ coordinates_velocity,
201
+ )
202
+ covariance_dict = {}
203
+
204
+ if model_kind in ["density", "full", "density_velocity"]:
205
+ covariance_dict["gg"] = np.array(
206
+ [
207
+ covariance_gg(
208
+ coordinates_density[0],
209
+ coordinates_density[1],
210
+ coordinates_density[2],
211
+ power_spectrum_dict["gg"][0][0],
212
+ power_spectrum_dict["gg"][0][1],
213
+ **kwargs,
214
+ )
215
+ ]
216
+ )
217
+ number_densities = len(coordinates_density[0])
218
+ else:
219
+ number_densities = None
220
+
221
+ if model_kind in ["velocity", "full", "density_velocity"]:
222
+ covariance_dict["vv"] = np.array(
223
+ [
224
+ covariance_vv(
225
+ coordinates_velocity[0],
226
+ coordinates_velocity[1],
227
+ coordinates_velocity[2],
228
+ power_spectrum_dict["vv"][0][0],
229
+ power_spectrum_dict["vv"][0][1],
230
+ **kwargs,
231
+ )
232
+ ]
233
+ )
234
+ number_velocities = len(coordinates_velocity[0])
235
+ else:
236
+ number_velocities = None
237
+
238
+ if model_kind == "full":
239
+ covariance_dict["gv"] = np.array(
240
+ [
241
+ covariance_gv(
242
+ coordinates_density[0],
243
+ coordinates_density[1],
244
+ coordinates_density[2],
245
+ coordinates_velocity[0],
246
+ coordinates_velocity[1],
247
+ coordinates_velocity[2],
248
+ power_spectrum_dict["gv"][0][0],
249
+ power_spectrum_dict["gv"][0][1],
250
+ **kwargs,
251
+ )
252
+ ]
253
+ )
254
+
255
+ los_definition = "bisector"
256
+ redshift_dict = None
257
+ return (
258
+ covariance_dict,
259
+ number_densities,
260
+ number_velocities,
261
+ los_definition,
262
+ redshift_dict,
263
+ )
@@ -0,0 +1,10 @@
1
+ _variant = [None, "baseline", "nobeta"]
2
+
3
+ _free_par = {
4
+ "fs8": ["velocity@all", "density@nobeta"],
5
+ "bs8": "density@all",
6
+ "sigv": "velocity@all",
7
+ "beta_f": "density@baseline",
8
+ }
9
+
10
+ _coordinate_keys = ["ra", "dec", "rcom_zobs"]
@@ -0,0 +1,46 @@
1
+ def get_coefficients(
2
+ parameter_values_dict,
3
+ model_kind,
4
+ variant=None,
5
+ redshift_dict=None,
6
+ ):
7
+ coefficients_dict = {}
8
+ if model_kind in ["density", "full", "density_velocity"]:
9
+ if variant == "nobeta":
10
+ coefficients_dict["gg"] = [
11
+ parameter_values_dict["bs8"] ** 2,
12
+ parameter_values_dict["bs8"] * parameter_values_dict["fs8"],
13
+ parameter_values_dict["fs8"] ** 2,
14
+ ]
15
+ else:
16
+ coefficients_dict["gg"] = [
17
+ parameter_values_dict["bs8"] ** 2,
18
+ parameter_values_dict["bs8"] ** 2 * parameter_values_dict["beta_f"],
19
+ parameter_values_dict["bs8"] ** 2
20
+ * parameter_values_dict["beta_f"] ** 2,
21
+ ]
22
+ if model_kind in ["full"]:
23
+ if variant == "nobeta":
24
+ coefficients_dict["gv"] = [
25
+ parameter_values_dict["bs8"] * parameter_values_dict["fs8"],
26
+ parameter_values_dict["fs8"] ** 2,
27
+ ]
28
+ else:
29
+ coefficients_dict["gv"] = [
30
+ parameter_values_dict["bs8"] * parameter_values_dict["fs8"],
31
+ parameter_values_dict["bs8"]
32
+ * parameter_values_dict["fs8"]
33
+ * parameter_values_dict["beta_f"],
34
+ ]
35
+ if model_kind in ["velocity", "full", "density_velocity"]:
36
+ coefficients_dict["vv"] = [parameter_values_dict["fs8"] ** 2]
37
+ return coefficients_dict
38
+
39
+
40
+ def get_diagonal_coefficients(parameter_values_dict, model_kind):
41
+ coefficients_dict = {}
42
+ if model_kind in ["density", "full", "density_velocity"]:
43
+ coefficients_dict["gg"] = 0.0
44
+ if model_kind in ["velocity", "full", "density_velocity"]:
45
+ coefficients_dict["vv"] = parameter_values_dict["sigv"] ** 2
46
+ return coefficients_dict