Skip to content

Commit f0fca23

Browse files
committed
rename moments_fail column to mcal_types_fail
The v1 `moments_fail` column counted moments-initial-guess (get_guess) failures. get_guess no longer exists in the v2.0 fitter; the column now holds the count (0-5) of metacal fit types with nonzero fit flags, and it reaches the catalogue (NGMIX_MOM_FAIL). The old name no longer matches the meaning, so rename through ngmix + make_cat to mcal_types_fail / NGMIX_MCAL_TYPES_FAIL. Tests updated in lockstep.
1 parent 8b6ac7b commit f0fca23

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/shapepipe/modules/make_cat_package/make_cat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def _save_ngmix_data(self, ngmix_cat_path, moments=False):
355355
#ngmix_cat_file.close()
356356
#return err_msg
357357

358-
ngmix_mom_fail = ngmix_cat_file.get_data()["moments_fail"]
358+
ngmix_mcal_types_fail = ngmix_cat_file.get_data()["mcal_types_fail"]
359359

360360
n_obj = len(self._obj_id)
361361
self._w_log.info(f"writing ngmix info for {n_obj} objects")
@@ -369,7 +369,7 @@ def _save_ngmix_data(self, ngmix_cat_path, moments=False):
369369
ngmix_id = ngmix_cat_file.get_data()["id"]
370370

371371
self._add2dict("NGMIX_N_EPOCH", np.zeros(n_obj))
372-
self._add2dict("NGMIX_MOM_FAIL", np.zeros(n_obj))
372+
self._add2dict("NGMIX_MCAL_TYPES_FAIL", np.zeros(n_obj))
373373

374374
prefix = f"NGMIX{m}"
375375

@@ -465,8 +465,8 @@ def _save_ngmix_data(self, ngmix_cat_path, moments=False):
465465
idx,
466466
)
467467
self._add2dict(
468-
f"NGMIX{m}_MOM_FAIL",
469-
ngmix_mom_fail[ind[0]],
468+
f"NGMIX{m}_MCAL_TYPES_FAIL",
469+
ngmix_mcal_types_fail[ind[0]],
470470
idx,
471471
)
472472

src/shapepipe/modules/ngmix_package/ngmix.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def compile_results(self, results):
376376
names2 = [
377377
'id',
378378
'n_epoch_model',
379-
'moments_fail',
379+
'mcal_types_fail',
380380
'nfev_fit',
381381
'g1_psfo_ngmix',
382382
'g2_psfo_ngmix',
@@ -430,8 +430,8 @@ def compile_results(self, results):
430430
output_dict[name]["n_epoch_model"].append(
431431
results[idx]["n_epoch_model"]
432432
)
433-
output_dict[name]["moments_fail"].append(
434-
results[idx]["moments_fail"]
433+
output_dict[name]["mcal_types_fail"].append(
434+
results[idx]["mcal_types_fail"]
435435
)
436436
# ngmix 2.x reports the solver's function-evaluation count
437437
# (nfev, ~tens-hundreds; -1 on some failures), not the v1
@@ -680,7 +680,11 @@ def process(self):
680680
# epochs that survived the PSF fit and entered the model,
681681
# not the number of epochs submitted (v1 contract)
682682
res['n_epoch_model'] = psf_res['n_epoch']
683-
res['moments_fail'] = sum(
683+
# Count of metacal fit types (0-5) with nonzero fit flags.
684+
# (In ngmix v1 the same-named column counted moments-initial-guess
685+
# failures from get_guess, which no longer exists — hence the
686+
# rename to mcal_types_fail / NGMIX_MCAL_TYPES_FAIL.)
687+
res['mcal_types_fail'] = sum(
684688
1 for k in METACAL_TYPES
685689
if res.get(k, {}).get('flags', 0) != 0
686690
)

tests/module/test_ngmix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def _fake_metacal_result(T, T_err, T_psf, T_psf_err):
158158
res = {
159159
"obj_id": 1,
160160
"n_epoch_model": 1,
161-
"moments_fail": 0,
161+
"mcal_types_fail": 0,
162162
"g_PSFo": [0.001, 0.002],
163163
"g_err_PSFo": [1e-5, 1e-5],
164164
"T_PSFo": T_psf,
@@ -244,7 +244,7 @@ def test_compile_results_nan_fills_failed_fit_types():
244244

245245
res = _fake_metacal_result(0.18, 0.02, 0.09, 0.001)
246246
res["1p"] = {"flags": 0x8, "nfev": 5} # failed fit: only flags/nfev
247-
res["moments_fail"] = 1
247+
res["mcal_types_fail"] = 1
248248
res["mcal_flags"] = get_mcal_flags(res)
249249

250250
inst = object.__new__(Ngmix)

0 commit comments

Comments
 (0)