Skip to content

Commit

Permalink
Merge pull request #244 from lsst/tickets/DM-47081
Browse files Browse the repository at this point in the history
DM-47081: Skip packaging missing forced sources
  • Loading branch information
isullivan authored Oct 24, 2024
2 parents 932f300 + 27f6df3 commit b083a54
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions python/lsst/ap/association/diaForcedSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class DiaForcedSourcedConfig(pexConfig.Config):
historyThreshold = pexConfig.Field(
dtype=int,
doc="Minimum number of detections of a diaObject required "
"to run forced photometry. Set to 0 to include all diaObjects.",
default=1,
"to run forced photometry. Set to 1 to include all diaObjects.",
default=2,
)

def setDefaults(self):
Expand Down Expand Up @@ -128,7 +128,7 @@ def run(self,
difference and direct images at DiaObject locations.
"""
# Restrict forced source measurement to objects with sufficient history to be reliable.
objectTable = dia_objects.query(f'nDiaSources > {self.config.historyThreshold}')
objectTable = dia_objects.query(f'nDiaSources >= {self.config.historyThreshold}')
if objectTable.empty:
# The dataframe will be coerced to the correct (empty) format in diaPipe.
return pd.DataFrame()
Expand Down
4 changes: 3 additions & 1 deletion python/lsst/ap/association/diaPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,11 @@ def run(self,
diaForcedSources = self.runForcedMeasurement(
diaCalResult.diaObjectCat, diaCalResult.updatedDiaObjects, exposure, diffIm, idGenerator
)

forcedSourceHistoryThreshold = self.diaForcedSource.config.historyThreshold
else:
# alertPackager needs correct columns
diaForcedSources = makeEmptyForcedSourceTable(self.schema)
forcedSourceHistoryThreshold = 0

# Write results to Alert Production Database (APDB)
self.writeToApdb(diaCalResult.updatedDiaObjects, associatedDiaSources, diaForcedSources)
Expand Down Expand Up @@ -533,6 +534,7 @@ def run(self,
exposure,
template,
doRunForcedMeasurement=self.config.doRunForcedMeasurement,
forcedSourceHistoryThreshold=forcedSourceHistoryThreshold,
)

# For historical reasons, apdbMarker is a Config even if it's not meant to be read.
Expand Down
6 changes: 5 additions & 1 deletion python/lsst/ap/association/packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def run(self,
calexp,
template,
doRunForcedMeasurement=True,
forcedSourceHistoryThreshold=0,
):
"""Package DiaSources/Object and exposure data into Avro alerts.
Expand Down Expand Up @@ -246,6 +247,9 @@ def run(self,
This should only be turned off for debugging purposes.
Added to allow disabling forced sources for performance
reasons during the ops rehearsal.
forcedSourceHistoryThreshold : `int`, optional
Minimum number of detections of a diaObject required
to run forced photometry. Set to 1 to include all diaObjects.
"""
alerts = []
self._patchDiaSources(diaSourceCat)
Expand Down Expand Up @@ -276,7 +280,7 @@ def run(self,
objSourceHistory = diaSrcHistory.loc[srcIndex[0]]
else:
objSourceHistory = None
if doRunForcedMeasurement and not diaForcedSources.empty:
if doRunForcedMeasurement and diaObject["nDiaSources"] >= forcedSourceHistoryThreshold:
objDiaForcedSources = diaForcedSources.loc[srcIndex[0]]
else:
# Send empty table with correct columns
Expand Down

0 comments on commit b083a54

Please sign in to comment.