Skip to content

Commit 508a652

Browse files
committed
make sure cls are included in data fits file
1 parent 0a937c7 commit 508a652

File tree

3 files changed

+131
-1
lines changed

3 files changed

+131
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,5 @@ cosmo_inference/cosmosis_config/*.ini
180180
!cosmo_inference/cosmosis_config/cosmosis_pipeline_A.ini
181181
!cosmo_inference/cosmosis_config/cosmosis_pipeline_glass_mock_00001_cell.ini
182182
!cosmo_inference/cosmosis_config/cosmosis_pipeline_glass_mock_00001.ini
183-
!cosmo_inference/cosmosis_config/cosmosis_pipeline_SP_v1.4.6_A_minsep=1.0_maxsep=250.0_nbins=20_npatch=1.ini
183+
!cosmo_inference/cosmosis_config/cosmosis_pipeline_SP_v1.4.6_A_minsep=1.0_maxsep=250.0_nbins=20_npatch=1.ini
184+
!cosmo_inference/cosmosis_config/cosmosis_pipeline_SP_v1.4.6_A_minsep=1.0_maxsep=250.0_nbins=20_npatch=1_cell.ini
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#parameters used elsewhere in this file
2+
[DEFAULT]
3+
SCRATCH = /n09data/guerrini/output_chains/SP_v1.4.6_A_minsep=1.0_maxsep=250.0_nbins=20_npatch=1
4+
FITS_FILE = data/SP_v1.4.6_A_minsep=1.0_maxsep=250.0_nbins=20_npatch=1/cosmosis_SP_v1.4.6_A_minsep=1.0_maxsep=250.0_nbins=20_npatch=1.fits
5+
COSMOSIS_DIR = /home/guerrini/cosmosis-standard-library
6+
7+
8+
[pipeline]
9+
values = cosmosis_config/values_psf.ini
10+
priors = cosmosis_config/priors_psf.ini
11+
modules = consistency sample_S8 camb load_nz_fits photoz_bias linear_alignment projection add_intrinsic shear_m_bias 2pt_like
12+
likelihoods = 2pt_like
13+
extra_output = cosmological_parameters/omega_lambda cosmological_parameters/S_8 cosmological_parameters/sigma_8 cosmological_parameters/omega_m
14+
timing = T
15+
debug = T
16+
17+
[runtime]
18+
sampler = polychord
19+
verbosity = debug
20+
21+
[test]
22+
save_dir = %(SCRATCH)s/best_fit/SP_v1.4.6_A_minsep=1.0_maxsep=250.0_nbins=20_npatch=1_cell
23+
24+
25+
[polychord]
26+
polychord_outfile_root = SP_v1.4.6_A_minsep=1.0_maxsep=250.0_nbins=20_npatch=1_cell
27+
live_points = 192
28+
feedback = 3
29+
resume = T
30+
base_dir = %(SCRATCH)s/polychord
31+
32+
[output]
33+
filename = %(SCRATCH)s/SP_v1.4.6_A_minsep=1.0_maxsep=250.0_nbins=20_npatch=1/samples_SP_v1.4.6_A_minsep=1.0_maxsep=250.0_nbins=20_npatch=1_cell.txt
34+
format = text
35+
lock = F
36+
37+
[consistency]
38+
file = %(COSMOSIS_DIR)s/utility/consistency/consistency_interface.py
39+
verbose = F
40+
41+
[sample_S8]
42+
file = %(COSMOSIS_DIR)s/utility/sample_sigma8/sample_S8.py
43+
44+
[camb]
45+
file = %(COSMOSIS_DIR)s/boltzmann/camb/camb_interface.py
46+
mode=power
47+
lmax=2508
48+
feedback=0
49+
do_reionization=F
50+
kmin=1e-5
51+
kmax=20.0
52+
nk=200
53+
zmax=5.0
54+
zmax_background=5.0
55+
nz_background=500
56+
halofit_version=mead2020_feedback
57+
nonlinear=pk
58+
neutrino_hierarchy=normal
59+
kmax_extrapolate = 500.0
60+
61+
[load_nz_fits]
62+
file = %(COSMOSIS_DIR)s/number_density/load_nz_fits/load_nz_fits.py
63+
nz_file =%(FITS_FILE)s
64+
data_sets = SOURCE
65+
66+
[photoz_bias]
67+
file = %(COSMOSIS_DIR)s/number_density/photoz_bias/photoz_bias.py
68+
mode = additive
69+
sample = nz_source
70+
bias_section = nofz_shifts
71+
interpolation = cubic
72+
output_deltaz_section_name = delta_z_out
73+
74+
[linear_alignment]
75+
file = %(COSMOSIS_DIR)s/intrinsic_alignments/la_model/linear_alignments_interface_znla.py
76+
method = bk_corrected
77+
78+
[projection]
79+
file = %(COSMOSIS_DIR)s/structure/projection/project_2d.py
80+
ell_min_logspaced = 1.0
81+
ell_max_logspaced = 25000.0
82+
n_ell_logspaced = 400
83+
shear-shear = source-source
84+
shear-intrinsic = source-source
85+
intrinsic-intrinsic = source-source
86+
get_kernel_peaks = F
87+
verbose = F
88+
89+
[add_intrinsic]
90+
file = %(COSMOSIS_DIR)s/shear/add_intrinsic/add_intrinsic.py
91+
shear-shear=T
92+
position-shear=F
93+
perbin=F
94+
95+
[shear_m_bias]
96+
file = %(COSMOSIS_DIR)s/shear/shear_bias/shear_m_bias.py
97+
m_per_bin = True
98+
; Despite the parameter name, this can operate on xi as well as C_ell.
99+
cl_section = shear_cl
100+
verbose = F
101+
102+
[2pt_shear]
103+
file = %(COSMOSIS_DIR)s/shear/cl_to_xi_nicaea/nicaea_interface.so
104+
corr_type = 0 ; shear_cl -> shear_xi
105+
106+
[2pt_like]
107+
file = %(COSMOSIS_DIR)s/likelihood/2pt/2pt_like.py
108+
data_sets=CELL_EE CELL_BB
109+
data_file=%(FITS_FILE)s
110+
gaussian_covariance=F
111+
covmat_name=COVMAT
112+
cut_zeros=F
113+
like_name=2pt_like

cosmo_inference/scripts/cosmosis_fitting.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ def load_glass_cl(cl_file):
115115
return ell, cl_ee, cl_bb
116116

117117

118+
def load_pseudo_cl_fits(cl_file):
119+
"""
120+
Load pseudo-C_ell data stored in FITS format with columns (ELL, EE, EB, BB).
121+
"""
122+
with fits.open(cl_file) as hdul:
123+
data = hdul[1].data
124+
ell = np.asarray(data["ELL"], dtype=np.float64)
125+
cl_ee = np.asarray(data["EE"], dtype=np.float64)
126+
cl_bb = np.asarray(data["BB"], dtype=np.float64)
127+
return ell, cl_ee, cl_bb
128+
129+
118130
def glass_cl_to_fits(ell, cl_ee, cl_bb):
119131
"""Convert GLASS C_ell arrays to CosmoSIS FITS HDUs for EE and BB."""
120132
nbins = len(ell)
@@ -545,6 +557,10 @@ def parse_args():
545557
ell, cl_ee, cl_bb = load_glass_cl(args.cl_file)
546558
cl_ee_hdu, cl_bb_hdu = glass_cl_to_fits(ell, cl_ee, cl_bb)
547559
print(f"Loaded Cl: {len(ell)} multipoles")
560+
elif args.cl_file.endswith(".fits"):
561+
ell, cl_ee, cl_bb = load_pseudo_cl_fits(args.cl_file)
562+
cl_ee_hdu, cl_bb_hdu = glass_cl_to_fits(ell, cl_ee, cl_bb)
563+
print(f"Loaded Cl: {len(ell)} multipoles (FITS pseudo-Cl)")
548564
else:
549565
raise NotImplementedError(f"Cl format not supported: {args.cl_file}")
550566

0 commit comments

Comments
 (0)