From b830df3dfd2631b500c29fe2237c9f62463e5574 Mon Sep 17 00:00:00 2001 From: Eric Bellm Date: Tue, 15 Jul 2025 12:03:18 -0700 Subject: [PATCH] Revert "Merge pull request #412 from lsst/tickets/DM-51228" This reverts commit 6c75a56628a410d164480ec06304ad4a9c83b953, reversing changes made to 5e1b9f9e8cdc06e71932d1597421bd24ea25bd57. --- python/lsst/ip/diffim/detectAndMeasure.py | 57 ++++++----------------- tests/test_detectAndMeasure.py | 6 +-- 2 files changed, 15 insertions(+), 48 deletions(-) diff --git a/python/lsst/ip/diffim/detectAndMeasure.py b/python/lsst/ip/diffim/detectAndMeasure.py index 1727aab1a..bcba5a2c7 100644 --- a/python/lsst/ip/diffim/detectAndMeasure.py +++ b/python/lsst/ip/diffim/detectAndMeasure.py @@ -420,28 +420,6 @@ def __init__(self, **kwargs): self.schema.addField( "ip_diffim_forced_PsfFlux_flag_edge", "Flag", "Forced PSF flux object was too close to the edge of the image to use the full PSF model.") - self.schema.addField( - "ip_diffim_forced_template_PsfFlux_instFlux", "D", - "Forced PSF flux measured on the template image.", - units="count") - self.schema.addField( - "ip_diffim_forced_template_PsfFlux_instFluxErr", "D", - "Forced PSF flux error measured on the template image.", - units="count") - self.schema.addField( - "ip_diffim_forced_template_PsfFlux_area", "F", - "Forced template PSF flux effective area of PSF.", - units="pixel") - self.schema.addField( - "ip_diffim_forced_template_PsfFlux_flag", "Flag", - "Forced template PSF flux general failure flag.") - self.schema.addField( - "ip_diffim_forced_template_PsfFlux_flag_noGoodPixels", "Flag", - "Forced template PSF flux not enough non-rejected pixels in data to attempt the fit.") - self.schema.addField( - "ip_diffim_forced_template_PsfFlux_flag_edge", "Flag", - """Forced template PSF flux object was too close to the edge of the image """ - """to use the full PSF model.""") self.makeSubtask("forcedMeasurement", refSchema=self.schema) self.schema.addField("refMatchId", "L", "unique id of reference catalog match") @@ -716,8 +694,6 @@ def processResults(self, science, matchedTemplate, difference, sources, idFactor if self.config.doForcedMeasurement: self.measureForcedSources(diaSources, science, difference.getWcs()) - self.measureForcedSources(diaSources, matchedTemplate, difference.getWcs(), - template=True) measurementResults.subtractedMeasuredExposure = difference @@ -881,42 +857,35 @@ def measureDiaSources(self, diaSources, science, difference, matchedTemplate): apCorrMap=apCorrMap, ) - def measureForcedSources(self, diaSources, image, wcs, template=False): - """Perform forced measurement of the diaSources on a direct image. + def measureForcedSources(self, diaSources, science, wcs): + """Perform forced measurement of the diaSources on the science image. Parameters ---------- diaSources : `lsst.afw.table.SourceCatalog` The catalog of detected sources. - image: `lsst.afw.image.ExposureF` - Exposure that the forced measurement is being performed on + science : `lsst.afw.image.ExposureF` + Science exposure that the template was subtracted from. wcs : `lsst.afw.geom.SkyWcs` Coordinate system definition (wcs) for the exposure. - template : `bool` - Is the forced measurement being performed on the template? """ - # Run forced psf photometry on the image at the diaSource locations. + # Run forced psf photometry on the PVI at the diaSource locations. # Copy the measured flux and error into the diaSource. - forcedSources = self.forcedMeasurement.generateMeasCat(image, diaSources, wcs) - self.forcedMeasurement.run(forcedSources, image, diaSources, wcs) - - if template: - base_key = 'ip_diffim_forced_template_PsfFlux' - else: - base_key = 'ip_diffim_forced_PsfFlux' + forcedSources = self.forcedMeasurement.generateMeasCat(science, diaSources, wcs) + self.forcedMeasurement.run(forcedSources, science, diaSources, wcs) mapper = afwTable.SchemaMapper(forcedSources.schema, diaSources.schema) mapper.addMapping(forcedSources.schema.find("base_PsfFlux_instFlux")[0], - f"{base_key}_instFlux", True) + "ip_diffim_forced_PsfFlux_instFlux", True) mapper.addMapping(forcedSources.schema.find("base_PsfFlux_instFluxErr")[0], - f"{base_key}_instFluxErr", True) + "ip_diffim_forced_PsfFlux_instFluxErr", True) mapper.addMapping(forcedSources.schema.find("base_PsfFlux_area")[0], - f"{base_key}_area", True) + "ip_diffim_forced_PsfFlux_area", True) mapper.addMapping(forcedSources.schema.find("base_PsfFlux_flag")[0], - f"{base_key}_flag", True) + "ip_diffim_forced_PsfFlux_flag", True) mapper.addMapping(forcedSources.schema.find("base_PsfFlux_flag_noGoodPixels")[0], - f"{base_key}_flag_noGoodPixels", True) + "ip_diffim_forced_PsfFlux_flag_noGoodPixels", True) mapper.addMapping(forcedSources.schema.find("base_PsfFlux_flag_edge")[0], - f"{base_key}_flag_edge", True) + "ip_diffim_forced_PsfFlux_flag_edge", True) for diaSource, forcedSource in zip(diaSources, forcedSources): diaSource.assign(forcedSource, mapper) diff --git a/tests/test_detectAndMeasure.py b/tests/test_detectAndMeasure.py index fa01c76ea..43af77ff1 100644 --- a/tests/test_detectAndMeasure.py +++ b/tests/test_detectAndMeasure.py @@ -211,8 +211,7 @@ def test_raise_bad_psf(self): def test_measurements_finite(self): """Measured fluxes and centroids should always be finite. """ - columnNames = ["coord_ra", "coord_dec", "ip_diffim_forced_PsfFlux_instFlux", - "ip_diffim_forced_template_PsfFlux_instFlux"] + columnNames = ["coord_ra", "coord_dec", "ip_diffim_forced_PsfFlux_instFlux"] # Set up the simulated images noiseLevel = 1. @@ -756,8 +755,7 @@ def test_detection_xy0(self): def test_measurements_finite(self): """Measured fluxes and centroids should always be finite. """ - columnNames = ["coord_ra", "coord_dec", "ip_diffim_forced_PsfFlux_instFlux", - "ip_diffim_forced_template_PsfFlux_instFlux"] + columnNames = ["coord_ra", "coord_dec", "ip_diffim_forced_PsfFlux_instFlux"] # Set up the simulated images noiseLevel = 1.