flipcosmo 1.0.0__py3-none-any.whl → 1.2.1__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.
- docs/conf.py +154 -0
- flip/__init__.py +4 -11
- flip/covariance/__init__.py +7 -8
- flip/covariance/analytical/__init__.py +11 -0
- flip/covariance/{adamsblake17plane → analytical/adamsblake17}/coefficients.py +1 -1
- flip/covariance/{adamsblake17plane → analytical/adamsblake17}/fisher_terms.py +1 -1
- flip/covariance/{adamsblake17 → analytical/adamsblake17}/flip_terms.py +0 -1
- flip/covariance/{adamsblake17 → analytical/adamsblake17plane}/coefficients.py +1 -1
- flip/covariance/{adamsblake17 → analytical/adamsblake17plane}/fisher_terms.py +1 -1
- flip/covariance/{adamsblake17plane → analytical/adamsblake17plane}/flip_terms.py +0 -1
- flip/covariance/{adamsblake17plane → analytical/adamsblake17plane}/generator.py +103 -19
- flip/covariance/{adamsblake20 → analytical/adamsblake20}/coefficients.py +1 -1
- flip/covariance/{adamsblake20 → analytical/adamsblake20}/fisher_terms.py +1 -1
- flip/covariance/{adamsblake20 → analytical/adamsblake20}/flip_terms.py +0 -1
- flip/covariance/{carreres23 → analytical/carreres23}/coefficients.py +1 -4
- flip/covariance/{ravouxnoanchor25 → analytical/carreres23}/fisher_terms.py +1 -1
- flip/covariance/{carreres23 → analytical/carreres23}/flip_terms.py +0 -1
- flip/covariance/analytical/carreres23/generator.py +198 -0
- flip/covariance/analytical/genericzdep/__init__.py +5 -0
- flip/covariance/analytical/genericzdep/coefficients.py +53 -0
- flip/covariance/analytical/genericzdep/flip_terms.py +99 -0
- flip/covariance/{lai22 → analytical/lai22}/coefficients.py +2 -3
- flip/covariance/{lai22 → analytical/lai22}/fisher_terms.py +1 -1
- flip/covariance/{lai22 → analytical/lai22}/flip_terms.py +0 -1
- flip/covariance/{lai22 → analytical/lai22}/generator.py +263 -58
- flip/covariance/{lai22 → analytical/lai22}/symbolic.py +55 -19
- flip/covariance/{ravouxcarreres → analytical/ravouxcarreres}/coefficients.py +1 -1
- flip/covariance/{ravouxcarreres → analytical/ravouxcarreres}/fisher_terms.py +1 -1
- flip/covariance/{ravouxcarreres → analytical/ravouxcarreres}/flip_terms.py +0 -1
- flip/covariance/{ravouxnoanchor25 → analytical/ravouxnoanchor25}/coefficients.py +3 -2
- flip/covariance/{carreres23 → analytical/ravouxnoanchor25}/fisher_terms.py +1 -1
- flip/covariance/{ravouxnoanchor25 → analytical/ravouxnoanchor25}/flip_terms.py +0 -9
- flip/covariance/{rcrk24 → analytical/rcrk24}/coefficients.py +6 -6
- flip/covariance/{rcrk24 → analytical/rcrk24}/fisher_terms.py +7 -9
- flip/covariance/{rcrk24 → analytical/rcrk24}/flip_terms.py +0 -8
- flip/covariance/contraction.py +82 -40
- flip/covariance/cov_utils.py +89 -81
- flip/covariance/covariance.py +172 -141
- flip/covariance/emulators/__init__.py +1 -1
- flip/covariance/emulators/generator.py +73 -3
- flip/covariance/emulators/gpmatrix.py +40 -1
- flip/covariance/emulators/nnmatrix.py +57 -1
- flip/covariance/emulators/skgpmatrix.py +125 -0
- flip/covariance/fisher.py +307 -0
- flip/{fit_utils.py → covariance/fit_utils.py} +185 -10
- flip/{fitter.py → covariance/fitter.py} +151 -125
- flip/covariance/generator.py +82 -106
- flip/{likelihood.py → covariance/likelihood.py} +286 -64
- flip/{plot_utils.py → covariance/plot_utils.py} +79 -4
- flip/covariance/symbolic.py +89 -44
- flip/data/__init__.py +1 -1
- flip/data/data_density.parquet +0 -0
- flip/data/data_velocity.parquet +0 -0
- flip/data/{grid_window_m.parquet → data_window_density.parquet} +0 -0
- flip/{gridding.py → data/gridding.py} +125 -130
- flip/data/load_data_test.py +102 -0
- flip/data/power_spectrum_mm.txt +2 -2
- flip/data/power_spectrum_mt.txt +2 -2
- flip/data/power_spectrum_tt.txt +2 -2
- flip/data/test_covariance_reference_values.json +145 -0
- flip/data/test_e2e_reference_values.json +14 -0
- flip/data_vector/basic.py +118 -101
- flip/data_vector/cosmo_utils.py +18 -0
- flip/data_vector/galaxypv_vectors.py +58 -94
- flip/data_vector/snia_vectors.py +60 -3
- flip/data_vector/vector_utils.py +47 -1
- flip/power_spectra/class_engine.py +36 -1
- flip/power_spectra/cosmoprimo_engine.py +37 -2
- flip/power_spectra/generator.py +47 -25
- flip/power_spectra/models.py +30 -31
- flip/power_spectra/pyccl_engine.py +36 -1
- flip/simulation/__init__.py +0 -0
- flip/utils.py +62 -91
- flipcosmo-1.2.1.dist-info/METADATA +78 -0
- flipcosmo-1.2.1.dist-info/RECORD +109 -0
- {flipcosmo-1.0.0.dist-info → flipcosmo-1.2.1.dist-info}/WHEEL +1 -1
- flipcosmo-1.2.1.dist-info/top_level.txt +7 -0
- scripts/flip_compute_correlation_model.py +70 -0
- scripts/flip_compute_power_spectra.py +50 -0
- scripts/flip_fisher_forecast_velocity.py +70 -0
- scripts/flip_fisher_rcrk24.py +164 -0
- scripts/flip_launch_minuit_density_fit.py +91 -0
- scripts/flip_launch_minuit_full_fit.py +117 -0
- scripts/flip_launch_minuit_velocity_fit.py +78 -0
- scripts/flip_launch_minuit_velocity_fit_full.py +107 -0
- scripts/flip_launch_minuit_velocity_fit_interpolation.py +93 -0
- test/refresh_reference_values.py +43 -0
- test/test_covariance_assembly.py +102 -0
- test/test_covariance_reference_values.py +125 -0
- test/test_covariance_utils.py +34 -0
- test/test_e2e_density.py +50 -0
- test/test_e2e_joint.py +65 -0
- test/test_e2e_velocity.py +53 -0
- test/test_likelihood_inversions.py +31 -0
- flip/covariance/carreres23/generator.py +0 -132
- flip/data/density_data.parquet +0 -0
- flip/data/velocity_data.parquet +0 -0
- flip/fisher.py +0 -190
- flipcosmo-1.0.0.dist-info/METADATA +0 -32
- flipcosmo-1.0.0.dist-info/RECORD +0 -82
- flipcosmo-1.0.0.dist-info/top_level.txt +0 -1
- /flip/{config.py → _config.py} +0 -0
- /flip/covariance/{adamsblake17 → analytical/adamsblake17}/__init__.py +0 -0
- /flip/covariance/{adamsblake17plane → analytical/adamsblake17plane}/__init__.py +0 -0
- /flip/covariance/{adamsblake20 → analytical/adamsblake20}/__init__.py +0 -0
- /flip/covariance/{carreres23 → analytical/carreres23}/__init__.py +0 -0
- /flip/covariance/{lai22 → analytical/lai22}/__init__.py +0 -0
- /flip/covariance/{lai22 → analytical/lai22}/h_terms.py +0 -0
- /flip/covariance/{ravouxcarreres → analytical/ravouxcarreres}/__init__.py +0 -0
- /flip/covariance/{ravouxcarreres → analytical/ravouxcarreres}/flip_terms_lmax.py +0 -0
- /flip/covariance/{ravouxnoanchor25 → analytical/ravouxnoanchor25}/__init__.py +0 -0
- /flip/covariance/{rcrk24 → analytical/rcrk24}/__init__.py +0 -0
- {flipcosmo-1.0.0.dist-info → flipcosmo-1.2.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -7,11 +7,12 @@ def get_coefficients(
|
|
|
7
7
|
model_kind,
|
|
8
8
|
parameter_values_dict,
|
|
9
9
|
variant=None,
|
|
10
|
-
|
|
10
|
+
covariance_prefactor_dict=None,
|
|
11
11
|
):
|
|
12
12
|
H0 = parameter_values_dict["H0"]
|
|
13
13
|
Omega_m0 = parameter_values_dict["Omega_m0"]
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
redshift_velocity = covariance_prefactor_dict["redshift_velocity"]
|
|
15
16
|
|
|
16
17
|
D1_z = D1_function(redshift_velocity, Omega_m0)
|
|
17
18
|
D1_0 = D1_function(0, Omega_m0)
|
|
@@ -2,8 +2,6 @@ import mpmath
|
|
|
2
2
|
import numpy
|
|
3
3
|
import scipy
|
|
4
4
|
|
|
5
|
-
from flip.covariance.ravouxnoanchor25.coefficients import D1_function
|
|
6
|
-
|
|
7
5
|
|
|
8
6
|
def set_backend(module):
|
|
9
7
|
global np, erf
|
|
@@ -40,15 +38,8 @@ def N_vv_0_2_0(theta, phi):
|
|
|
40
38
|
return (9 / 2) * np.cos(2 * phi) + (3 / 2) * np.cos(theta)
|
|
41
39
|
|
|
42
40
|
|
|
43
|
-
def Z_vv_0(k, redshift_1, redshift_2, Omega_m0, knl):
|
|
44
|
-
D1_z1 = D1_function(redshift_1, Omega_m0)
|
|
45
|
-
D1_z2 = D1_function(redshift_2, Omega_m0)
|
|
46
|
-
return np.exp(np.outer((D1_z1 - D1_z2) ** 2, -((k / knl) ** 2)))
|
|
47
|
-
|
|
48
|
-
|
|
49
41
|
dictionary_terms = {"vv": ["0"]}
|
|
50
42
|
dictionary_lmax = {"vv": [2]}
|
|
51
43
|
dictionary_subterms = {"vv_0_0": 1, "vv_0_1": 0, "vv_0_2": 1}
|
|
52
44
|
multi_index_model = False
|
|
53
|
-
redshift_dependent_model = True
|
|
54
45
|
regularize_M_terms = None
|
|
@@ -204,10 +204,10 @@ def get_coefficients(
|
|
|
204
204
|
parameter_values_dict,
|
|
205
205
|
model_kind,
|
|
206
206
|
variant=None,
|
|
207
|
-
|
|
207
|
+
covariance_prefactor_dict=None,
|
|
208
208
|
):
|
|
209
|
-
|
|
210
|
-
a = 1 / (1 +
|
|
209
|
+
redshift_velocity = covariance_prefactor_dict["redshift_velocity"]
|
|
210
|
+
a = 1 / (1 + redshift_velocity)
|
|
211
211
|
|
|
212
212
|
coefficients_dict = {}
|
|
213
213
|
if variant == "growth_index":
|
|
@@ -220,9 +220,9 @@ def get_coefficients(
|
|
|
220
220
|
gamma = parameter_values_dict["gamma"]
|
|
221
221
|
|
|
222
222
|
coefficient_vector = (
|
|
223
|
-
aH(1 / (1 +
|
|
223
|
+
aH(1 / (1 + redshift_velocity))
|
|
224
224
|
* f(a, Om0, gamma)
|
|
225
|
-
* s8_approx(
|
|
225
|
+
* s8_approx(redshift_velocity, Om0, gamma)
|
|
226
226
|
)
|
|
227
227
|
|
|
228
228
|
coefficients_dict["vv"] = [np.outer(coefficient_vector, coefficient_vector)]
|
|
@@ -233,7 +233,7 @@ def get_coefficients(
|
|
|
233
233
|
# P = (aHfs8)(aHfs8) (P_fid/s8^2_fid)
|
|
234
234
|
|
|
235
235
|
fs8 = parameter_values_dict["fs8"]
|
|
236
|
-
coefficient_vector = aH(1 / (1 +
|
|
236
|
+
coefficient_vector = aH(1 / (1 + redshift_velocity)) * fs8
|
|
237
237
|
|
|
238
238
|
coefficients_dict["vv"] = [np.outer(coefficient_vector, coefficient_vector)]
|
|
239
239
|
else:
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
-
from
|
|
3
|
-
|
|
4
|
-
from flip.covariance.rcrk24.coefficients import (
|
|
2
|
+
from flip.covariance.analytical.rcrk24.coefficients import (
|
|
5
3
|
aH,
|
|
6
4
|
dfdgamma,
|
|
7
5
|
dfdOm0,
|
|
@@ -29,11 +27,11 @@ def get_partial_derivative_coefficients(
|
|
|
29
27
|
model_kind,
|
|
30
28
|
parameter_values_dict,
|
|
31
29
|
variant=None,
|
|
32
|
-
|
|
30
|
+
covariance_prefactor_dict=None,
|
|
33
31
|
):
|
|
34
32
|
partial_coefficients_dict = None
|
|
35
|
-
|
|
36
|
-
a = 1 / (1 +
|
|
33
|
+
redshift_velocity = covariance_prefactor_dict["redshift_velocity"]
|
|
34
|
+
a = 1 / (1 + redshift_velocity)
|
|
37
35
|
|
|
38
36
|
if variant == "growth_index":
|
|
39
37
|
# vv
|
|
@@ -46,20 +44,20 @@ def get_partial_derivative_coefficients(
|
|
|
46
44
|
# The Om0-gamma model f=Omega(Om0)^gamma
|
|
47
45
|
aH_values = aH(a)
|
|
48
46
|
f_values = f(a, Om0, gamma) # cosmoOm ** parameter_values_dict["gamma"]
|
|
49
|
-
s8_values = s8(
|
|
47
|
+
s8_values = s8(redshift_velocity, Om0, gamma)
|
|
50
48
|
aHfs8 = aH_values * f_values * s8_values
|
|
51
49
|
|
|
52
50
|
dfdOm0_values = dfdOm0(a, Om0, gamma)
|
|
53
51
|
dfdgamma_values = dfdgamma(a, Om0, gamma)
|
|
54
52
|
|
|
55
53
|
ds8dO0_values = ds8dO0(
|
|
56
|
-
|
|
54
|
+
redshift_velocity,
|
|
57
55
|
Om0,
|
|
58
56
|
gamma,
|
|
59
57
|
s8_values=s8_values,
|
|
60
58
|
)
|
|
61
59
|
ds8dgamma_values = ds8dgamma(
|
|
62
|
-
|
|
60
|
+
redshift_velocity,
|
|
63
61
|
Om0,
|
|
64
62
|
gamma,
|
|
65
63
|
s8_values=s8_values,
|
|
@@ -15,9 +15,6 @@ def set_backend(module):
|
|
|
15
15
|
|
|
16
16
|
set_backend("numpy")
|
|
17
17
|
|
|
18
|
-
import scipy.integrate as integrate
|
|
19
|
-
from astropy.cosmology import FlatLambdaCDM
|
|
20
|
-
|
|
21
18
|
exact = False
|
|
22
19
|
|
|
23
20
|
|
|
@@ -43,13 +40,8 @@ def N_vv_0_2_0(theta, phi):
|
|
|
43
40
|
return (9 / 2) * np.cos(2 * phi) + (3 / 2) * np.cos(theta)
|
|
44
41
|
|
|
45
42
|
|
|
46
|
-
def Z_vv_0(k, redshift_1, redshift_2):
|
|
47
|
-
return 1
|
|
48
|
-
|
|
49
|
-
|
|
50
43
|
dictionary_terms = {"vv": ["0"]}
|
|
51
44
|
dictionary_lmax = {"vv": [2]}
|
|
52
45
|
dictionary_subterms = {"vv_0_0": 1, "vv_0_1": 0, "vv_0_2": 1}
|
|
53
46
|
multi_index_model = False
|
|
54
|
-
redshift_dependent_model = True
|
|
55
47
|
regularize_M_terms = None
|
flip/covariance/contraction.py
CHANGED
|
@@ -2,7 +2,6 @@ import importlib
|
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
|
|
5
|
-
from flip.covariance import cov_utils
|
|
6
5
|
from flip.covariance import generator as generator_flip
|
|
7
6
|
from flip.utils import create_log
|
|
8
7
|
|
|
@@ -10,6 +9,13 @@ log = create_log()
|
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
class Contraction:
|
|
12
|
+
"""Container for contracted covariance components and coordinates.
|
|
13
|
+
|
|
14
|
+
Holds precomputed contraction tensors (per block gg/gv/vv) and the
|
|
15
|
+
corresponding coordinate grids. Provides utilities to build from flip
|
|
16
|
+
covariance generators and to evaluate weighted sums via model coefficients.
|
|
17
|
+
"""
|
|
18
|
+
|
|
13
19
|
def __init__(
|
|
14
20
|
self,
|
|
15
21
|
model_name=None,
|
|
@@ -17,15 +23,23 @@ class Contraction:
|
|
|
17
23
|
contraction_dict=None,
|
|
18
24
|
coordinates_dict=None,
|
|
19
25
|
basis_definition=None,
|
|
20
|
-
redshift_dict=None,
|
|
21
26
|
variant=None,
|
|
22
27
|
):
|
|
28
|
+
"""Initialize the contraction container.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
model_name (str|None): Covariance model package name.
|
|
32
|
+
model_kind (str|None): `"density"`, `"velocity"`, `"full"`, or `"density_velocity"`.
|
|
33
|
+
contraction_dict (dict|None): Arrays per block (e.g., `{"gg": [..], "vv": [..]}`).
|
|
34
|
+
coordinates_dict (dict|None): Coordinates like `r_perpendicular`, `r_parallel`, etc.
|
|
35
|
+
basis_definition (str|None): Basis choice, e.g., `"bisector"`, `"mean"`, `"endpoint"`.
|
|
36
|
+
variant (str|None): Optional model variant.
|
|
37
|
+
"""
|
|
23
38
|
self.model_name = model_name
|
|
24
39
|
self.model_kind = model_kind
|
|
25
40
|
self.contraction_dict = contraction_dict
|
|
26
41
|
self.coordinates_dict = coordinates_dict
|
|
27
42
|
self.basis_definition = basis_definition
|
|
28
|
-
self.redshift_dict = redshift_dict
|
|
29
43
|
self.variant = variant
|
|
30
44
|
|
|
31
45
|
@classmethod
|
|
@@ -45,10 +59,29 @@ class Contraction:
|
|
|
45
59
|
variant=None,
|
|
46
60
|
**kwargs,
|
|
47
61
|
):
|
|
62
|
+
"""Build a `Contraction` from flip covariance generator outputs.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
model_name (str): Covariance model name under `flip.covariance`.
|
|
66
|
+
model_kind (str): `"density"`, `"velocity"`, `"full"`, or `"density_velocity"`.
|
|
67
|
+
power_spectrum_dict (dict): Power spectra per block: keys `gg`, `vv`, and optional `gv`.
|
|
68
|
+
coord_1 (ndarray): First coordinate grid (e.g., `r_perp` or `r`).
|
|
69
|
+
coord_2 (ndarray): Second coordinate grid (e.g., `r_par` or `mu`).
|
|
70
|
+
coord_1_reference (float): Reference point first coordinate.
|
|
71
|
+
coord_2_reference (float): Reference point second coordinate.
|
|
72
|
+
coordinate_type (str): `"rprt"` or `"rmu"`.
|
|
73
|
+
additional_parameters_values (dict|None): Extra model parameters.
|
|
74
|
+
basis_definition (str): Basis choice for angular definitions.
|
|
75
|
+
redshift (float|None): Optional redshift context.
|
|
76
|
+
variant (str|None): Model variant.
|
|
77
|
+
**kwargs: Options forwarded to generator.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
Contraction: Initialized instance with tensors and coordinates.
|
|
81
|
+
"""
|
|
48
82
|
(
|
|
49
83
|
contraction_dict,
|
|
50
84
|
coordinates_dict,
|
|
51
|
-
redshift_dict,
|
|
52
85
|
) = contract_covariance(
|
|
53
86
|
model_name,
|
|
54
87
|
model_kind,
|
|
@@ -70,25 +103,15 @@ class Contraction:
|
|
|
70
103
|
contraction_dict=contraction_dict,
|
|
71
104
|
coordinates_dict=coordinates_dict,
|
|
72
105
|
basis_definition=basis_definition,
|
|
73
|
-
redshift_dict=redshift_dict,
|
|
74
106
|
variant=variant,
|
|
75
107
|
)
|
|
76
108
|
|
|
77
109
|
@property
|
|
78
110
|
def type(self):
|
|
79
|
-
"""
|
|
80
|
-
The type function is used to determine the type of covariance model that will be computed.
|
|
81
|
-
The options are:
|
|
82
|
-
- velocity: The covariance model is computed for velocity only.
|
|
83
|
-
- density: The covariance model is computed for density only.
|
|
84
|
-
- density_velocity: The covariance model is computed for both velocity and density, without cross-term (i.e., the covariances between velocities and densities are zero). This option should be used when computing a full 3D tomography in which we want to compute a separate 1D tomography along each axis (x, y, z
|
|
85
|
-
|
|
86
|
-
Args:
|
|
87
|
-
self: Represent the instance of the class
|
|
111
|
+
"""Return the model kind and log a short description.
|
|
88
112
|
|
|
89
113
|
Returns:
|
|
90
|
-
|
|
91
|
-
|
|
114
|
+
str: `model_kind` as provided on initialization.
|
|
92
115
|
"""
|
|
93
116
|
if self.model_kind == "velocity":
|
|
94
117
|
log.add("The covariance model is computed for velocity")
|
|
@@ -108,27 +131,22 @@ class Contraction:
|
|
|
108
131
|
self,
|
|
109
132
|
parameter_values_dict,
|
|
110
133
|
):
|
|
111
|
-
"""
|
|
112
|
-
The compute_contraction_sum function computes the sum of all the contractions
|
|
113
|
-
for a given model type and parameter values.
|
|
134
|
+
"""Compute weighted sum of contraction tensors using model coefficients.
|
|
114
135
|
|
|
115
136
|
Args:
|
|
116
|
-
|
|
117
|
-
parameter_values_dict: Get the coefficients for each of the covariances
|
|
118
|
-
: Get the coefficients of the model
|
|
137
|
+
parameter_values_dict (dict): Parameters to obtain coefficients.
|
|
119
138
|
|
|
120
139
|
Returns:
|
|
121
|
-
|
|
140
|
+
dict: Sum per block, e.g., `{"gg": array, "vv": array, "gv": array}`.
|
|
122
141
|
"""
|
|
123
142
|
coefficients = importlib.import_module(
|
|
124
|
-
f"flip.covariance.{self.model_name}.coefficients"
|
|
143
|
+
f"flip.covariance.analytical.{self.model_name}.coefficients"
|
|
125
144
|
)
|
|
126
145
|
|
|
127
146
|
coefficients_dict = coefficients.get_coefficients(
|
|
128
147
|
parameter_values_dict,
|
|
129
148
|
self.model_kind,
|
|
130
149
|
variant=self.variant,
|
|
131
|
-
redshift_dict=self.redshift_dict,
|
|
132
150
|
)
|
|
133
151
|
contraction_covariance_sum_dict = {}
|
|
134
152
|
if self.model_kind == "density":
|
|
@@ -174,7 +192,7 @@ class Contraction:
|
|
|
174
192
|
axis=0,
|
|
175
193
|
)
|
|
176
194
|
else:
|
|
177
|
-
log.add(
|
|
195
|
+
log.add("Wrong model type in the loaded covariance.")
|
|
178
196
|
|
|
179
197
|
return contraction_covariance_sum_dict
|
|
180
198
|
|
|
@@ -187,6 +205,23 @@ def compute_contraction_coordinates(
|
|
|
187
205
|
coordinate_type,
|
|
188
206
|
basis_definition,
|
|
189
207
|
):
|
|
208
|
+
"""Compute coordinate grids and derived angles for contractions.
|
|
209
|
+
|
|
210
|
+
Supports `rmu` and `rprt` input coordinate parameterizations and basis
|
|
211
|
+
definitions `bisector`, `mean`, and `endpoint`.
|
|
212
|
+
|
|
213
|
+
Args:
|
|
214
|
+
coord_1 (ndarray): First coordinate grid.
|
|
215
|
+
coord_2 (ndarray): Second coordinate grid.
|
|
216
|
+
coord_1_reference (float): Reference first coordinate.
|
|
217
|
+
coord_2_reference (float): Reference second coordinate.
|
|
218
|
+
coordinate_type (str): `"rmu"` or `"rprt"`.
|
|
219
|
+
basis_definition (str): `"bisector"`, `"mean"`, or `"endpoint"`.
|
|
220
|
+
|
|
221
|
+
Returns:
|
|
222
|
+
tuple: `(coordinates_dict, coordinates)` where `coordinates_dict` holds
|
|
223
|
+
2D grids and `coordinates` is a stacked array `[r, theta, phi]` per point.
|
|
224
|
+
"""
|
|
190
225
|
shape_coord_1_coord_2 = len(coord_1) * len(coord_2)
|
|
191
226
|
|
|
192
227
|
if coordinate_type == "rmu":
|
|
@@ -285,6 +320,26 @@ def contract_covariance(
|
|
|
285
320
|
number_worker=8,
|
|
286
321
|
hankel=True,
|
|
287
322
|
):
|
|
323
|
+
"""Generate contraction tensors for the specified model and blocks.
|
|
324
|
+
|
|
325
|
+
Args:
|
|
326
|
+
model_name (str): Covariance model name under `flip.covariance`.
|
|
327
|
+
model_kind (str): `"density"`, `"velocity"`, `"full"`, or `"density_velocity"`.
|
|
328
|
+
power_spectrum_dict (dict): Power spectra per block.
|
|
329
|
+
coord_1 (ndarray): First coordinate grid.
|
|
330
|
+
coord_2 (ndarray): Second coordinate grid.
|
|
331
|
+
coord_1_reference (float): Reference first coordinate.
|
|
332
|
+
coord_2_reference (float): Reference second coordinate.
|
|
333
|
+
coordinate_type (str): Input parameterization, `"rprt"` or `"rmu"`.
|
|
334
|
+
additional_parameters_values (dict|None): Extra model parameters.
|
|
335
|
+
basis_definition (str): Basis choice.
|
|
336
|
+
redshift (float|None): Optional redshift context.
|
|
337
|
+
number_worker (int): Parallel workers used by generator.
|
|
338
|
+
hankel (bool): Use FFTLog Hankel transform when True.
|
|
339
|
+
|
|
340
|
+
Returns:
|
|
341
|
+
tuple: `(contraction_dict, coordinates_dict)`.
|
|
342
|
+
"""
|
|
288
343
|
# r_perpendicular : coord_1, r_parallel : coord_2
|
|
289
344
|
coordinates_dict, coordinates = compute_contraction_coordinates(
|
|
290
345
|
coord_1,
|
|
@@ -295,19 +350,6 @@ def contract_covariance(
|
|
|
295
350
|
basis_definition,
|
|
296
351
|
)
|
|
297
352
|
|
|
298
|
-
redshift_dependent_model = generator_flip.get_redshift_dependent_model_flag(
|
|
299
|
-
model_name
|
|
300
|
-
)
|
|
301
|
-
if redshift_dependent_model:
|
|
302
|
-
redshift_dict = cov_utils.generate_redshift_dict(
|
|
303
|
-
model_name,
|
|
304
|
-
model_kind,
|
|
305
|
-
redshift_velocity=redshift,
|
|
306
|
-
redshift_density=redshift,
|
|
307
|
-
)
|
|
308
|
-
else:
|
|
309
|
-
redshift_dict = None
|
|
310
|
-
|
|
311
353
|
contraction_dict = {}
|
|
312
354
|
if model_kind in ["density", "full", "density_velocity"]:
|
|
313
355
|
contraction_dict["gg"] = generator_flip.compute_coeficient(
|
|
@@ -342,4 +384,4 @@ def contract_covariance(
|
|
|
342
384
|
hankel=hankel,
|
|
343
385
|
)[:, :].reshape(-1, len(coord_1), len(coord_2))
|
|
344
386
|
|
|
345
|
-
return contraction_dict, coordinates_dict
|
|
387
|
+
return contraction_dict, coordinates_dict
|