Skip to content
Open
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
6 changes: 3 additions & 3 deletions cosmo_val/cat_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1272,15 +1272,15 @@ GLASS_mock_validation:
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
mask: /n09data/guerrini/glass_mock_test/mask_nside_1024.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
path: ../../../../n17data/UNIONS/WL/v1.6.x/unions_shapepipe_psf_2024_v1.6.a.fits
ra_col: RA
dec_col: Dec
e1_PSF_col: E1_PSF_HSM
Expand All @@ -1303,5 +1303,5 @@ GLASS_mock_validation:
dec_col: Dec
e1_col: e1
e2_col: e2
path: unions_shapepipe_star_2024_v1.6.a.fits
path: ../../../../n17data/UNIONS/WL/v1.6.x/unions_shapepipe_star_2024_v1.6.a.fits

80 changes: 68 additions & 12 deletions src/sp_validation/cosmo_val/catalog_characterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,17 @@ def area(self):
@property
def n_eff_gal(self):
if not hasattr(self, "_n_eff_gal"):
self.calculate_n_eff_gal()
self.calculate_n_eff_gal(tomography=False)
if self.compute_tomography:
self.calculate_n_eff_gal(tomography=True)
return self._n_eff_gal

@property
def ellipticity_dispersion(self):
if not hasattr(self, "_ellipticity_dispersion"):
self.calculate_ellipticity_dispersion()
self.calculate_ellipticity_dispersion(tomography=False)
if self.compute_tomography:
Comment thread
sachaguer marked this conversation as resolved.
self.calculate_ellipticity_dispersion(tomography=True)
return self._ellipticity_dispersion

def _get_binned_catalog_mask(self, ver):
Expand Down Expand Up @@ -202,29 +206,81 @@ def calculate_area_from_binned_catalog(self, ver):

return area

def calculate_n_eff_gal(self):
def calculate_n_eff_gal(self, tomography=False):
self.print_start("Calculating effective number of galaxy")
n_eff_gal = {}
if not hasattr(self, "_n_eff_gal"):
self._n_eff_gal = {}
for ver in self.versions:
self.print_magenta(ver)
if ver not in self._n_eff_gal:
self._n_eff_gal[ver] = {}

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")]

with self.results[ver].temporarily_read_data():
w = self._read_shear_cols(ver, "w_col")
n_eff_gal[ver] = n_eff_density(w, self.area[ver])
print(f"n_eff_gal = {n_eff_gal[ver]:.2f} gal./arcmin^-2")
for tomo_bin_id in tomo_bin_ids:
if tomo_bin_id == "all":
self._n_eff_gal[ver][f"tomo_bin_{tomo_bin_id}"] = n_eff_density(
w, self.area[ver]
)
else:
tomo_bin = self._read_shear_cols(ver, "tomo_bin_col")
mask = tomo_bin == tomo_bin_id
self._n_eff_gal[ver][f"tomo_bin_{tomo_bin_id}"] = n_eff_density(
w[mask], self.area[ver]
)
print(
f"n_eff_gal for tomo_bin_{tomo_bin_id} = {self._n_eff_gal[ver][f'tomo_bin_{tomo_bin_id}']:.2f} gal./arcmin^-2"
)

self._n_eff_gal = n_eff_gal
self.print_done("Effective number of galaxy calculation finished")

def calculate_ellipticity_dispersion(self):
def calculate_ellipticity_dispersion(self, tomography=False):
self.print_start("Calculating ellipticity dispersion")
ellipticity_dispersion = {}
if not hasattr(self, "_ellipticity_dispersion"):
self._ellipticity_dispersion = {}
for ver in self.versions:
self.print_magenta(ver)
if ver not in self._ellipticity_dispersion:
self._ellipticity_dispersion[ver] = {}

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")]

with self.results[ver].temporarily_read_data():
e1, e2, w = self._read_shear_cols(ver, "e1_col", "e2_col", "w_col")
ellipticity_dispersion[ver] = ellipticity_dispersion_stat(e1, e2, w)
print(f"Ellipticity dispersion = {ellipticity_dispersion[ver]:.4f}")
self._ellipticity_dispersion = ellipticity_dispersion
for tomo_bin_id in tomo_bin_ids:
if tomo_bin_id == "all":
self._ellipticity_dispersion[ver][f"tomo_bin_{tomo_bin_id}"] = (
ellipticity_dispersion_stat(e1, e2, w)
)
else:
tomo_bin = self._read_shear_cols(ver, "tomo_bin_col")
mask = tomo_bin == tomo_bin_id
self._ellipticity_dispersion[ver][f"tomo_bin_{tomo_bin_id}"] = (
ellipticity_dispersion_stat(e1[mask], e2[mask], w[mask])
)
print(
f"Ellipticity dispersion for tomo_bin_{tomo_bin_id} = {self._ellipticity_dispersion[ver][f'tomo_bin_{tomo_bin_id}']:.4f}"
)

def plot_footprints(self):
self.print_start("Plotting footprints:")
Expand Down
Loading
Loading