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
2 changes: 1 addition & 1 deletion config/calibration/mask_v1.X.10.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Config file for masking and calibration.
# Standard cuts without halo masks, type v1.X.10
# Standard cuts without halo masks, including deblended objects, type v1.X.10

# General parameters (can also given on command line)
params:
Expand Down
36 changes: 18 additions & 18 deletions notebooks/config_mask.yaml → config/calibration/mask_v1.X.11.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# Config file for masking and calibration.
# Standard cuts without halo masks, including deblended objects, type v1.X.11

# General parameters (can also given on command line)
params:
input_path: unions_shapepipe_comprehensive_struc_2024_v1.4.2.hdf5
cmatrices: True
input_path: unions_shapepipe_comprehensive_struc_2024_v1.X.c.hdf5
cmatrices: False
sky_regions: False
verbose: True

# Masks
## Using columns in 'dat' group (ShapePipe flags)
dat:
# SExtractor flags
- col_name: FLAGS
label: SE FLAGS
kind: equal
value: 0
kind: smaller_equal
value: 3

# Duplicate objects
- col_name: overlap
Expand Down Expand Up @@ -50,18 +57,8 @@ dat:
kind: not_equal
value: -10

## Using columns in 'dat_ext' group (post-processing flags)
dat_ext:
# Faint star halos
- col_name: 1_Faint_star_halos
label: "Faint star halos"
kind: equal
value: False

# Bright star halos
- col_name: 2_Bright_star_halos
label: "Bright star halos"
kind: equal
value: False

# Stars
- col_name: 4_Stars
Expand All @@ -87,7 +84,7 @@ dat_ext:
kind: equal
value: False

# Rought pointing coverage
# Rough pointing coverage
- col_name: npoint3
label: r"$n_{\rm pointing}$"
kind: greater_equal
Expand All @@ -103,8 +100,11 @@ metacal:
gal_snr_max: 500

# Relative-size (hlr / hlr_psf) range
gal_rel_size_min: 0.5
gal_rel_size_min: 0.707
gal_rel_size_max: 3

# Correct relative size for ellipticity?
gal_size_corr_ell: False
gal_size_corr_ell: False

# Weight for global response matrix, None for unweighted mean
global_R_weight: w
11 changes: 11 additions & 0 deletions config/calibration/mask_v1.X.2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,14 @@ metacal:

# Correct relative size for ellipticity?
gal_size_corr_ell: False

# Binned footprint mask
binned_mask:
# Resolution
nside: 8192

# Mask value for "good region (observed)
good: False

# Output file path
output_path: "footprint_binned.fits"
11 changes: 11 additions & 0 deletions config/calibration/mask_v1.X.3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,14 @@ metacal:

# Correct relative size for ellipticity?
gal_size_corr_ell: False

# Binned footprint mask
binned_mask:
# Resolution
nside: 8192

# Mask value for "good region (observed)
good: False

# Output file path
output_path: "footprint_binned.fits"
11 changes: 11 additions & 0 deletions config/calibration/mask_v1.X.4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,14 @@ metacal:

# Correct relative size for ellipticity?
gal_size_corr_ell: False

# Binned footprint mask
binned_mask:
# Resolution
nside: 8192

# Mask value for "good region (observed)
good: False

# Output file path
output_path: "footprint_binned.fits"
11 changes: 11 additions & 0 deletions config/calibration/mask_v1.X.5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,14 @@ metacal:

# Correct relative size for ellipticity?
gal_size_corr_ell: False

# Binned footprint mask
binned_mask:
# Resolution
nside: 8192

# Mask value for "good region (observed)
good: False

# Output file path
output_path: "footprint_binned.fits"
11 changes: 11 additions & 0 deletions config/calibration/mask_v1.X.6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,14 @@ metacal:

# Weight for global response matrix, None for unweighted mean
global_R_weight: w

# Binned footprint mask
binned_mask:
# Resolution
nside: 8192

# Mask value for "good region (observed)
good: False

