Skip to content

Tomographic rho-/tau-statistics#295

Merged
LisaGoh merged 13 commits into
feature/sp_validation-extend-to-tomographyfrom
feature/tomo-rho-tau
Jul 24, 2026
Merged

Tomographic rho-/tau-statistics#295
LisaGoh merged 13 commits into
feature/sp_validation-extend-to-tomographyfrom
feature/tomo-rho-tau

Conversation

@sachaguer

Copy link
Copy Markdown
Contributor

This PR upgrades the existing script to compute rho-/tau-statistics to iterate over tomographic bins. Only the tau-statistics change with the bin (the sample of star remains fixed).

The format to call tomographic run is similar to the implementation for pseudo-cl #221. Plotting functions have been upgraded to handle it as well.

The code has run on the GLASS mock, see the plot below for a validation example. The PSF error parameters are consistent with zero at the 2sigma level across the bins.

image

@sachaguer sachaguer self-assigned this Jul 22, 2026
@sachaguer sachaguer added the enhancement New feature or request label Jul 22, 2026
@sachaguer sachaguer linked an issue Jul 22, 2026 that may be closed by this pull request
@sachaguer
sachaguer requested a review from Copilot July 22, 2026 12:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the rho-/tau-statistics workflow to support tomographic bin iteration (tau varies with bin while the star sample remains fixed), and updates plotting/utilities to handle tomographic outputs consistently within the cosmo_val pipeline.

Changes:

  • Add tomographic looping + masking support for tau-statistics computation and plotting in PSFSystematicsMixin.
  • Refactor rho/tau computation helpers to distinguish base_rho vs base_tau, add optional masking/force re-run, and extend covariance options.
  • Update shared basename format to encode tomography metadata, and adjust a pseudo-$C_\ell$ plotting detail.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/sp_validation/rho_tau.py Refactors rho/tau computation + covariance wrappers for tomographic use (base_rho vs base_tau) and adds masking/force-run hooks.
src/sp_validation/cosmo_val/psf_systematics.py Implements tomographic rho/tau computation, PSF-parameter sampling per bin, and tomographic tau plotting.
src/sp_validation/cosmo_val/pseudo_cl.py Tweaks plotting factor computation when jittering $\ell$ values.
src/sp_validation/cosmo_val/core.py Extends basename() to include tomography identifiers in cached output names.
cosmo_val/cat_config.yaml Updates GLASS mock PSF catalog path in configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 93 to 96
elif method == "jk":
return get_jackknife_cov(
config,
version,
treecorr_config,
outdir,
base,
npatch=npatch,
config, version, treecorr_config, outdir, base_rho, base_tau
)
def plot_tau_stats(self, plot_tau_m=False):
filenames = [f"tau_stats_{self.basename(ver)}.fits" for ver in self.versions]
# --- calculate functions ---
def calculate_rho_tau_stats(self, tomography=True):
Comment on lines +78 to +101
for ver in self.versions:
# Get the tomographic bins
if tomography:
tomo_bin_ids, tomo_bin_pairs = self._get_tomo_bins(ver)

if tomo_bin_ids is None or tomo_bin_pairs is None:
raise ValueError(
f"Version {ver} does not have tomography information."
)

else:
tomo_bin_ids, tomo_bin_pairs = ["all"], [("all", "all")]

for tomo_bin_id in tomo_bin_ids:
self.print_cyan(f"Computing for the tomographic bin: {tomo_bin_id}")
base_rho = self.basename(ver)
base_tau = self.basename(ver, tomo_bin_a=tomo_bin_id)

# Get the selection for galaxies
mask_gal = self._get_galaxy_mask(ver, tomo_bin_id)

# Get the selection for stars
mask_star = self._get_star_mask(ver)

Comment thread src/sp_validation/rho_tau.py Outdated
Comment on lines +147 to +148
base : str
Base name for output files.
Comment on lines +496 to 500
tomo_bin_a_str = f"tomo_bin_{tomo_bin_a}"
tomo_bin_b_str = f"_tomo_bin_{tomo_bin_b}" if tomo_bin_b is not None else ""
return (
f"{version}_minsep={cfg['min_sep']}"
f"{version}_{tomo_bin_a_str}{tomo_bin_b_str}_minsep={cfg['min_sep']}"
f"_maxsep={cfg['max_sep']}"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will have to be checked whether new outputs are read differently or if the call to open the file relies on the basename function as well.

Comment thread cosmo_val/cat_config.yaml
@sachaguer

Copy link
Copy Markdown
Contributor Author

I updated the plotting script. In particular, I wrote a wrapper to plot any 2PCF like tomographic plot that requires to be fed a function to plot the actual thing on the axes. This seems quite flexible to me and could be used outside of the pipeline to produce plots from any other output. Ultimately could be useful to plot the 2PCF data vectors (together with the leakage) (see #296 )

image image

@sachaguer

Copy link
Copy Markdown
Contributor Author

Updates also handle the non tomographic case with a call to the same function

image

@sachaguer
sachaguer requested review from LisaGoh and cailmdaley July 23, 2026 16:51
@sachaguer

sachaguer commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@cailmdaley @LisaGoh Ready for a review and probably relevant for #296

Also related to CosmoStat/shear_psf_leakage#35

@cailmdaley cailmdaley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The estimator plumbing (per-bin masks, basename, base_rho/base_tau split) reads internally consistent, and the GLASS validation is convincing. Two paths look broken where the new defaults meet the old accessors — both easy fixes — plus one dead switch.

One non-blocking aside: effective number density / survey area are now computed independently in shear_psf_leakage (for the tau theory covariance) and in sp_validation (for the OneCovariance config, #298). Nothing wrong here, but we opened CosmoStat/cs_util#81 to converge on one canonical implementation so the two covariances can't silently disagree on shape noise — opinions welcome there.

— Claude, on behalf of Cail

Comment thread src/sp_validation/cosmo_val/psf_systematics.py
Comment thread src/sp_validation/cosmo_val/psf_systematics.py
if method == "th":
nbin_ang, nbin_rad = 100, 200
nbin_ang, nbin_rad = kwargs.get("nbin_ang", 100), kwargs.get("nbin_rad", 200)
compute_minus = kwargs.get("compute_minus", True)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: compute_minus is a named parameter, so it never lands in **kwargs — this kwargs.get("compute_minus", True) always returns True and passing False is silently ignored. Just use the argument directly.

@sachaguer

sachaguer commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Bugs identified are fixed in the last commit.

Agreed for the homogeneisation of the number density, area, and shape noise computations. Should we keep it for a future PR as the branches for tho-/tau- and OneCovariance are modified indendently right now?

Also, I left the scale dependant leakage and the objectwise leakage aside for now but this could be part of this PR if I find some time to do it.

@cailmdaley

Copy link
Copy Markdown
Collaborator

Let's leave the survey statistics unification for a future PR! Up to you on the leakage

@LisaGoh

LisaGoh commented Jul 24, 2026

Copy link
Copy Markdown
Member

Thank you for this, looks good to me too! As I was suggesting in #296 perhaps after merging this we can move the plot_2pcf_tomography function to real_space.py and all the real space plotting goes there, while the x_y_functions relavant to the psf systematics stay here

@LisaGoh
LisaGoh merged commit ee75f53 into feature/sp_validation-extend-to-tomography Jul 24, 2026
1 check passed
@LisaGoh
LisaGoh deleted the feature/tomo-rho-tau branch July 24, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tomographic rho-/tau-statistics

4 participants