Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,4 @@ papers/catalog/plots/*.pdf
papers/cosmo_val/logs/

# Ignore scratch notebooks
scratch/*/*.ipynb
scratch/guerrini/work_notebooks
scratch/guerrini/launch_scripts
scratch/*/*.ipynb
46 changes: 0 additions & 46 deletions cosmo_val/cat_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1259,49 +1259,3 @@ SP_v1.6.6:
e1_col: e1
e2_col: e2
path: unions_shapepipe_star_2024_v1.6.a.fits

GLASS_mock_validation:
subdir: /n09data/guerrini/glass_mock_test/results/
pipeline: SP
colour: violet
getdist_colour: 0.0, 0.5, 1.0
ls: dashed
marker: '*'
cov_th:
A: 2405.3892055695346
n_e: 6.128201234871523
n_psf: 0.752316232272063
sigma_e: 0.379587601488189
mask: /home/guerrini/sp_validation/cosmo_inference/data/mask/mask_map_footprint_nside_4096.fits
psf:
PSF_flag: FLAG_PSF_HSM
PSF_size: SIGMA_PSF_HSM
square_size: true
star_flag: FLAG_STAR_HSM
star_size: SIGMA_STAR_HSM
hdu: 1
path: unions_shapepipe_psf_2024_v1.6.a.fits
ra_col: RA
dec_col: Dec
e1_PSF_col: E1_PSF_HSM
e1_star_col: E1_STAR_HSM
e2_PSF_col: E2_PSF_HSM
e2_star_col: E2_STAR_HSM
shear:
R: 1.0
path: tomo_test_2_glass_sim_00001_1024.fits
redshift_path: /home/guerrini/sp_validation_cosmostat/config/glass_mock/test_data/redshift_distribution_tomo.txt
w_col: w
e1_col: e1
e1_PSF_col: e1_PSF
e2_col: e2
e2_PSF_col: e2_PSF
cols: RA,Dec
tomo_bin_col: tom_bin_id
star:
ra_col: RA
dec_col: Dec
e1_col: e1
e2_col: e2
path: unions_shapepipe_star_2024_v1.6.a.fits

51 changes: 3 additions & 48 deletions src/sp_validation/cosmo_val/core.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# %%
import copy
import itertools
import os
import re
from pathlib import Path

import colorama
import numpy as np
import yaml
from astropy.io import fits
from cs_util.cosmo import get_cosmo
from shear_psf_leakage import run_object, run_scale

from ..b_modes import (
Expand Down Expand Up @@ -89,7 +88,7 @@ class CosmologyValidation(
Number of ell bins for pseudo-C_ell analysis (used with binning='powspace').
ell_step : int, default 10
Bin width in ell for linear binning (used with binning='linear').
pol_factor : int, default -1
pol_factor : bool, default True
Apply polarization correction factor in pseudo-C_ell calculations.
nrandom_cell : int, default 10
Number of random realizations for C_ell error estimation.
Expand All @@ -98,10 +97,6 @@ class CosmologyValidation(
noise debiasing, making those realizations reproducible run-to-run.
cosmo_params : dict, optional
Cosmological parameters to pass to get_cosmo(). If None, uses Planck 2018.
compute_tomography : bool, default False
Whether to compute tomographic correlation functions and pseudo-C_ell.
force_run : bool, default False
If True, forces re-computation of results even if cached outputs exist.

Attributes
----------
Expand Down Expand Up @@ -219,7 +214,7 @@ def __init__(
power=1 / 2,
n_ell_bins=32,
ell_step=10,
pol_factor=-1,
pol_factor=True,
cell_method="map",
noise_bias_method="analytic",
fiducial_input_inka="coupled",
Expand All @@ -228,8 +223,6 @@ def __init__(
path_onecovariance=None,
cosmo_params=None,
blind=None,
compute_tomography=False,
force_run=False,
):
self.rho_tau_method = rho_tau_method
self.cov_estimate_method = cov_estimate_method
Expand All @@ -250,10 +243,7 @@ def __init__(
self.power = power
self.n_ell_bins = n_ell_bins
self.ell_step = ell_step

assert pol_factor in (-1, 1), "The polarisatio factor must be -1 or 1."
self.pol_factor = pol_factor

self.nrandom_cell = nrandom_cell
self.cell_seed = cell_seed
self.cell_method = cell_method
Expand All @@ -262,8 +252,6 @@ def __init__(
self.nside_mask = nside_mask
self.path_onecovariance = path_onecovariance
self.blind = blind
self.compute_tomography = compute_tomography
self.force_run = force_run

assert self.cell_method in ["map", "catalog"], (
"cell_method must be 'map' or 'catalog'"
Expand Down Expand Up @@ -648,36 +636,3 @@ def summarize_bmodes(self, fiducial_scale_cut=(12, 83), versions=None):
print()

return summary

def _get_tomo_bins(self, version):
"""
Return the tomo_bin_ids for a given version. If the version does not have tomography, return None.

Returns
-------
tomo_bin_ids : list or None
List of unique tomographic bin IDs for the version, or None if no tomography is available
tomo_bin_pairs : list of tuples or None
List of unique pairs of tomographic bin IDs (including self-pairs) for the version, or None if no tomography is available
"""
if "tomo_bin_col" in self.cc[version]["shear"]:
self.print_cyan(
f"Extracting tomography information from version {version}."
)
cat_gal = fits.getdata(self.cc[version]["shear"]["path"])
tomo_bin = cat_gal[self.cc[version]["shear"]["tomo_bin_col"]]
tomo_bin_ids = np.unique(tomo_bin)
tomo_bin_ids = tomo_bin_ids[
tomo_bin_ids > 0
] # Exclude zero or negative bins
self.print_cyan(
f"Found {len(tomo_bin_ids)} tomographic bins for version {version}: {tomo_bin_ids}."
)

tomo_bin_pairs = list(
itertools.combinations_with_replacement(tomo_bin_ids, 2)
)
return tomo_bin_ids, tomo_bin_pairs
else:
self.print_cyan(f"Version {version} does not have tomography information.")
return None, None
Loading
Loading