From e002052f63124ecbc0ef3b8e7a78b14a6d8c95cb Mon Sep 17 00:00:00 2001 From: Lauren MacArthur Date: Mon, 16 Feb 2026 15:16:42 -0800 Subject: [PATCH] Add option to pass WCS into loadRegion This is to allow for columns to be added to the returned reference catalog that include the pixel centroid positions associated with this WCS for the sky positions of the reference objects. --- .../meas/algorithms/loadReferenceObjects.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/python/lsst/meas/algorithms/loadReferenceObjects.py b/python/lsst/meas/algorithms/loadReferenceObjects.py index b65c0f57e..2d78428c1 100644 --- a/python/lsst/meas/algorithms/loadReferenceObjects.py +++ b/python/lsst/meas/algorithms/loadReferenceObjects.py @@ -623,7 +623,7 @@ def _filterFunction(refCat, region): return filteredRefCat return self.loadRegion(outerSkyRegion, filterName, filtFunc=_filterFunction, epoch=epoch) - def loadRegion(self, region, filterName, filtFunc=None, epoch=None): + def loadRegion(self, region, filterName, filtFunc=None, epoch=None, wcsForCentroids=None): """Load reference objects within a specified region. This function loads the DataIds used to construct an instance of this @@ -651,6 +651,9 @@ class which intersect or are contained within the specified region. The epoch : `astropy.time.Time` or `None`, optional Epoch to which to correct proper motion and parallax, or `None` to not apply such corrections. + wcsForCentroids : `lsst.afw.geom.SkyWcs`, optional + If provided, this WCS will be used to convert the reference catalog + sky coordinates to pixel positions. Returns ------- @@ -747,9 +750,20 @@ class which intersect or are contained within the specified region. The self.applyProperMotions(refCat, epoch) - expandedCat = self._remapReferenceCatalogSchema(refCat, - anyFilterMapsToThis=self.config.anyFilterMapsToThis, - filterMap=self.config.filterMap) + if wcsForCentroids is not None: + expandedCat = self._remapReferenceCatalogSchema( + refCat, + anyFilterMapsToThis=self.config.anyFilterMapsToThis, + filterMap=self.config.filterMap, + centroids=True, + ) + afwTable.updateRefCentroids(wcsForCentroids, expandedCat) + else: + expandedCat = self._remapReferenceCatalogSchema( + refCat, + anyFilterMapsToThis=self.config.anyFilterMapsToThis, + filterMap=self.config.filterMap, + ) # Ensure that the returned reference catalog is continuous in memory if not expandedCat.isContiguous():