Tomographic rho-/tau-statistics#295
Conversation
…ranch for rho-tau-statistics
…ranch for rho-tau-statistics
… the code running and GLASS mocks. Upgrade the sampling of error parameters.
There was a problem hiding this comment.
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_rhovsbase_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 |
| 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.
| 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): |
| 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) | ||
|
|
| base : str | ||
| Base name for output files. |
| 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']}" |
There was a problem hiding this comment.
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.
|
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 )
|
|
@cailmdaley @LisaGoh Ready for a review and probably relevant for #296 Also related to CosmoStat/shear_psf_leakage#35 |
cailmdaley
left a comment
There was a problem hiding this comment.
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
| 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) |
There was a problem hiding this comment.
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.
|
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. |
|
Let's leave the survey statistics unification for a future PR! Up to you on the leakage |
|
Thank you for this, looks good to me too! As I was suggesting in #296 perhaps after merging this we can move the |
ee75f53
into
feature/sp_validation-extend-to-tomography



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.