Skip to content

Commit 1187847

Browse files
cailmdaleyclaude
andcommitted
refactor(make_cat): remove the dead galsim shape-serialization path
No runner produces galsim shapes (there is no galsim_shapes_runner) and the dual-shape (len==5) input branch in make_cat_runner never fires — ngmix is the pipeline's only shape estimator, so the galsim serialization path was dead code. - delete SaveCatalogue._save_galsim_shapes and its "galsim" process mode (drops the now-orphaned cs_util.size import from make_cat) - make_cat_runner validates SHAPE_MEASUREMENT_TYPE against ngmix alone and drops the dead second-shape-catalogue branch; the list knob is kept as the extension point for a future estimator family - drop test_galsim_grammar_properties.py and the galsim cases from the frozen column-grammar examples in test_psf_grammar_properties.py - lose the galsim references in the make_cat docstring, the make_cat_mccd example config, and the cat_matched.param comment Carved out of #761 to keep that PR scoped to the reconvolved-PSF column grammar; the removal deletes a test #761 introduced. Closes #783 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 662fad4 commit 1187847

7 files changed

Lines changed: 22 additions & 432 deletions

File tree

example/cfis/config_make_cat_mccd.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@ TIMEOUT = 96:00:00
5757
# Input file pattern(s), list of strings with length matching number of expected input file types
5858
# Cannot contain wild cards
5959
FILE_PATTERN = sexcat, sexcat_sm, galaxy_psf, ngmix
60-
#, galsim
6160

6261
# FILE_EXT (optional) list of string extensions to identify input files
6362
FILE_EXT = .fits, .fits, .sqlite, .fits
64-
#, .fits
6563

6664
# Numbering convention, string that exemplifies a numbering pattern.
6765
# Matches input single exposures (with 'p' removed)
@@ -74,4 +72,3 @@ SM_STAR_THRESH = 0.003
7472
SM_GAL_THRESH = 0.01
7573

7674
SHAPE_MEASUREMENT_TYPE = ngmix
77-
#, galsim

example/unions_800/cat_matched.param

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ FLAG_TILING
9494
# magnitude, mainly for plots
9595
MAG_AUTO
9696

97-
# SNR from SExtractor, used for cuts on GALSIM shapes
97+
# SNR from SExtractor, used for cuts on shapes
9898
SNR_WIN
9999

100100
# PSF size measured on original image

src/shapepipe/modules/make_cat_package/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
spread model and :math:`\sigma_s` is the spread model error; default value
4444
is ``0.01``
4545
SHAPE_MEASUREMENT_TYPE : list
46-
Shape measurement method, valid options are ``ngmix`` and/or ``galsim``
46+
Shape measurement method; the only valid option is ``ngmix`` (the knob is
47+
retained as the extension point for a future estimator family)
4748
SAVE_PSF_DATA : bool, optional
4849
Save PSF information if ``True``; default value is ``False``
4950
TILE_LIST : str, optional

src/shapepipe/modules/make_cat_package/make_cat.py

Lines changed: 3 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from astropy import coordinates as coords
1414
from astropy import units as u
1515
from astropy.wcs import WCS
16-
from cs_util import size as cs_size
1716
from sqlitedict import SqliteDict
1817

