flipcosmo 1.0.0__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 (95) hide show
  1. flipcosmo-1.0.0/LICENSE +21 -0
  2. flipcosmo-1.0.0/PKG-INFO +32 -0
  3. flipcosmo-1.0.0/README.md +46 -0
  4. flipcosmo-1.0.0/flip/__init__.py +27 -0
  5. flipcosmo-1.0.0/flip/config.py +1 -0
  6. flipcosmo-1.0.0/flip/covariance/__init__.py +15 -0
  7. flipcosmo-1.0.0/flip/covariance/adamsblake17/__init__.py +5 -0
  8. flipcosmo-1.0.0/flip/covariance/adamsblake17/coefficients.py +27 -0
  9. flipcosmo-1.0.0/flip/covariance/adamsblake17/fisher_terms.py +300 -0
  10. flipcosmo-1.0.0/flip/covariance/adamsblake17/flip_terms.py +78 -0
  11. flipcosmo-1.0.0/flip/covariance/adamsblake17plane/__init__.py +5 -0
  12. flipcosmo-1.0.0/flip/covariance/adamsblake17plane/coefficients.py +27 -0
  13. flipcosmo-1.0.0/flip/covariance/adamsblake17plane/fisher_terms.py +300 -0
  14. flipcosmo-1.0.0/flip/covariance/adamsblake17plane/flip_terms.py +75 -0
  15. flipcosmo-1.0.0/flip/covariance/adamsblake17plane/generator.py +263 -0
  16. flipcosmo-1.0.0/flip/covariance/adamsblake20/__init__.py +10 -0
  17. flipcosmo-1.0.0/flip/covariance/adamsblake20/coefficients.py +46 -0
  18. flipcosmo-1.0.0/flip/covariance/adamsblake20/fisher_terms.py +813 -0
  19. flipcosmo-1.0.0/flip/covariance/adamsblake20/flip_terms.py +346 -0
  20. flipcosmo-1.0.0/flip/covariance/carreres23/__init__.py +8 -0
  21. flipcosmo-1.0.0/flip/covariance/carreres23/coefficients.py +18 -0
  22. flipcosmo-1.0.0/flip/covariance/carreres23/fisher_terms.py +48 -0
  23. flipcosmo-1.0.0/flip/covariance/carreres23/flip_terms.py +46 -0
  24. flipcosmo-1.0.0/flip/covariance/carreres23/generator.py +132 -0
  25. flipcosmo-1.0.0/flip/covariance/contraction.py +345 -0
  26. flipcosmo-1.0.0/flip/covariance/cov_utils.py +437 -0
  27. flipcosmo-1.0.0/flip/covariance/covariance.py +825 -0
  28. flipcosmo-1.0.0/flip/covariance/emulators/__init__.py +3 -0
  29. flipcosmo-1.0.0/flip/covariance/emulators/generator.py +317 -0
  30. flipcosmo-1.0.0/flip/covariance/emulators/gpmatrix.py +95 -0
  31. flipcosmo-1.0.0/flip/covariance/emulators/nnmatrix.py +218 -0
  32. flipcosmo-1.0.0/flip/covariance/generator.py +713 -0
  33. flipcosmo-1.0.0/flip/covariance/lai22/__init__.py +11 -0
  34. flipcosmo-1.0.0/flip/covariance/lai22/coefficients.py +83 -0
  35. flipcosmo-1.0.0/flip/covariance/lai22/fisher_terms.py +3911 -0
  36. flipcosmo-1.0.0/flip/covariance/lai22/flip_terms.py +16003 -0
  37. flipcosmo-1.0.0/flip/covariance/lai22/generator.py +868 -0
  38. flipcosmo-1.0.0/flip/covariance/lai22/h_terms.py +2202 -0
  39. flipcosmo-1.0.0/flip/covariance/lai22/symbolic.py +148 -0
  40. flipcosmo-1.0.0/flip/covariance/ravouxcarreres/__init__.py +10 -0
  41. flipcosmo-1.0.0/flip/covariance/ravouxcarreres/coefficients.py +46 -0
  42. flipcosmo-1.0.0/flip/covariance/ravouxcarreres/fisher_terms.py +813 -0
  43. flipcosmo-1.0.0/flip/covariance/ravouxcarreres/flip_terms.py +884 -0
  44. flipcosmo-1.0.0/flip/covariance/ravouxcarreres/flip_terms_lmax.py +3395 -0
  45. flipcosmo-1.0.0/flip/covariance/ravouxnoanchor25/__init__.py +13 -0
  46. flipcosmo-1.0.0/flip/covariance/ravouxnoanchor25/coefficients.py +49 -0
  47. flipcosmo-1.0.0/flip/covariance/ravouxnoanchor25/fisher_terms.py +48 -0
  48. flipcosmo-1.0.0/flip/covariance/ravouxnoanchor25/flip_terms.py +54 -0
  49. flipcosmo-1.0.0/flip/covariance/rcrk24/__init__.py +10 -0
  50. flipcosmo-1.0.0/flip/covariance/rcrk24/coefficients.py +251 -0
  51. flipcosmo-1.0.0/flip/covariance/rcrk24/fisher_terms.py +126 -0
  52. flipcosmo-1.0.0/flip/covariance/rcrk24/flip_terms.py +55 -0
  53. flipcosmo-1.0.0/flip/covariance/symbolic.py +1274 -0
  54. flipcosmo-1.0.0/flip/data/__init__.py +3 -0
  55. flipcosmo-1.0.0/flip/data/density_data.parquet +0 -0
  56. flipcosmo-1.0.0/flip/data/grid_window_m.parquet +0 -0
  57. flipcosmo-1.0.0/flip/data/power_spectrum_mm.txt +3 -0
  58. flipcosmo-1.0.0/flip/data/power_spectrum_mt.txt +3 -0
  59. flipcosmo-1.0.0/flip/data/power_spectrum_tt.txt +3 -0
  60. flipcosmo-1.0.0/flip/data/style.mplstyle +86 -0
  61. flipcosmo-1.0.0/flip/data/velocity_data.parquet +0 -0
  62. flipcosmo-1.0.0/flip/data_vector/__init__.py +4 -0
  63. flipcosmo-1.0.0/flip/data_vector/basic.py +374 -0
  64. flipcosmo-1.0.0/flip/data_vector/cosmo_utils.py +6 -0
  65. flipcosmo-1.0.0/flip/data_vector/galaxypv_vectors.py +480 -0
  66. flipcosmo-1.0.0/flip/data_vector/snia_vectors.py +172 -0
  67. flipcosmo-1.0.0/flip/data_vector/vector_utils.py +148 -0
  68. flipcosmo-1.0.0/flip/fisher.py +190 -0
  69. flipcosmo-1.0.0/flip/fit_utils.py +882 -0
  70. flipcosmo-1.0.0/flip/fitter.py +558 -0
  71. flipcosmo-1.0.0/flip/gridding.py +999 -0
  72. flipcosmo-1.0.0/flip/likelihood.py +610 -0
  73. flipcosmo-1.0.0/flip/plot_utils.py +477 -0
  74. flipcosmo-1.0.0/flip/power_spectra/__init__.py +4 -0
  75. flipcosmo-1.0.0/flip/power_spectra/class_engine.py +165 -0
  76. flipcosmo-1.0.0/flip/power_spectra/cosmoprimo_engine.py +73 -0
  77. flipcosmo-1.0.0/flip/power_spectra/generator.py +190 -0
  78. flipcosmo-1.0.0/flip/power_spectra/models.py +124 -0
  79. flipcosmo-1.0.0/flip/power_spectra/pyccl_engine.py +96 -0
  80. flipcosmo-1.0.0/flip/utils.py +228 -0
  81. flipcosmo-1.0.0/flipcosmo.egg-info/PKG-INFO +32 -0
  82. flipcosmo-1.0.0/flipcosmo.egg-info/SOURCES.txt +94 -0
  83. flipcosmo-1.0.0/flipcosmo.egg-info/dependency_links.txt +1 -0
  84. flipcosmo-1.0.0/flipcosmo.egg-info/requires.txt +22 -0
  85. flipcosmo-1.0.0/flipcosmo.egg-info/top_level.txt +1 -0
  86. flipcosmo-1.0.0/setup.cfg +43 -0
  87. flipcosmo-1.0.0/setup.py +63 -0
  88. flipcosmo-1.0.0/test/test_covariance_assembly.py +92 -0
  89. flipcosmo-1.0.0/test/test_covariance_reference_values.py +138 -0
  90. flipcosmo-1.0.0/test/test_covariance_utils.py +35 -0
  91. flipcosmo-1.0.0/test/test_e2e_density.py +57 -0
  92. flipcosmo-1.0.0/test/test_e2e_joint.py +76 -0
  93. flipcosmo-1.0.0/test/test_e2e_velocity.py +65 -0
  94. flipcosmo-1.0.0/test/test_likelihood_inversions.py +32 -0
  95. flipcosmo-1.0.0/test/test_models_coverage.py +126 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 corentinravoux
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,32 @@
1
+ Metadata-Version: 2.4
2
+ Name: flipcosmo
3
+ Version: 1.0.0
4
+ Summary: Field Level Inference Package
5
+ Home-page: https://github.com/corentinravoux/flip
6
+ Author: Corentin Ravoux
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Requires-Dist: pandas
10
+ Requires-Dist: numpy
11
+ Requires-Dist: scipy>=1.12
12
+ Requires-Dist: matplotlib
13
+ Requires-Dist: importlib-metadata
14
+ Requires-Dist: emcee
15
+ Requires-Dist: iminuit
16
+ Requires-Dist: astropy
17
+ Requires-Dist: mpmath
18
+ Provides-Extra: docs
19
+ Requires-Dist: markdown; extra == "docs"
20
+ Requires-Dist: sphinx>=5.2.3; extra == "docs"
21
+ Requires-Dist: sphinx-markdown-tables>=0.0.15; extra == "docs"
22
+ Requires-Dist: numpydoc; extra == "docs"
23
+ Requires-Dist: sphinx_book_theme; extra == "docs"
24
+ Requires-Dist: myst-parser; extra == "docs"
25
+ Requires-Dist: sphinx-copybutton; extra == "docs"
26
+ Requires-Dist: sphinx-design; extra == "docs"
27
+ Requires-Dist: sphinx-inline-tabs; extra == "docs"
28
+ Requires-Dist: sphinx-tabs; extra == "docs"
29
+ Requires-Dist: sphinx-autoapi; extra == "docs"
30
+ Dynamic: license-file
31
+
32
+ file : README.md
@@ -0,0 +1,46 @@
1
+ <img src="docs/_static/flip_logo.webp" width=350>
2
+
3
+ # flip: Field Level Inference Package
4
+
5
+ flip is a Python package that uses the maximum likelihood method to fit the growth rate based on the velocity and density fields. The first part of the software is the computation of a covariance matrix from a model power spectrum and the considered coordinates. This part is generalized to work for any linear power spectrum models, both for velocities, densities, and cross-terms, and it is optimized with Hankel transform for any model. In the second part, the covariance is used to create a likelihood by multiplying it by velocities or densities. Finally, this package includes some integrated fitters such as Minuit and MCMC (with emcee) to fit the growth rate of structures.
6
+
7
+
8
+ [![Documentation Status](https://readthedocs.org/projects/flip/badge/?version=latest)](https://flip.readthedocs.io/en/latest/?badge=latest)
9
+
10
+ ## Quick install
11
+ ```bash
12
+ git clone https://github.com/corentinravoux/flip.git
13
+ cd flip
14
+ pip install .
15
+ ```
16
+ For now, the package requires you to install manually cosmoprimo: pip install git+https://github.com/cosmodesi/cosmoprimo
17
+
18
+
19
+ ## Required packages
20
+
21
+ Mandatory: numpy, scipy, matplotlib, [cosmoprimo](https://github.com/adematti/cosmoprimo), iminuit, emcee, sympy
22
+
23
+ Optional: classy, pyccl, pypower, GPy, tensorflow
24
+
25
+ ## Examples
26
+
27
+ For an example with velocity fit check out: <a target="_blank" href="https://colab.research.google.com/github/corentinravoux/flip/blob/main/notebook/fit_velocity.ipynb">
28
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
29
+ </a>
30
+
31
+ For density only: <a target="_blank" href="https://colab.research.google.com/github/corentinravoux/flip/blob/main/notebook/fit_density.ipynb">
32
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
33
+ </a>
34
+
35
+ For a joint fit: <a target="_blank" href="https://colab.research.google.com/github/corentinravoux/flip/blob/main/notebook/fit_joint.ipynb">
36
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
37
+ </a>
38
+
39
+ ## Need help?
40
+ Documentation available on [ReadTheDoc](https://flip.readthedocs.io/)
41
+
42
+ ## How to cite
43
+
44
+ The full description of the core concepts of this package is given [here](https://arxiv.org/abs/2501.16852).
45
+ This package was started on the previous work of [@bastiencarreres](https://github.com/bastiencarreres), detail in [this article](https://arxiv.org/abs/2303.01198).
46
+ Please cite both paper when using the package.
@@ -0,0 +1,27 @@
1
+ """Init file of the flip package."""
2
+
3
+ import os
4
+
5
+ from flip.utils import create_log
6
+
7
+ log = create_log()
8
+ from . import (
9
+ covariance,
10
+ data_vector,
11
+ fisher,
12
+ fitter,
13
+ gridding,
14
+ likelihood,
15
+ power_spectra,
16
+ utils,
17
+ )
18
+
19
+ try:
20
+ import jax
21
+
22
+ jax.config.update("jax_enable_x64", True)
23
+ except:
24
+ log.add("Jax is not available, loading numpy and scipy instead")
25
+
26
+ __version__ = "1.0.0"
27
+ __flip_dir_path__ = os.path.dirname(__file__)
@@ -0,0 +1 @@
1
+ __use_jax__ = True
@@ -0,0 +1,15 @@
1
+ """Init file of the flip.covariance package."""
2
+
3
+ from . import (
4
+ adamsblake17,
5
+ adamsblake17plane,
6
+ adamsblake20,
7
+ carreres23,
8
+ cov_utils,
9
+ emulators,
10
+ lai22,
11
+ ravouxcarreres,
12
+ ravouxnoanchor25,
13
+ rcrk24,
14
+ )
15
+ from .covariance import CovMatrix
@@ -0,0 +1,5 @@
1
+ _variant = [None]
2
+
3
+ _free_par = {"fs8": "velocity@all", "bs8": "density@all", "sigv": "velocity@all"}
4
+
5
+ _coordinate_keys = ["ra", "dec", "rcom_zobs"]
@@ -0,0 +1,27 @@
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
+ coefficients_dict["gg"] = [
10
+ parameter_values_dict["bs8"] ** 2,
11
+ ]
12
+ if model_kind in ["full"]:
13
+ coefficients_dict["gv"] = [
14
+ parameter_values_dict["bs8"] * parameter_values_dict["fs8"],
15
+ ]
16
+ if model_kind in ["velocity", "full", "density_velocity"]:
17
+ coefficients_dict["vv"] = [parameter_values_dict["fs8"] ** 2]
18
+ return coefficients_dict
19
+
20
+
21
+ def get_diagonal_coefficients(parameter_values_dict, model_kind):
22
+ coefficients_dict = {}
23
+ if model_kind in ["density", "full", "density_velocity"]:
24
+ coefficients_dict["gg"] = 0.0
25
+ if model_kind in ["velocity", "full", "density_velocity"]:
26
+ coefficients_dict["vv"] = parameter_values_dict["sigv"] ** 2
27
+ return coefficients_dict
@@ -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,78 @@
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 + (1 / 2) * theta)
39
+
40
+
41
+ def M_vv_0_0_0():
42
+ def func(k):
43
+ return (10000 / 9) / k**2
44
+
45
+ return func
46
+
47
+
48
+ def N_vv_0_0_0(theta, phi):
49
+ return 3 * np.cos(theta)
50
+
51
+
52
+ def M_vv_0_2_0():
53
+ def func(k):
54
+ return (10000 / 9) / k**2
55
+
56
+ return func
57
+
58
+
59
+ def N_vv_0_2_0(theta, phi):
60
+ return (9 / 2) * np.cos(2 * phi) + (3 / 2) * np.cos(theta)
61
+
62
+
63
+ dictionary_terms = {"gg": ["0"], "gv": ["0"], "vv": ["0"]}
64
+ dictionary_lmax = {"gg": [2], "gv": [2], "vv": [2]}
65
+ dictionary_subterms = {
66
+ "gg_0_0": 1,
67
+ "gg_0_1": 0,
68
+ "gg_0_2": 0,
69
+ "gv_0_0": 0,
70
+ "gv_0_1": 1,
71
+ "gv_0_2": 0,
72
+ "vv_0_0": 1,
73
+ "vv_0_1": 0,
74
+ "vv_0_2": 1,
75
+ }
76
+ multi_index_model = False
77
+ redshift_dependent_model = False
78
+ regularize_M_terms = None
@@ -0,0 +1,5 @@
1
+ _variant = [None]
2
+
3
+ _free_par = {"fs8": "velocity@all", "bs8": "density@all", "sigv": "velocity@all"}
4
+
5
+ _coordinate_keys = ["ra", "dec", "rcom_zobs"]
@@ -0,0 +1,27 @@
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
+ coefficients_dict["gg"] = [
10
+ parameter_values_dict["bs8"] ** 2,
11
+ ]
12
+ if model_kind in ["full"]:
13
+ coefficients_dict["gv"] = [
14
+ parameter_values_dict["bs8"] * parameter_values_dict["fs8"],
15
+ ]
16
+ if model_kind in ["velocity", "full", "density_velocity"]:
17
+ coefficients_dict["vv"] = [parameter_values_dict["fs8"] ** 2]
18
+ return coefficients_dict
19
+
20
+
21
+ def get_diagonal_coefficients(parameter_values_dict, model_kind):
22
+ coefficients_dict = {}
23
+ if model_kind in ["density", "full", "density_velocity"]:
24
+ coefficients_dict["gg"] = 0.0
25
+ if model_kind in ["velocity", "full", "density_velocity"]:
26
+ coefficients_dict["vv"] = parameter_values_dict["sigv"] ** 2
27
+ return coefficients_dict