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
|
@@ -14,6 +14,13 @@ def plot_1d_contraction(
|
|
|
14
14
|
parameter_dict,
|
|
15
15
|
rs_multiplied=True,
|
|
16
16
|
):
|
|
17
|
+
"""Plot 1D slices of contraction sums for gg/gv/vv blocks.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
contraction (object): Contraction object with `compute_contraction_sum` and `coordinates_dict`.
|
|
21
|
+
parameter_dict (dict): Parameter values for evaluation.
|
|
22
|
+
rs_multiplied (bool): Multiply gg by r^2 for visualization.
|
|
23
|
+
"""
|
|
17
24
|
contraction_sum = contraction.compute_contraction_sum(parameter_dict)
|
|
18
25
|
coord = contraction.coordinates_dict
|
|
19
26
|
|
|
@@ -87,6 +94,13 @@ def plot_2d_contraction(
|
|
|
87
94
|
parameter_dict,
|
|
88
95
|
rs_multiplied=True,
|
|
89
96
|
):
|
|
97
|
+
"""Plot 2D images of contraction sums for gg/gv/vv blocks.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
contraction (object): Contraction with `compute_contraction_sum` & `coordinates_dict`.
|
|
101
|
+
parameter_dict (dict): Parameter values for evaluation.
|
|
102
|
+
rs_multiplied (bool): Multiply gg by r^2 for visualization.
|
|
103
|
+
"""
|
|
90
104
|
contraction_sum = contraction.compute_contraction_sum(parameter_dict)
|
|
91
105
|
coord = contraction.coordinates_dict
|
|
92
106
|
|
|
@@ -155,8 +169,17 @@ def plot_2d_contraction(
|
|
|
155
169
|
def plot_correlation_from_likelihood(
|
|
156
170
|
likelihood,
|
|
157
171
|
parameter_dict,
|
|
172
|
+
covariance_prefactor_dict=None,
|
|
158
173
|
**kwargs,
|
|
159
174
|
):
|
|
175
|
+
"""Plot correlation matrix computed from a likelihood’s covariance.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
likelihood (BaseLikelihood): Likelihood instance providing data/covariance.
|
|
179
|
+
parameter_dict (dict): Parameter specs; values read to form vector and variance.
|
|
180
|
+
covariance_prefactor_dict (dict, optional): Prefactors per covariance block.
|
|
181
|
+
**kwargs: Plot options, e.g., `vmin`, `vmax`.
|
|
182
|
+
"""
|
|
160
183
|
vmin = utils.return_key(kwargs, "vmin", -0.1)
|
|
161
184
|
vmax = utils.return_key(kwargs, "vmax", 0.1)
|
|
162
185
|
|
|
@@ -166,11 +189,13 @@ def plot_correlation_from_likelihood(
|
|
|
166
189
|
]
|
|
167
190
|
parameter_values_dict = dict(zip(parameter_names, parameter_values))
|
|
168
191
|
|
|
169
|
-
_, vector_variance = likelihood.data(
|
|
192
|
+
_, vector_variance = likelihood.data.give_data_and_variance(
|
|
170
193
|
parameter_values_dict,
|
|
171
194
|
)
|
|
172
195
|
covariance_sum = likelihood.covariance.compute_covariance_sum(
|
|
173
|
-
parameter_values_dict,
|
|
196
|
+
parameter_values_dict,
|
|
197
|
+
vector_variance,
|
|
198
|
+
covariance_prefactor_dict=covariance_prefactor_dict,
|
|
174
199
|
)
|
|
175
200
|
|
|
176
201
|
correlation_sum = cov_utils.return_correlation_matrix(covariance_sum)
|
|
@@ -189,6 +214,22 @@ def plot_all_fits(
|
|
|
189
214
|
plot=True,
|
|
190
215
|
**kwargs,
|
|
191
216
|
):
|
|
217
|
+
"""Scatter all fit results per parameter with errors.
|
|
218
|
+
|
|
219
|
+
Args:
|
|
220
|
+
fit_output (str): Directory containing pickled fit outputs.
|
|
221
|
+
parameters (list[str]): Parameters to plot.
|
|
222
|
+
fiducials (list[float]|None): Optional reference lines per parameter.
|
|
223
|
+
compute_fs8_from_beta (bool): Plot `fs8 = beta_f * bs8` when requested.
|
|
224
|
+
subset_plot (list[str]|None): Only include fit files whose names contain these substrings.
|
|
225
|
+
remove_lower (dict|None): Exclude fits where param < threshold.
|
|
226
|
+
remove_higher (dict|None): Exclude fits where param > threshold.
|
|
227
|
+
plot (bool): Whether to render the plots.
|
|
228
|
+
**kwargs: Matplotlib options, e.g., `figsize`.
|
|
229
|
+
|
|
230
|
+
Returns:
|
|
231
|
+
tuple: `(fit_name_to_plot, param_dict, error_dict)`.
|
|
232
|
+
"""
|
|
192
233
|
|
|
193
234
|
fit_to_plot, fit_name_to_plot = select_valid_fits(
|
|
194
235
|
fit_output,
|
|
@@ -258,6 +299,29 @@ def plot_all_mean_fits(
|
|
|
258
299
|
use_minos=False,
|
|
259
300
|
**kwargs,
|
|
260
301
|
):
|
|
302
|
+
"""Plot mean parameter values and errors across grouped fits.
|
|
303
|
+
|
|
304
|
+
Groups fits by a substring in filenames, computes mean and error metrics, and
|
|
305
|
+
optionally plots both means and errors.
|
|
306
|
+
|
|
307
|
+
Args:
|
|
308
|
+
fit_output (str): Directory containing pickled fit outputs.
|
|
309
|
+
parameters (list[str]): Parameters to summarize.
|
|
310
|
+
fiducials (list[float]|None): Reference lines per parameter.
|
|
311
|
+
weighted_mean (bool): Weight by inverse Hessian variance when True.
|
|
312
|
+
compute_fs8_from_beta (bool): Use `fs8 = beta_f * bs8`.
|
|
313
|
+
plot_std_error (bool): Plot standard deviation instead of mean error.
|
|
314
|
+
plot_error_bar_of_mean (bool): Plot error-of-the-mean instead of mean error.
|
|
315
|
+
subset_plot (list[str]|None): Only include fits matching substrings.
|
|
316
|
+
remove_lower (dict|None): Exclude fits where param < threshold.
|
|
317
|
+
remove_higher (dict|None): Exclude fits where param > threshold.
|
|
318
|
+
plot (bool): Whether to render plots.
|
|
319
|
+
use_minos (bool): Use MINOS errors if available; fall back to Hessian.
|
|
320
|
+
**kwargs: Matplotlib options, e.g., `figsize`.
|
|
321
|
+
|
|
322
|
+
Returns:
|
|
323
|
+
tuple: `(unique_fit_prop, mean_param_dict, mean_error_dict, error_mean_dict, std_dict, count_dict)`.
|
|
324
|
+
"""
|
|
261
325
|
|
|
262
326
|
fit_to_plot, fit_name_to_plot = select_valid_fits(
|
|
263
327
|
fit_output,
|
|
@@ -330,7 +394,7 @@ def plot_all_mean_fits(
|
|
|
330
394
|
error_bs8_high = fits[i][3][index_bs8].upper
|
|
331
395
|
error_betaf_low = fits[i][3][index_beta_f].lower
|
|
332
396
|
error_betaf_high = fits[i][3][index_beta_f].upper
|
|
333
|
-
except:
|
|
397
|
+
except IndexError:
|
|
334
398
|
print("Minos failed, taking hessian error")
|
|
335
399
|
errors = [
|
|
336
400
|
[
|
|
@@ -365,7 +429,7 @@ def plot_all_mean_fits(
|
|
|
365
429
|
index = np.argwhere(np.array(names) == param_name)[0][0]
|
|
366
430
|
errors[0].append(abs(fits[i][3][index].lower))
|
|
367
431
|
errors[1].append(abs(fits[i][3][index].upper))
|
|
368
|
-
except:
|
|
432
|
+
except IndexError:
|
|
369
433
|
errors[0].append(fits[i][2][param_name])
|
|
370
434
|
errors[1].append(fits[i][2][param_name])
|
|
371
435
|
else:
|
|
@@ -447,6 +511,17 @@ def select_valid_fits(
|
|
|
447
511
|
remove_lower=None,
|
|
448
512
|
remove_higher=None,
|
|
449
513
|
):
|
|
514
|
+
"""Select valid fit files based on status flags and filters.
|
|
515
|
+
|
|
516
|
+
Args:
|
|
517
|
+
fit_output (str): Directory of pickled fit outputs.
|
|
518
|
+
subset_plot (list[str]|None): Only include filenames containing these substrings.
|
|
519
|
+
remove_lower (dict|None): Exclude fits where param < threshold.
|
|
520
|
+
remove_higher (dict|None): Exclude fits where param > threshold.
|
|
521
|
+
|
|
522
|
+
Returns:
|
|
523
|
+
tuple[list, list]: Fit objects and their filenames.
|
|
524
|
+
"""
|
|
450
525
|
all_fit = glob.glob(os.path.join(fit_output, "*"))
|
|
451
526
|
|
|
452
527
|
fit_to_plot = []
|
flip/covariance/symbolic.py
CHANGED
|
@@ -65,7 +65,7 @@ def simplify_term(
|
|
|
65
65
|
|
|
66
66
|
def generate_MN_ab_i_l_function_wide_angle(
|
|
67
67
|
term_B,
|
|
68
|
-
|
|
68
|
+
ell,
|
|
69
69
|
l1,
|
|
70
70
|
l2,
|
|
71
71
|
):
|
|
@@ -90,10 +90,10 @@ def generate_MN_ab_i_l_function_wide_angle(
|
|
|
90
90
|
integral_mu1_M_l * legendre_poly(l2, x=mu2), (mu2, -1, 1)
|
|
91
91
|
)
|
|
92
92
|
term_N_l_l1_l2 = 0
|
|
93
|
-
for m in range(-
|
|
93
|
+
for m in range(-ell, ell + 1):
|
|
94
94
|
for m1 in range(-l1, l1 + 1):
|
|
95
95
|
for m2 in range(-l2, l2 + 1):
|
|
96
|
-
term_N_l_l1_l2_m_m1_m2 = wigner.gaunt(
|
|
96
|
+
term_N_l_l1_l2_m_m1_m2 = wigner.gaunt(ell, l1, l2, m, m1, m2)
|
|
97
97
|
# The two comments are for the following line, they are the results of an intense
|
|
98
98
|
# head scratching and are quite important for all the modeling of flip.
|
|
99
99
|
|
|
@@ -107,7 +107,7 @@ def generate_MN_ab_i_l_function_wide_angle(
|
|
|
107
107
|
# For the order of term chosen, the sy.pi must be added here.
|
|
108
108
|
# If not, it will give wrong results for cross-terms (gv).
|
|
109
109
|
term_N_l_l1_l2_m_m1_m2 *= (
|
|
110
|
-
sy.Ynm(
|
|
110
|
+
sy.Ynm(ell, m, sy.pi - phi, 0)
|
|
111
111
|
* sy.Ynm(l1, m1, theta / 2, 0)
|
|
112
112
|
* sy.Ynm(l2, m2, theta / 2, sy.pi)
|
|
113
113
|
)
|
|
@@ -126,7 +126,7 @@ def generate_MN_ab_i_l_function_wide_angle(
|
|
|
126
126
|
return term_M_l_l1_l2, term_N_l_l1_l2
|
|
127
127
|
|
|
128
128
|
|
|
129
|
-
def generate_MN_ab_i_l_function_parallel_plane(term_B,
|
|
129
|
+
def generate_MN_ab_i_l_function_parallel_plane(term_B, ell):
|
|
130
130
|
"""
|
|
131
131
|
The generate_MN_ab_i_l_function_parallel_plane function takes in a term_B and an l value.
|
|
132
132
|
It then generates the M_l and N_l functions for that particular term B, which is used to calculate the parallel plane integral.
|
|
@@ -143,12 +143,12 @@ def generate_MN_ab_i_l_function_parallel_plane(term_B, l):
|
|
|
143
143
|
phi = sy.symbols("phi")
|
|
144
144
|
mu = sy.symbols("mu")
|
|
145
145
|
M_l = sy.Rational(1 / 2) * sy.integrate(
|
|
146
|
-
term_B * legendre_poly(
|
|
146
|
+
term_B * legendre_poly(ell, x=mu), (mu, -1, 1)
|
|
147
147
|
)
|
|
148
148
|
# The sy.pi term is directly linked to the definition of r chosen in flip.
|
|
149
149
|
# For the order of term chosen, the sy.pi must be added here.
|
|
150
150
|
# If not, it will give wrong results for cross-terms (gv).
|
|
151
|
-
N_l = sy.Rational(2 *
|
|
151
|
+
N_l = sy.Rational(2 * ell + 1) * legendre_poly(ell, x=sy.cos(sy.pi - phi))
|
|
152
152
|
M_l = simplify_term(
|
|
153
153
|
M_l.expand(func=True),
|
|
154
154
|
simplification_method="simplify_iteration",
|
|
@@ -172,7 +172,6 @@ def write_output(
|
|
|
172
172
|
l1max_list=None,
|
|
173
173
|
l2max_list=None,
|
|
174
174
|
multi_index_model=False,
|
|
175
|
-
redshift_dependent_model=False,
|
|
176
175
|
regularize_M_terms="None",
|
|
177
176
|
):
|
|
178
177
|
"""
|
|
@@ -224,26 +223,26 @@ def write_output(
|
|
|
224
223
|
dict_terms[f"{type}"] = term_index_list[k]
|
|
225
224
|
dict_lmax[f"{type}"] = lmax_list[k]
|
|
226
225
|
for i, t in enumerate(term_index_list[k]):
|
|
227
|
-
for
|
|
226
|
+
for ell in range(lmax_list[k][i] + 1):
|
|
228
227
|
list_M_ab_i_l = []
|
|
229
228
|
list_N_ab_i_l = []
|
|
230
229
|
if wide_angle:
|
|
231
230
|
for l1 in range(l1max_list[k][i] + 1):
|
|
232
231
|
for l2 in range(l2max_list[k][i] + 1):
|
|
233
232
|
M_ab_i_l_l1_l2, N_ab_i_l_l1_l2 = output_pool[
|
|
234
|
-
index_pool[f"{type}_{t}_{
|
|
233
|
+
index_pool[f"{type}_{t}_{ell}_{l1}_{l2}"]
|
|
235
234
|
]
|
|
236
235
|
if (M_ab_i_l_l1_l2 != 0) & (N_ab_i_l_l1_l2 != 0):
|
|
237
236
|
list_M_ab_i_l.append(M_ab_i_l_l1_l2)
|
|
238
237
|
list_N_ab_i_l.append(N_ab_i_l_l1_l2)
|
|
239
238
|
else:
|
|
240
239
|
M_ab_i_l_l1_l2, N_ab_i_l_l1_l2 = output_pool[
|
|
241
|
-
index_pool[f"{type}_{t}_{
|
|
240
|
+
index_pool[f"{type}_{t}_{ell}"]
|
|
242
241
|
]
|
|
243
242
|
if (M_ab_i_l_l1_l2 != 0) & (N_ab_i_l_l1_l2 != 0):
|
|
244
243
|
list_M_ab_i_l.append(M_ab_i_l_l1_l2)
|
|
245
244
|
list_N_ab_i_l.append(N_ab_i_l_l1_l2)
|
|
246
|
-
dict_j[f"{type}_{t}_{
|
|
245
|
+
dict_j[f"{type}_{t}_{ell}"] = len(list_M_ab_i_l)
|
|
247
246
|
for j in range(len(list_M_ab_i_l)):
|
|
248
247
|
M_ab_i_l_j = (
|
|
249
248
|
pycode(list_M_ab_i_l[j])
|
|
@@ -261,13 +260,13 @@ def write_output(
|
|
|
261
260
|
for add in additional_parameters:
|
|
262
261
|
additional_str = additional_str + f"{add},"
|
|
263
262
|
additional_str = additional_str[:-1]
|
|
264
|
-
f.write(f"def M_{type}_{t}_{
|
|
265
|
-
f.write(
|
|
266
|
-
f.write(f" return
|
|
267
|
-
f.write(
|
|
263
|
+
f.write(f"def M_{type}_{t}_{ell}_{j}({additional_str}):\n")
|
|
264
|
+
f.write(" def func(k):\n")
|
|
265
|
+
f.write(f" return {M_ab_i_l_j}\n")
|
|
266
|
+
f.write(" return func\n")
|
|
268
267
|
f.write("\n")
|
|
269
268
|
|
|
270
|
-
f.write(f"def N_{type}_{t}_{
|
|
269
|
+
f.write(f"def N_{type}_{t}_{ell}_{j}(theta,phi):\n")
|
|
271
270
|
f.write(f" return({N_ab_i_l_j})\n")
|
|
272
271
|
f.write("\n")
|
|
273
272
|
|
|
@@ -286,8 +285,6 @@ def write_output(
|
|
|
286
285
|
f.write(f"multi_index_model = {multi_index_model}")
|
|
287
286
|
f.write("\n")
|
|
288
287
|
|
|
289
|
-
f.write(f"redshift_dependent_model = {redshift_dependent_model}")
|
|
290
|
-
f.write("\n")
|
|
291
288
|
f.write(f"regularize_M_terms = {regularize_M_terms}")
|
|
292
289
|
f.write("\n")
|
|
293
290
|
f.close()
|
|
@@ -305,7 +302,6 @@ def write_M_N_functions(
|
|
|
305
302
|
l1max_list=None,
|
|
306
303
|
l2max_list=None,
|
|
307
304
|
multi_index_model=False,
|
|
308
|
-
redshift_dependent_model=False,
|
|
309
305
|
regularize_M_terms="None",
|
|
310
306
|
):
|
|
311
307
|
"""
|
|
@@ -336,17 +332,17 @@ def write_M_N_functions(
|
|
|
336
332
|
index = 0
|
|
337
333
|
for k, type in enumerate(type_list):
|
|
338
334
|
for i, t in enumerate(term_index_list[k]):
|
|
339
|
-
for
|
|
335
|
+
for ell in range(lmax_list[k][i] + 1):
|
|
340
336
|
B_ab_i = dict_B[f"B_{type}_{t}"]
|
|
341
337
|
if wide_angle:
|
|
342
338
|
for l1 in range(l1max_list[k][i] + 1):
|
|
343
339
|
for l2 in range(l2max_list[k][i] + 1):
|
|
344
|
-
params_pool.append([B_ab_i,
|
|
345
|
-
index_pool[f"{type}_{t}_{
|
|
340
|
+
params_pool.append([B_ab_i, ell, l1, l2])
|
|
341
|
+
index_pool[f"{type}_{t}_{ell}_{l1}_{l2}"] = index
|
|
346
342
|
index = index + 1
|
|
347
343
|
else:
|
|
348
|
-
params_pool.append([B_ab_i,
|
|
349
|
-
index_pool[f"{type}_{t}_{
|
|
344
|
+
params_pool.append([B_ab_i, ell])
|
|
345
|
+
index_pool[f"{type}_{t}_{ell}"] = index
|
|
350
346
|
index = index + 1
|
|
351
347
|
|
|
352
348
|
if number_worker == 1:
|
|
@@ -383,13 +379,58 @@ def write_M_N_functions(
|
|
|
383
379
|
l1max_list=l1max_list,
|
|
384
380
|
l2max_list=l2max_list,
|
|
385
381
|
multi_index_model=multi_index_model,
|
|
386
|
-
redshift_dependent_model=redshift_dependent_model,
|
|
387
382
|
regularize_M_terms=regularize_M_terms,
|
|
388
383
|
)
|
|
389
384
|
|
|
390
385
|
|
|
386
|
+
def generate_generalized_genericzdep_functions(
|
|
387
|
+
filename="./analytical/genericzdep/flip_terms.py", number_worker=8
|
|
388
|
+
):
|
|
389
|
+
"""
|
|
390
|
+
The generate_generalized_genericzdep_functions function generates the flip_terms.py file in the genericzdep directory, which contains functions that calculate M and N terms for a generalized version of Carreres' (2012) model 2 and 3.
|
|
391
|
+
|
|
392
|
+
Args:
|
|
393
|
+
filename: Specify the name of the file that will be generated
|
|
394
|
+
number_worker: Determine the number of processes to use for multiprocessing
|
|
395
|
+
|
|
396
|
+
Returns:
|
|
397
|
+
A list of functions,
|
|
398
|
+
|
|
399
|
+
"""
|
|
400
|
+
mu1, mu2 = sy.symbols("mu1 mu2")
|
|
401
|
+
k = sy.symbols("k", positive=True, finite=True, real=True)
|
|
402
|
+
kNL = sy.symbols("kNL", positive=True, finite=True, real=True)
|
|
403
|
+
additional_parameters = ["kNL"]
|
|
404
|
+
|
|
405
|
+
type_list = ["vv"]
|
|
406
|
+
term_index_list = [["0", "1", "2"]]
|
|
407
|
+
lmax_list = [[2, 2, 2]]
|
|
408
|
+
l1max_list = [[1, 1, 1]]
|
|
409
|
+
l2max_list = [[1, 1, 1]]
|
|
410
|
+
dict_B = {
|
|
411
|
+
"B_vv_0": mu1 * mu2 / k**2,
|
|
412
|
+
"B_vv_1": mu1 * mu2 / kNL**2,
|
|
413
|
+
"B_vv_2": mu1 * mu2 * k**2 / kNL**4,
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
regularize_M_terms = "None"
|
|
417
|
+
write_M_N_functions(
|
|
418
|
+
filename,
|
|
419
|
+
type_list,
|
|
420
|
+
term_index_list,
|
|
421
|
+
lmax_list,
|
|
422
|
+
dict_B,
|
|
423
|
+
number_worker=number_worker,
|
|
424
|
+
wide_angle=True,
|
|
425
|
+
l1max_list=l1max_list,
|
|
426
|
+
l2max_list=l2max_list,
|
|
427
|
+
regularize_M_terms=regularize_M_terms,
|
|
428
|
+
additional_parameters=additional_parameters,
|
|
429
|
+
)
|
|
430
|
+
|
|
431
|
+
|
|
391
432
|
def generate_generalized_adamsblake17plane_functions(
|
|
392
|
-
filename="./adamsblake17plane/flip_terms.py", number_worker=8
|
|
433
|
+
filename="./analytical/adamsblake17plane/flip_terms.py", number_worker=8
|
|
393
434
|
):
|
|
394
435
|
mu = sy.symbols("mu")
|
|
395
436
|
k = sy.symbols("k", positive=True, finite=True, real=True)
|
|
@@ -416,7 +457,7 @@ def generate_generalized_adamsblake17plane_functions(
|
|
|
416
457
|
|
|
417
458
|
|
|
418
459
|
def generate_generalized_adamsblake17_functions(
|
|
419
|
-
filename="./adamsblake17/flip_terms.py", number_worker=8
|
|
460
|
+
filename="./analytical/adamsblake17/flip_terms.py", number_worker=8
|
|
420
461
|
):
|
|
421
462
|
|
|
422
463
|
mu1, mu2 = sy.symbols("mu1 mu2")
|
|
@@ -448,7 +489,7 @@ def generate_generalized_adamsblake17_functions(
|
|
|
448
489
|
|
|
449
490
|
|
|
450
491
|
def generate_generalized_adamsblake20_functions(
|
|
451
|
-
filename="./adamsblake20/flip_terms.py", number_worker=8
|
|
492
|
+
filename="./analytical/adamsblake20/flip_terms.py", number_worker=8
|
|
452
493
|
):
|
|
453
494
|
"""
|
|
454
495
|
The generate_generalized_adamsblake20_functions function generates the functions needed to compute the M and N matrices for a generalized version of Adams, Blake & Kitching (2020).
|
|
@@ -492,7 +533,7 @@ def generate_generalized_adamsblake20_functions(
|
|
|
492
533
|
|
|
493
534
|
|
|
494
535
|
def generate_generalized_lai22_functions(
|
|
495
|
-
filename="./lai22/flip_terms.py", number_worker=8
|
|
536
|
+
filename="./analytical/lai22/flip_terms.py", number_worker=8
|
|
496
537
|
):
|
|
497
538
|
"""
|
|
498
539
|
The generate_generalized_lai22_functions function generates the functions for calculating the M and N terms in
|
|
@@ -625,7 +666,7 @@ def generate_generalized_lai22_functions(
|
|
|
625
666
|
|
|
626
667
|
|
|
627
668
|
def generate_generalized_carreres23_functions(
|
|
628
|
-
filename="./carreres23/flip_terms.py", number_worker=8
|
|
669
|
+
filename="./analytical/carreres23/flip_terms.py", number_worker=8
|
|
629
670
|
):
|
|
630
671
|
"""
|
|
631
672
|
The generate_generalized_carreres23_functions function generates the flip_terms.py file in the carreres23 directory, which contains functions that calculate M and N terms for a generalized version of Carreres' (2012) model 2 and 3.
|
|
@@ -663,7 +704,7 @@ def generate_generalized_carreres23_functions(
|
|
|
663
704
|
|
|
664
705
|
|
|
665
706
|
def generate_generalized_ravouxcarreres_functions(
|
|
666
|
-
filename="./ravouxcarreres/flip_terms.py", number_worker=8
|
|
707
|
+
filename="./analytical/ravouxcarreres/flip_terms.py", number_worker=8
|
|
667
708
|
):
|
|
668
709
|
"""
|
|
669
710
|
The generate_generalized_ravouxcarreres_functions function generates the functions needed to compute the generalized Ravoux-Carreres model.
|
|
@@ -715,7 +756,7 @@ def generate_generalized_ravouxcarreres_functions(
|
|
|
715
756
|
|
|
716
757
|
|
|
717
758
|
def generate_generalized_rcrk24_functions(
|
|
718
|
-
filename="./rcrk24/flip_terms.py", number_worker=8
|
|
759
|
+
filename="./analytical/rcrk24/flip_terms.py", number_worker=8
|
|
719
760
|
):
|
|
720
761
|
"""
|
|
721
762
|
The generate_generalized_rcrk24_functions function generates the flip_terms.py file in the carreres23 directory, which contains functions that calculate M and N terms for a generalized version of Carreres' (2012) model 2 and 3.
|
|
@@ -748,7 +789,6 @@ def generate_generalized_rcrk24_functions(
|
|
|
748
789
|
wide_angle=True,
|
|
749
790
|
l1max_list=l1max_list,
|
|
750
791
|
l2max_list=l2max_list,
|
|
751
|
-
redshift_dependent_model=True,
|
|
752
792
|
regularize_M_terms=regularize_M_terms,
|
|
753
793
|
)
|
|
754
794
|
|
|
@@ -829,7 +869,7 @@ def write_partial_derivatives(
|
|
|
829
869
|
)
|
|
830
870
|
|
|
831
871
|
f.write(
|
|
832
|
-
"def get_partial_derivative_coefficients(model_kind,parameter_values_dict,variant=None,
|
|
872
|
+
"def get_partial_derivative_coefficients(model_kind,parameter_values_dict,variant=None,covariance_prefactor_dict=None,):\n"
|
|
833
873
|
)
|
|
834
874
|
write_one_function(
|
|
835
875
|
f,
|
|
@@ -840,7 +880,7 @@ def write_partial_derivatives(
|
|
|
840
880
|
)
|
|
841
881
|
else:
|
|
842
882
|
f.write(
|
|
843
|
-
"def get_partial_derivative_coefficients(model_kind,parameter_values_dict,variant=None,):\n"
|
|
883
|
+
"def get_partial_derivative_coefficients(model_kind,parameter_values_dict,variant=None,covariance_prefactor_dict=None,):\n"
|
|
844
884
|
)
|
|
845
885
|
f.write(" if model_kind == 'density':\n")
|
|
846
886
|
f.write(
|
|
@@ -914,7 +954,7 @@ def write_one_function(
|
|
|
914
954
|
else:
|
|
915
955
|
for i_model, name in enumerate(name_models):
|
|
916
956
|
if name is None:
|
|
917
|
-
f.write(
|
|
957
|
+
f.write(" else:\n")
|
|
918
958
|
elif i_model > 0:
|
|
919
959
|
f.write(f" elif variant == '{name}':\n")
|
|
920
960
|
else:
|
|
@@ -939,7 +979,7 @@ def write_one_function(
|
|
|
939
979
|
|
|
940
980
|
|
|
941
981
|
def generate_fisher_coefficients_dictionnary_carreres23(
|
|
942
|
-
filename="./carreres23/fisher_terms.py",
|
|
982
|
+
filename="./analytical/carreres23/fisher_terms.py",
|
|
943
983
|
):
|
|
944
984
|
|
|
945
985
|
name_models = ["growth_index", None]
|
|
@@ -959,7 +999,7 @@ def generate_fisher_coefficients_dictionnary_carreres23(
|
|
|
959
999
|
|
|
960
1000
|
|
|
961
1001
|
def generate_fisher_coefficients_dictionnary_adamsblake17(
|
|
962
|
-
filename="./adamsblake17/fisher_terms.py",
|
|
1002
|
+
filename="./analytical/adamsblake17/fisher_terms.py",
|
|
963
1003
|
):
|
|
964
1004
|
|
|
965
1005
|
name_models = ["growth_index", None]
|
|
@@ -993,7 +1033,7 @@ def generate_fisher_coefficients_dictionnary_adamsblake17(
|
|
|
993
1033
|
|
|
994
1034
|
|
|
995
1035
|
def generate_fisher_coefficients_dictionnary_adamsblake17plane(
|
|
996
|
-
filename="./adamsblake17plane/fisher_terms.py",
|
|
1036
|
+
filename="./analytical/adamsblake17plane/fisher_terms.py",
|
|
997
1037
|
):
|
|
998
1038
|
|
|
999
1039
|
name_models = ["growth_index", None]
|
|
@@ -1073,9 +1113,9 @@ def generate_fisher_coefficients_dictionnary_full_nosigmag(
|
|
|
1073
1113
|
|
|
1074
1114
|
|
|
1075
1115
|
def generate_fisher_coefficients_dictionnary_lai22(
|
|
1076
|
-
filename="./lai22/fisher_terms.py",
|
|
1116
|
+
filename="./analytical/lai22/fisher_terms.py",
|
|
1077
1117
|
):
|
|
1078
|
-
from flip.covariance.lai22.flip_terms import dictionary_terms
|
|
1118
|
+
from flip.covariance.analytical.lai22.flip_terms import dictionary_terms
|
|
1079
1119
|
|
|
1080
1120
|
name_models = ["growth_index", "growth_index_nobeta", "nobeta", None]
|
|
1081
1121
|
components = ["gg", "gv", "vv"]
|
|
@@ -1262,13 +1302,18 @@ def generate_files():
|
|
|
1262
1302
|
|
|
1263
1303
|
|
|
1264
1304
|
def generate_fisher_files():
|
|
1305
|
+
"""Generate Fisher coefficient modules across supported covariance models.
|
|
1306
|
+
|
|
1307
|
+
Writes `fisher_terms.py` files for each model with partial derivative
|
|
1308
|
+
coefficient dictionaries tailored to their parameterizations.
|
|
1309
|
+
"""
|
|
1265
1310
|
generate_fisher_coefficients_dictionnary_carreres23()
|
|
1266
1311
|
generate_fisher_coefficients_dictionnary_adamsblake17()
|
|
1267
1312
|
generate_fisher_coefficients_dictionnary_adamsblake17plane()
|
|
1268
1313
|
generate_fisher_coefficients_dictionnary_full_nosigmag(
|
|
1269
|
-
"./adamsblake20/fisher_terms.py"
|
|
1314
|
+
"./analytical/adamsblake20/fisher_terms.py"
|
|
1270
1315
|
)
|
|
1271
1316
|
generate_fisher_coefficients_dictionnary_full_nosigmag(
|
|
1272
|
-
"./ravouxcarreres/fisher_terms.py"
|
|
1317
|
+
"./analytical/ravouxcarreres/fisher_terms.py"
|
|
1273
1318
|
)
|
|
1274
1319
|
generate_fisher_coefficients_dictionnary_lai22()
|
flip/data/__init__.py
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|