Skip to content

Commit

Permalink
Pad detector footprint more conservatively.
Browse files Browse the repository at this point in the history
A ConvexPolygon is now padded into a slightly larger ConvexPolygon,
instead of a bounding circle. This should reduce the load size to
~64% of the previous solution.
  • Loading branch information
kfindeisen committed Sep 6, 2024
1 parent 2391bbe commit 82b0bd9
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions python/lsst/ap/association/loadDiaCatalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@

"""Task for pre-loading DiaSources and DiaObjects within ap_pipe.
"""

import math

import pandas as pd

import lsst.dax.apdb as daxApdb
import lsst.geom
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
import lsst.pipe.base.connectionTypes as connTypes
Expand Down Expand Up @@ -183,9 +187,21 @@ def _paddedRegion(region, margin):
padded : `lsst.sphgeom.Region`
An enlarged copy of ``region``.
"""
circle = region.getBoundingCircle()
circle.dilateBy(margin)
return circle
# region is almost certainly a (padded) detector bounding box.
if isinstance(region, lsst.sphgeom.ConvexPolygon):
# This is an ad-hoc, approximate implementation. It should be good
# enough for catalog loading, but is not a general-purpose solution.
center = lsst.geom.SpherePoint(region.getCentroid())
corners = [lsst.geom.SpherePoint(c) for c in region.getVertices()]
# Approximate the region as a Euclidian square
# geom.Angle(sphgeom.Angle) converter not pybind-wrapped???
diagonal_margin = lsst.geom.Angle(margin.asRadians() * math.sqrt(2.0))
padded = [c.offset(center.bearingTo(c), diagonal_margin) for c in corners]
return lsst.sphgeom.ConvexPolygon.convexHull([c.getVector() for c in padded])
elif hasattr(region, "dilatedBy"):
return region.dilatedBy(margin)
else:
return region.getBoundingCircle().dilatedBy(margin)

@timeMethod
def loadDiaObjects(self, region, schema):
Expand Down

0 comments on commit 82b0bd9

Please sign in to comment.