Skip to content

Commit 8ae3203

Browse files
cailmdaleyclaude
andcommitted
refactor(ngmix): build the per-family PSF res-keys from one loop
The 12 hand-written g*/T_psf_{reconv,orig} assignments collapse to a single template applied over (family, source) — same keys, same values, but the two PSF families are now generated symmetrically, so one can't gain or misname a column the other lacks. Addresses a drift/hardcoding risk Cail flagged in review. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 31d2080 commit 8ae3203

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

  • src/shapepipe/modules/ngmix_package

src/shapepipe/modules/ngmix_package/ngmix.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -708,22 +708,19 @@ def process(self):
708708
if res.get(k, {}).get('flags', 0) != 0
709709
)
710710
res['mcal_flags'] = get_mcal_flags(res)
711-
# Two distinct PSF families (shapepipe#749), each with its own
712-
# ellipticity AND size, written under self-naming res-keys:
713-
# reconvolution kernel (psf_res) -> *_psf_reconv
714-
# original image PSF (psf_orig_res) -> *_psf_orig
715-
res['g1_psf_reconv'] = psf_res['g_psf'][0]
716-
res['g2_psf_reconv'] = psf_res['g_psf'][1]
717-
res['g1_err_psf_reconv'] = psf_res['g_psf_err'][0]
718-
res['g2_err_psf_reconv'] = psf_res['g_psf_err'][1]
719-
res['T_psf_reconv'] = psf_res['T_psf']
720-
res['T_err_psf_reconv'] = psf_res['T_psf_err']
721-
res['g1_psf_orig'] = psf_orig_res['g_psf'][0]
722-
res['g2_psf_orig'] = psf_orig_res['g_psf'][1]
723-
res['g1_err_psf_orig'] = psf_orig_res['g_psf_err'][0]
724-
res['g2_err_psf_orig'] = psf_orig_res['g_psf_err'][1]
725-
res['T_psf_orig'] = psf_orig_res['T_psf']
726-
res['T_err_psf_orig'] = psf_orig_res['T_psf_err']
711+
# Two distinct PSF families (shapepipe#749), each carrying its own
712+
# ellipticity AND size: the metacal reconvolution kernel (psf_res)
713+
# and the original image PSF (psf_orig_res). Tag both into res from
714+
# ONE template so the families stay symmetric — same quantities,
715+
# parallel ``*_psf_{family}`` names — and cannot drift apart by a
716+
# hand-edit to one and not the other.
717+
for family, psf in (("reconv", psf_res), ("orig", psf_orig_res)):
718+
res[f"g1_psf_{family}"] = psf["g_psf"][0]
719+
res[f"g2_psf_{family}"] = psf["g_psf"][1]
720+
res[f"g1_err_psf_{family}"] = psf["g_psf_err"][0]
721+
res[f"g2_err_psf_{family}"] = psf["g_psf_err"][1]
722+
res[f"T_psf_{family}"] = psf["T_psf"]
723+
res[f"T_err_psf_{family}"] = psf["T_psf_err"]
727724
final_res.append(res)
728725
n_fitted += 1
729726
count_batch += 1

0 commit comments

Comments
 (0)