Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH(twopoint): compute binned spectra and mixing matrices #103

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions heracles/twopoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def angular_power_spectra(
alms2=None,
*,
lmax=None,
bins=None,
weights=None,
include=None,
exclude=None,
out=None,
Expand Down Expand Up @@ -129,6 +131,10 @@ def angular_power_spectra(
md[f"{key}_2"] = value
update_metadata(cl, **md)

# if bins are given, apply the binning
if bins is not None:
cl = bin2pt(cl, bins, "CL", weights=weights)

# add cl to the set
cls[k1, k2, i1, i2] = cl

Expand Down Expand Up @@ -203,6 +209,8 @@ def mixing_matrices(
l1max: int | None = None,
l2max: int | None = None,
l3max: int | None = None,
bins: ArrayLike | None = None,
weights: str | ArrayLike | None = None,
out: MutableMapping[TwoPointKey, ArrayLike] | None = None,
progress: bool = False,
) -> MutableMapping[TwoPointKey, ArrayLike]:
Expand Down Expand Up @@ -278,6 +286,8 @@ def mixing_matrices(
l3max=l3max,
spin=(spin1, spin2),
)
if bins is not None:
mm = bin2pt(mm, bins, "MM", weights=weights)
name1 = f1 if spin1 == 0 else f"{f1}_E"
name2 = f2 if spin2 == 0 else f"{f2}_E"
out[name1, name2, i1, i2] = mm
Expand All @@ -291,6 +301,10 @@ def mixing_matrices(
l3max=l3max,
spin=(spin1, spin2),
)
if bins is not None:
mm_ee = bin2pt(mm_ee, bins, "MM", weights=weights)
mm_bb = bin2pt(mm_bb, bins, "MM", weights=weights)
mm_eb = bin2pt(mm_eb, bins, "MM", weights=weights)
out[f"{f1}_E", f"{f2}_E", i1, i2] = mm_ee
out[f"{f1}_B", f"{f2}_B", i1, i2] = mm_bb
out[f"{f1}_E", f"{f2}_B", i1, i2] = mm_eb
Expand Down
Loading