# Output file path
output_path: "footprint_binned.fits"
11 changes: 11 additions & 0 deletions config/calibration/mask_v1.X.7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,14 @@ metacal:

# Weight for global response matrix, None for unweighted mean
global_R_weight: w

# Binned footprint mask
binned_mask:
# Resolution
nside: 8192

# Mask value for "good region (observed)
good: False

# Output file path
output_path: "footprint_binned.fits"
11 changes: 11 additions & 0 deletions config/calibration/mask_v1.X.8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,14 @@ metacal:

# Weight for global response matrix, None for unweighted mean
global_R_weight: w

# Binned footprint mask
binned_mask:
# Resolution
nside: 8192

# Mask value for "good region (observed)
good: False

# Output file path
output_path: "footprint_binned.fits"
28 changes: 20 additions & 8 deletions notebooks/calibrate_comprehensive_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
# enable autoreload for interactive sessions
ipython = get_ipython()
if ipython is not None:
ipython.run_line_magic("load_ext", "autoreload")
ipython.run_line_magic("reload_ext", "autoreload")
ipython.run_line_magic("autoreload", "2")
ipython.run_line_magic("load_ext", "log_cell_time")
ipython.run_line_magic("reload_ext", "log_cell_time")


# %%
import sys
Expand All @@ -36,6 +37,11 @@
# Read configuration file and set parameters
config = obj.read_config_set_params("config_mask.yaml")



# %%
obj._params

# %%
# Get data. Set load_into_memory to False for very large files
dat, dat_ext = obj.read_cat(load_into_memory=False)
Expand All @@ -49,7 +55,6 @@
dat_ext = dat_ext[:n_test]



# %%
# ## Masking

Expand Down Expand Up @@ -125,6 +130,10 @@
mask_combined,
mask_metacal,
num_bins=20,
snr_min=cm["gal_snr_min"],
snr_max=cm["gal_snr_max"],
size_ratio_min=cm["gal_rel_size_min"],
size_ratio_max=cm["gal_rel_size_max"],
)

# %%
Expand Down Expand Up @@ -195,7 +204,14 @@
mask_combined._mask,
mask_metacal
)
#add_cols_data[key] = dat[key][mask_combined._mask][mask_metacal]

# Keep original NOSHEAR column, override with 1P PSF values (FHP/MK hack)
print(
"FHP/MK hack: explicit copying of the metacal no-shear (updated from 1p)"
+ f" PSF size"
)
add_cols_data["NGMIX_Tpsf_NOSHEAR_orig"] = add_cols_data["NGMIX_Tpsf_NOSHEAR"]
add_cols_data["NGMIX_Tpsf_NOSHEAR"] = gal_metacal.ns["Tpsf"][mask_metacal]

# %%
# Additional post-processing columns to write to output cat
Expand Down Expand Up @@ -229,10 +245,6 @@
for my_mask in masks:
my_mask.add_summary_to_FITS_header(header)


# %%
header

