diff --git a/python/lsst/ip/diffim/computeSpatiallySampledMetrics.py b/python/lsst/ip/diffim/computeSpatiallySampledMetrics.py index 804f8274..cddec0af 100644 --- a/python/lsst/ip/diffim/computeSpatiallySampledMetrics.py +++ b/python/lsst/ip/diffim/computeSpatiallySampledMetrics.py @@ -48,12 +48,6 @@ class SpatiallySampledMetricsConnections(pipeBase.PipelineTaskConnections, storageClass="ExposureF", name="{fakesType}calexp" ) - matchedTemplate = pipeBase.connectionTypes.Input( - doc="Warped and PSF-matched template used to create the difference image.", - dimensions=("instrument", "visit", "detector"), - storageClass="ExposureF", - name="{fakesType}{coaddName}Diff_matchedExp", - ) template = pipeBase.connectionTypes.Input( doc="Warped and not PSF-matched template used to create the difference image.", dimensions=("instrument", "visit", "detector"), @@ -69,8 +63,8 @@ class SpatiallySampledMetricsConnections(pipeBase.PipelineTaskConnections, diaSources = pipeBase.connectionTypes.Input( doc="Filtered diaSources on the difference image.", dimensions=("instrument", "visit", "detector"), - storageClass="SourceCatalog", - name="{fakesType}{coaddName}Diff_candidateDiaSrc", + storageClass="ArrowAstropy", + name="{fakesType}dia_source_detector", ) psfMatchingKernel = pipeBase.connectionTypes.Input( doc="Kernel used to PSF match the science and template images.", @@ -195,16 +189,13 @@ def __init__(self, **kwargs): units="radian") @timeMethod - def run(self, science, matchedTemplate, template, difference, diaSources, psfMatchingKernel): + def run(self, science, template, difference, diaSources, psfMatchingKernel): """Calculate difference image metrics on specific locations across the images Parameters ---------- science : `lsst.afw.image.ExposureF` Science exposure that the template was subtracted from. - matchedTemplate : `lsst.afw.image.ExposureF` - Warped and PSF-matched template that was used produce the - difference image. template : `lsst.afw.image.ExposureF` Warped and non PSF-matched template that was used produce the difference image. @@ -237,13 +228,13 @@ def run(self, science, matchedTemplate, template, difference, diaSources, psfMat self.log.info("Unable to calculate metrics for mask plane %s: not in image"%maskPlane) for src in spatiallySampledMetrics: - self._evaluateLocalMetric(src, science, matchedTemplate, template, difference, diaSources, + self._evaluateLocalMetric(src, science, template, difference, diaSources, metricsMaskPlanes=metricsMaskPlanes, psfMatchingKernel=psfMatchingKernel) return pipeBase.Struct(spatiallySampledMetrics=spatiallySampledMetrics.asAstropy()) - def _evaluateLocalMetric(self, src, science, matchedTemplate, template, difference, diaSources, + def _evaluateLocalMetric(self, src, science, template, difference, diaSources, metricsMaskPlanes, psfMatchingKernel): """Calculate image quality metrics at spatially sampled locations. @@ -255,8 +246,6 @@ def _evaluateLocalMetric(self, src, science, matchedTemplate, template, differen The catalog of detected sources. science : `lsst.afw.image.Exposure` The science image. - matchedTemplate : `lsst.afw.image.Exposure` - The reference image, warped and psf-matched to the science image. difference : `lsst.afw.image.Exposure` Result of subtracting template from the science image. metricsMaskPlanes : `list` of `str` @@ -282,18 +271,18 @@ def _evaluateLocalMetric(self, src, science, matchedTemplate, template, differen src.set('x', peak['i_x']) src.set('y', peak['i_y']) src.setCoord(science.wcs.pixelToSky(peak['i_x'], peak['i_y'])) - selectSources = diaSources[bbox.contains(diaSources.getX(), diaSources.getY())] + selectSources = diaSources[bbox.contains(diaSources['x'], diaSources['y'])] sourceDensity = len(selectSources)/area - dipoleSources = selectSources[selectSources["ip_diffim_DipoleFit_classification"]] + dipoleSources = selectSources[selectSources["isDipole"]] dipoleDensity = len(dipoleSources)/area if dipoleSources: - meanDipoleOrientation = angleMean(dipoleSources["ip_diffim_DipoleFit_orientation"]) + meanDipoleOrientation = angleMean(dipoleSources["dipoleAngle"]) src.set('dipole_direction', meanDipoleOrientation) - meanDipoleSeparation = np.mean(dipoleSources["ip_diffim_DipoleFit_separation"]) + meanDipoleSeparation = np.mean(dipoleSources["dipoleLength"]) src.set('dipole_separation', meanDipoleSeparation) - templateVal = np.median(matchedTemplate[bbox].image.array) + templateVal = np.median(template[bbox].image.array) scienceVal = np.median(science[bbox].image.array) diffimVal = np.median(difference[bbox].image.array) src.set('source_density', sourceDensity)