Skip to content

Commit

Permalink
Add option to disable loading diaForcedSource history
Browse files Browse the repository at this point in the history
  • Loading branch information
isullivan committed Mar 20, 2024
1 parent 5912515 commit 69c730a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
9 changes: 8 additions & 1 deletion python/lsst/ap/association/diaPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ class DiaPipelineConfig(pipeBase.PipelineTaskConfig,
target=DiaObjectCalculationTask,
doc="Task to compute summary statistics for DiaObjects.",
)
doLoadForcedSources = pexConfig.Field(
dtype=bool,
default=True,
doc="Load forced DiaSource history from the APDB?"
"This should only be turned off for debugging purposes.",
)
diaForcedSource = pexConfig.ConfigurableField(
target=DiaForcedSourceTask,
doc="Task used for force photometer DiaObject locations in direct and "
Expand Down Expand Up @@ -370,7 +376,8 @@ def run(self,
DiaSources. (`pandas.DataFrame`)
"""
# Load the DiaObjects and DiaSource history.
loaderResult = self.diaCatalogLoader.run(diffIm, self.apdb)
loaderResult = self.diaCatalogLoader.run(diffIm, self.apdb,
doLoadForcedSources=self.config.doLoadForcedSources)
if len(loaderResult.diaObjects) > 0:
diaObjects = self.purgeDiaObjects(diffIm.getBBox(), diffIm.getWcs(), loaderResult.diaObjects,
buffer=self.config.imagePixelMargin)
Expand Down
15 changes: 13 additions & 2 deletions python/lsst/ap/association/loadDiaCatalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, **kwargs):
pipeBase.Task.__init__(self, **kwargs)

@timeMethod
def run(self, exposure, apdb):
def run(self, exposure, apdb, doLoadForcedSources=True):
"""Preload all DiaObjects and DiaSources from the Apdb given the
current exposure.
Expand All @@ -66,6 +66,9 @@ def run(self, exposure, apdb):
An exposure with a bounding box.
apdb : `lsst.dax.apdb.Apdb`
AP database connection object.
doLoadForcedSources : `bool`, optional
Load forced DiaSource history from the APDB?
This should only be turned off for debugging purposes.
Returns
-------
Expand All @@ -79,6 +82,11 @@ def run(self, exposure, apdb):
exposure padded by ``pixelMargin``. DataFrame is indexed by
``diaObjectId``, ``band``, ``diaSourceId`` columns.
(`pandas.DataFrame`)
Raises
------
RuntimeError
If the Database query failed to load DiaObjects
"""
region = self._getRegion(exposure)

Expand All @@ -95,7 +103,10 @@ def run(self, exposure, apdb):

diaSources = self.loadDiaSources(diaObjects, region, dateTime, apdb)

diaForcedSources = self.loadDiaForcedSources(diaObjects, region, dateTime, apdb)
if doLoadForcedSources:
diaForcedSources = self.loadDiaForcedSources(diaObjects, region, dateTime, apdb)
else:
diaForcedSources = pd.DataFrame(columns=["diaObjectId", "diaForcedSourceId"])

return pipeBase.Struct(
diaObjects=diaObjects,
Expand Down

0 comments on commit 69c730a

Please sign in to comment.