# %%
output_shape_cat_path = obj._params["input_path"].replace(
"comprehensive", "cut"
Expand Down
22 changes: 11 additions & 11 deletions notebooks/cosmo_val/cat_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ SP_v1.3:
SP_v1.3.6:
subdir: /n17data/UNIONS/WL/v1.3.x
pipeline: SP
colour: violet
colour: coral
getdist_colour: 0.0, 0.5, 1.0
ls: dashed
marker: h
Expand Down Expand Up @@ -646,7 +646,7 @@ SP_v1.4.8:
SP_v1.4.11.2:
subdir: /n17data/UNIONS/WL/v1.4.x
pipeline: SP
colour: blue
colour: orange
getdist_colour: 0.0, 0.5, 1.0
ls: dashed
marker: s
Expand Down Expand Up @@ -688,18 +688,18 @@ SP_v1.4.11.2:
e1_col: e1
e2_col: e2
path: unions_shapepipe_star_2024_v1.4.a.fits
SP_v1.4.11.2_w_iv:
SP_v1.4.11.3:
subdir: /n17data/UNIONS/WL/v1.4.x
pipeline: SP
colour: teal
getdist_colour: 0.0, 0.7, 0.7
ls: dotted
marker: s
colour: red
getdist_colour: 0.0, 0.5, 1.0
ls: dashdot
marker: v
cov_th:
A: 2405.3892055695346
n_e: 7.529428768078532
n_e: 6.128201234871523
n_psf: 0.752316232272063
sigma_e: 0.380499698062307
sigma_e: 0.379587601488189
mask: /home/guerrini/sp_validation/cosmo_inference/data/mask/mask_map_v1.4.6_nside_8192.fits
psf:
PSF_flag: FLAG_PSF_HSM
Expand All @@ -718,9 +718,9 @@ SP_v1.4.11.2_w_iv:
shear:
R: 1.0
covmat_file: ./covs/shapepipe_A/cov_shapepipe_A.txt
path: v1.4.11.2/unions_shapepipe_cut_struc_2024_v1.4.11.2.fits
path: v1.4.11.3/unions_shapepipe_cut_struc_2024_v1.4.11.3.fits
redshift_path: /n17data/mkilbing/astro/data/CFIS/v1.0/nz/dndz_SP_A.txt
w_col: w_iv
w_col: w_des
e1_col: e1
e1_col_corrected: e1_leak_corrected
e1_PSF_col: e1_PSF
Expand Down
2 changes: 1 addition & 1 deletion notebooks/create_shear_mb_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# Set parameters
base = "unions_shapepipe_comprehensive_struc"
year = 2024
ver = "v1.5.c"
ver = "v1.6.c"

obj._params = {}

Expand Down
3 changes: 2 additions & 1 deletion notebooks/demo_apply_hsp_masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
# +
# Set parameters
base = "unions_shapepipe_comprehensive"
year = 2024
ver = "v1.3.c"

if ver == "v1.3.c":
year = 2022
else:
Expand Down
1 change: 0 additions & 1 deletion notebooks/extract_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@
g_star_psf[1],
)


#### Refine: Match to SPREAD_CLASS samples
if "SPREAD_CLASS" in dd.dtype.names:
spv_cat.match_spread_class(dd, ind_star, m_star, stats_file, len(ra_star), verbose=verbose)
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies = [
"camb",
"clmm",
"colorama",
"cosmo-numba @ git+https://github.com/aguinot/cosmo-numba",
"cs_util>=0.1.5",
"emcee",
"getdist @ git+https://github.com/benabed/getdist.git@upper_triangle_whisker",
Expand Down
20 changes: 11 additions & 9 deletions src/sp_validation/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ def _read_data(self, data, mask):
ns,
)

print("FHP/MK hack using p1 PSF for ns in cuts")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should do it @fabianhervaspeters. We need to update both the PSF size in the no-shear dict, and in the original data.

indices = np.where(mask)[0]
col_noshear = f"{self._prefix}_Tpsf_NOSHEAR"
col_1p = f"{self._prefix}_Tpsf_1P"
new_psf = data[col_1p][indices]

# Overwriting incorrect no-shear PSF size to the one from 1p
ns["Tpsf"] = new_psf

self.m1 = m1
self.p1 = p1
self.m2 = m2
Expand All @@ -157,7 +166,7 @@ def _read_data_ngmix(self, masked_data, m1, p1, m2, p2, ns):
Read data from ngmix catalogue.

"""

for name_shear, dict_tmp in zip(
['1M', '1P', '2M', '2P', 'NOSHEAR'],
[m1, p1, m2, p2, ns]
Expand Down Expand Up @@ -370,14 +379,7 @@ def _masking_gal(self):
else:
snr_flux = data['flux'] / data['flux_err']

if name == 'ns':
# This is a FHP hack, the ns PSF measured in shapepipe is not correct,
# fortunately it is the same dilated PSF as the other branches,
# thus we can simply use p1
print("FHP using p1 PSF for ns in cuts")
Tpsf = self.p1['Tpsf']
else:
Tpsf = data['Tpsf']
Tpsf = data['Tpsf']

mask_tmp = (
(data['flag'] == 0)
Expand Down
Loading