Skip to content

Commit e62fdee

Browse files
committed
modify port2sacc
1 parent b636af6 commit e62fdee

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎pspipe_utils/io.py‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def port2sacc(
2222
metadata=None,
2323
sacc_file_name="data_sacc.fits",
2424
log=None,
25-
):
25+
binned_mcm = False
26+
):
2627
"""
2728
This function computes the chi2 value between data/sim spectra wrt theory spectra given
2829
the data covariance and a set of multipole cuts
@@ -51,6 +52,8 @@ def port2sacc(
5152
the sacc file name
5253
log: logger
5354
the logger to print message (default gets back to logging library with debug level)
55+
binned_mcm: boolean
56+
whether data are binned or not
5457
"""
5558

5659
passbands = passbands or {}
@@ -111,11 +114,20 @@ def port2sacc(
111114
# Add Bbl
112115
bp_window = None
113116
if bbls is not None:
114-
if (bbl := bbls.get(cross)) is None:
117+
if (bbl_s := bbls.get(cross)) is None:
115118
raise ValueError(f"Missing bbl for '{cross}' cross spectra!")
119+
if not binned_mcm:
120+
# if no binning, the bbl in the same for all spin combo
121+
bbl = bbl_s
122+
else:
123+
# reading the bbl for the correct spin combo
124+
spin = f"spin{tracer1[-1]}xspin{tracer2[-1]}"
125+
bbl = bbl_s[spin]
126+
116127
ls_w = np.arange(2, bbl.shape[-1] + 2)
117128
bp_window = sacc.BandpowerWindow(ls_w, bbl.T)
118129

130+
119131
log.debug(f"Adding '{cross}', {spec} spectrum as {data_type} {tracer1} {tracer2}")
120132

121133
kwargs = dict(

0 commit comments

Comments
 (0)