1918
from shapepipe.pipeline import file_io
@@ -243,7 +242,7 @@ def process(
243242
Parameters
244243
----------
245244
mode : str
246-
Run mode, options are ``ngmix``, ``galsim`` or ``psf``
245+
Run mode, options are ``ngmix`` or ``psf``
247246
cat_path : str
248247
Path to input catalogue
249248
moments : bool
@@ -263,15 +262,13 @@ def process(
263262
err_msg = None
264263
if mode == "ngmix":
265264
err_msg = self._save_ngmix_data(cat_path, moments)
266-
elif mode == "galsim":
267-
self._save_galsim_shapes(cat_path)
268265
elif mode == "psf":
269266
self._save_psf_data(cat_path)
270267
else:
271268
err_msg = (
272269
f"Invalid process mode ({mode}) for "
273-
+ '``make_cat.Savecatalogue``. Options are "ngmix", '
274-
+ '"galsim" or "psf".'
270+
+ '``make_cat.Savecatalogue``. Options are "ngmix" '
271+
+ 'or "psf".'
275272
)
276273

277274
if err_msg is None:
@@ -543,139 +540,6 @@ def _save_ngmix_data(self, ngmix_cat_path, moments=False):
543540

544541
return None
545542

546-
def _save_galsim_shapes(self, galsim_cat_path):
547-
"""Save GalSim Shapes.
548-
549-
Save the GalSim catalogue into the final one.
550-
551-
Parameters
552-
----------
553-
galsim_cat_path : str
554-
Path to GalSim catalogue to save
555-
556-
"""
557-
galsim_cat_file = file_io.FITSCatalogue(galsim_cat_path)
558-
galsim_cat_file.open()
559-
560-
self._key_ends = galsim_cat_file.get_ext_name()[1:]
561-
562-
galsim_id = galsim_cat_file.get_data()["id"]
563-
564-
for key_str in (
565-
"GALSIM_T_",
566-
"GALSIM_T_PSF_",
567-
"GALSIM_FLUX_",
568-
"GALSIM_MAG_",
569-
):
570-
self._update_dict(key_str, np.zeros(len(self._obj_id)))
571-
for key_str in ("GALSIM_FLUX_ERR_", "GALSIM_MAG_ERR_", "GALSIM_RES_"):
572-
self._update_dict(key_str, np.ones(len(self._obj_id)) * -1)
573-
for key_str in (
574-
"GALSIM_G1_",
575-
"GALSIM_G2_",
576-
"GALSIM_G1_ERR_",
577-
"GALSIM_G2_ERR_",
578-
"GALSIM_G1_UNCORR_",
579-
"GALSIM_G2_UNCORR_",
580-
"GALSIM_G1_PSF_",
581-
"GALSIM_G2_PSF_",
582-
):
583-
self._update_dict(key_str, np.ones(len(self._obj_id)) * -10.0)
584-
self._update_dict(
585-
"GALSIM_FLAGS_",
586-
np.ones(len(self._obj_id), dtype="int16"),
587-
)
588-
589-
for idx, id_tmp in enumerate(self._obj_id):
590-
ind = np.where(id_tmp == galsim_id)[0]
591-
if len(ind) > 0:
592-
593-
for key in self._key_ends:
594-
595-
gcf_data = galsim_cat_file.get_data(key)
596-
597-
if key == "ORIGINAL_PSF":
598-
599-
# PSF columns sourced from the galaxy uncorr fields
600-
# for this special extension (asymmetry preserved).
601-
self._add2dict(
602-
f"GALSIM_G1_PSF_{key}",
603-
gcf_data["gal_uncorr_g1"][ind[0]], idx
604-
)
605-
self._add2dict(
606-
f"GALSIM_G2_PSF_{key}",
607-
gcf_data["gal_uncorr_g2"][ind[0]], idx
608-
)
609-
self._add2dict(
610-
f"GALSIM_T_PSF_{key}",
611-
cs_size.sigma_to_T(gcf_data["gal_sigma"][ind[0]]),
612-
idx
613-
)
614-
615-
else:
616-
617-
self._add2dict(
618-
f"GALSIM_G1_{key}", gcf_data["gal_g1"][ind[0]], idx
619-
)
620-
self._add2dict(
621-
f"GALSIM_G2_{key}", gcf_data["gal_g2"][ind[0]], idx
622-
)
623-
self._add2dict(
624-
f"GALSIM_G1_ERR_{key}",
625-
gcf_data["gal_g1_err"][ind[0]], idx
626-
)
627-
self._add2dict(
628-
f"GALSIM_G2_ERR_{key}",
629-
gcf_data["gal_g2_err"][ind[0]], idx
630-
)
631-
632-
self._add2dict(
633-
f"GALSIM_G1_UNCORR_{key}",
634-
gcf_data["gal_uncorr_g1"][ind[0]], idx
635-
)
636-
self._add2dict(
637-
f"GALSIM_G2_UNCORR_{key}",
638-
gcf_data["gal_uncorr_g2"][ind[0]], idx
639-
)
640-
641-
self._add2dict(
642-
f"GALSIM_T_{key}",
643-
cs_size.sigma_to_T(gcf_data["gal_sigma"][ind[0]]),
644-
idx
645-
)
646-
647-
self._add2dict(
648-
f"GALSIM_G1_PSF_{key}",
649-
gcf_data["psf_g1"][ind[0]], idx
650-
)
651-
self._add2dict(
652-
f"GALSIM_G2_PSF_{key}",
653-
gcf_data["psf_g2"][ind[0]], idx
654-
)
655-
self._add2dict(
656-
f"GALSIM_T_PSF_{key}",
657-
cs_size.sigma_to_T(gcf_data["psf_sigma"][ind[0]]),
658-
idx
659-
)
660-
661-
flux = gcf_data["gal_flux"][ind[0]]
662-
flux_err = gcf_data["gal_flux_err"][ind[0]]
663-
self._add2dict(f"GALSIM_FLUX_{key}", flux, idx)
664-
self._add2dict(f"GALSIM_FLUX_ERR_{key}", flux_err, idx)
665-
666-
mag = gcf_data["gal_mag"][ind[0]]
667-
mag_err = gcf_data["gal_mag_err"][ind[0]]
668-
self._add2dict(f"GALSIM_MAG_{key}", mag, idx)
669-
self._add2dict(f"GALSIM_MAG_ERR_{key}", mag_err, idx)
670-
671-
flags = gcf_data["gal_flag"][ind[0]]
672-
self._add2dict(f"GALSIM_FLAGS_{key}", flags, idx)
673-
674-
res = gcf_data["gal_resolution"][ind[0]]
675-
self._add2dict(f"GALSIM_RES_{key}", res, idx)
676-
677-
galsim_cat_file.close()
678-
679543
def _save_psf_data(self, galaxy_psf_path):
680544
"""Save PSF data.
681545

src/shapepipe/modules/make_cat_runner.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ def make_cat_runner(
5555
galaxy_psf_path,
5656
shape1_cat_path,
5757
) = input_file_list[0:4]
58-
if len(input_file_list) == 5:
59-
# With second shape catalogue input
60-
shape2_cat_path = input_file_list[4]
6158

6259
# Fetch classification options
6360
do_classif = config.getboolean(
@@ -77,10 +74,8 @@ def make_cat_runner(
7774
"SHAPE_MEASUREMENT_TYPE",
7875
)
7976
for shape_type in shape_type_list:
80-
if shape_type.lower() not in ["ngmix", "galsim"]:
81-
raise ValueError(
82-
"SHAPE_MEASUREMENT_TYPE must be in [ngmix, galsim]"
83-
)
77+
if shape_type.lower() != "ngmix":
78+
raise ValueError("SHAPE_MEASUREMENT_TYPE must be [ngmix]")
8479

8580
# Fetch PSF data option
8681
if config.has_option(module_config_sec, "SAVE_PSF_DATA"):
@@ -125,10 +120,7 @@ def make_cat_runner(
125120
w_log.info("Save shape measurement data")
126121
for shape_type in shape_type_list:
127122
w_log.info(f"Save {shape_type.lower()} data")
128-
cat_path = (
129-
shape2_cat_path if shape_type == "galsim" else shape1_cat_path
130-
)
131-
err_msg = sc_inst.process(shape_type.lower(), cat_path)
123+
err_msg = sc_inst.process(shape_type.lower(), shape1_cat_path)
132124

133125

134126
# If error message: delete (incomplete) output file and raise error

0 commit comments

Comments
 (0)