Skip to content

Commit f77f7cb

Browse files
Merge pull request #166 from martinkilbinger/v1.5.9
V1.5.9
2 parents c4ef573 + 457ee55 commit f77f7cb

File tree

3 files changed

+135
-2
lines changed

3 files changed

+135
-2
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Config file for masking and calibration.
2+
# Less conservative cuts, type v1.X.9 (e.g. for matching with spectroscopic sample).
3+
4+
# General parameters (can also given on command line)
5+
params:
6+
input_path: unions_shapepipe_comprehensive_struc_2024_v1.X.c.hdf5
7+
cmatrices: False
8+
sky_regions: False
9+
verbose: True
10+
11+
# Masks
12+
## Using columns in 'dat' group (ShapePipe flags)
13+
dat:
14+
# SExtractor flags
15+
- col_name: FLAGS
16+
label: SE FLAGS
17+
kind: smaller_equal
18+
value: 2
19+
20+
# Duplicate objects
21+
- col_name: overlap
22+
label: tile overlap
23+
kind: equal
24+
value: True
25+
26+
# ShapePipe flags
27+
- col_name: IMAFLAGS_ISO
28+
label: SP mask
29+
kind: equal
30+
value: 0
31+
32+
# Number of epochs
33+
- col_name: N_EPOCH
34+
label: r"$n_{\rm epoch}$"
35+
kind: greater_equal
36+
value: 1
37+
38+
# Magnitude range
39+
- col_name: mag
40+
label: mag range
41+
kind: range
42+
value: [15, 30]
43+
44+
# ngmix flags
45+
- col_name: NGMIX_MOM_FAIL
46+
label: "ngmix moments failure"
47+
kind: equal
48+
value: 0
49+
50+
# invalid PSF ellipticities
51+
- col_name: NGMIX_ELL_PSFo_NOSHEAR_0
52+
label: "bad PSF ellipticity comp 1"
53+
kind: not_equal
54+
value: -10
55+
- col_name: NGMIX_ELL_PSFo_NOSHEAR_1
56+
label: "bad PSF ellipticity comp 2"
57+
kind: not_equal
58+
value: -10
59+
60+
## Using columns in 'dat_ext' group (post-processing flags)
61+
dat_ext:
62+
63+
# Stars
64+
- col_name: 4_Stars
65+
label: "Stars"
66+
kind: equal
67+
value: False
68+
69+
# Manual mask
70+
- col_name: 8_Manual
71+
label: "manual mask"
72+
kind: equal
73+
value: False
74+
75+
# r-band footprint
76+
- col_name: 64_r
77+
label: "r-band imaging"
78+
kind: equal
79+
value: False
80+
81+
# Maximask
82+
- col_name: 1024_Maximask
83+
label: "maximask"
84+
kind: equal
85+
value: False
86+
87+
# Metacal parameters
88+
metacal:
89+
# Ellipticity dispersion
90+
sigma_eps_prior: 0.34
91+
92+
# Signal-to-noise range
93+
gal_snr_min: 5
94+
gal_snr_max: 500
95+
96+
# Relative-size (hlr / hlr_psf) range
97+
gal_rel_size_min: 0.25
98+
gal_rel_size_max: 10
99+
100+
# Correct relative size for ellipticity?
101+
gal_size_corr_ell: False
102+
103+
# Weight for global response matrix, None for unweighted mean
104+
global_R_weight: w
105+
106+
# Binned footprint mask
107+
binned_mask:
108+
# Resolution
109+
nside: 8192
110+
111+
# Mask value for "good region (observed)
112+
good: False
113+
114+
# Output file path
115+
output_path: "footprint_binned.fits"

notebooks/calibrate_comprehensive_cat.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
import sys
1717
import os
1818
import numpy as np
19+
import healpy as hp
1920
from astropy.io import fits
2021
import matplotlib.pylab as plt
2122

23+
from cs_util import cat as cs_cat
24+
2225
from sp_validation import run_joint_cat as sp_joint
2326
from sp_validation import util
2427
from sp_validation.basic import metacal
@@ -145,14 +148,27 @@
145148
for mask in masks:
146149
del mask
147150

148-
# %%
149151
# %%
150152
# Additional quantities
151153
ra = cat.get_col(dat, "RA", mask_combined._mask, mask_metacal)
152154
dec = cat.get_col(dat, "Dec", mask_combined._mask, mask_metacal)
153155
mag = cat.get_col(dat, "mag", mask_combined._mask, mask_metacal)
154156

155157

158+
# %%
159+
# Create hp mask file
160+
if "binned_mask" in config:
161+
cbm = config["binned_mask"]
162+
print("Binning data to obtain mask...")
163+
area_deg2, pix = cs_cat.get_binned_area(ra, dec, nside=cbm["nside"], return_pix=True)
164+
healpix_map = np.full(hp.nside2npix(cbm["nside"]), not cbm["good"])
165+
healpix_map[pix] = cbm["good"]
166+
print(f"Writing binned mask to file {cbm['output_path']}...")
167+
hp.write_map(cbm["output_path"], healpix_map, overwrite=True)
168+
else:
169+
print("No binned mask file on output")
170+
171+
156172
# %%
157173
# Additional data columns to write to output cat
158174
add_cols = [
@@ -244,10 +260,12 @@
244260
)
245261

246262
# %%
263+
# Write mask information to ASCII file
247264
with open("masks.txt", "w") as f_out:
248265
for my_mask in masks:
249266
my_mask.print_summary(f_out)
250267

268+
251269
# %%
252270

253271
if not obj._params["cmatrices"]:

notebooks/demo_calibrate_minimal_cat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
)
115115
# -
116116

117-
g_corr_mc, g_uncorr, w, nask)metacal, c, c_err = get_calibrated_m_c(gal_metacal
117+
g_corr_mc, g_uncorr, w, nask)metacal, c, c_err = get_calibrated_m_c(gal_metacal)
118118

119119
num_ok = len(g_corr_mc[0])
120120
sp_joint.Mask.print_strings(

0 commit comments

Comments
 (0)