Skip to content

Commit

Permalink
Merge branch 'tickets/DM-43402'
Browse files Browse the repository at this point in the history
  • Loading branch information
kfindeisen committed Mar 20, 2024
2 parents c42df01 + fdfa9b3 commit 6179bb6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 15 deletions.
49 changes: 35 additions & 14 deletions python/lsst/ap/association/diaPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def __init__(self, *, config=None):
self.outputs.remove("associatedDiaSources")
self.outputs.remove("diaForcedSources")
self.outputs.remove("diaObjects")
elif not config.doRunForcedMeasurement:
self.outputs.remove("diaForcedSources")
if not config.doSolarSystemAssociation:
self.inputs.remove("solarSystemObjectTable")
if not config.associator.doTrailedSourceFilter:
Expand Down Expand Up @@ -247,10 +249,19 @@ class DiaPipelineConfig(pipeBase.PipelineTaskConfig,
doLoadForcedSources = pexConfig.Field(
dtype=bool,
default=True,
deprecated="Added to allow disabling forced sources for performance"
"reasons during the ops rehearsal."
" It is expected to be removed.",
doc="Load forced DiaSource history from the APDB?"
deprecated="Added to allow disabling forced sources for performance "
"reasons during the ops rehearsal. "
"It is expected to be removed.",
doc="Load forced DiaSource history from the APDB? "
"This should only be turned off for debugging purposes.",
)
doRunForcedMeasurement = pexConfig.Field(
dtype=bool,
default=True,
deprecated="Added to allow disabling forced sources for performance "
"reasons during the ops rehearsal. "
"It is expected to be removed.",
doc="Run forced measurement on all of the diaObjects? "
"This should only be turned off for debugging purposes.",
)
diaForcedSource = pexConfig.ConfigurableField(
Expand Down Expand Up @@ -317,7 +328,8 @@ def __init__(self, initInputs=None, **kwargs):
self.makeSubtask("diaCatalogLoader")
self.makeSubtask("associator")
self.makeSubtask("diaCalculation")
self.makeSubtask("diaForcedSource")
if self.config.doRunForcedMeasurement:
self.makeSubtask("diaForcedSource")
if self.config.doPackageAlerts:
self.makeSubtask("alertPackager")
if self.config.doSolarSystemAssociation:
Expand Down Expand Up @@ -498,14 +510,21 @@ def run(self,
"DiaCalculation. This is unexpected behavior and should be "
"reported. Exiting.")

# Force photometer on the Difference and Calibrated exposures using
# the new and updated DiaObject locations.
diaForcedSources = self.diaForcedSource.run(
diaCalResult.diaObjectCat,
diaCalResult.updatedDiaObjects.loc[:, "diaObjectId"].to_numpy(),
exposure,
diffIm,
idGenerator=idGenerator)
if self.config.doRunForcedMeasurement:
# Force photometer on the Difference and Calibrated exposures using
# the new and updated DiaObject locations.
diaForcedSources = self.diaForcedSource.run(
diaCalResult.diaObjectCat,
diaCalResult.updatedDiaObjects.loc[:, "diaObjectId"].to_numpy(),
exposure,
diffIm,
idGenerator=idGenerator)
else:
# alertPackager needs correct columns
diaForcedSources = pd.DataFrame(columns=[
"diaForcedSourceId", "diaObjectID", "ccdVisitID", "psfFlux", "psfFluxErr",
"x", "y", "flags", "midpointMjdTai", "band",
])

# Store DiaSources, updated DiaObjects, and DiaForcedSources in the
# Apdb.
Expand Down Expand Up @@ -557,7 +576,9 @@ def run(self,
diaForcedSources,
diffIm,
exposure,
template)
template,
doRunForcedMeasurement=self.config.doRunForcedMeasurement,
)

return pipeBase.Struct(apdbMarker=self.config.apdb.value,
associatedDiaSources=associatedDiaSources,
Expand Down
12 changes: 11 additions & 1 deletion python/lsst/ap/association/packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def run(self,
diffIm,
calexp,
template,
doRunForcedMeasurement=True,
):
"""Package DiaSources/Object and exposure data into Avro alerts.
Expand Down Expand Up @@ -177,6 +178,11 @@ def run(self,
Calexp used to create the ``diffIm``.
template : `lsst.afw.image.ExposureF` or `None`
Template image used to create the ``diffIm``.
doRunForcedMeasurement : `bool`, optional
Flag to indicate whether forced measurement was run.
This should only be turned off for debugging purposes.
Added to allow disabling forced sources for performance
reasons during the ops rehearsal.
"""
alerts = []
self._patchDiaSources(diaSourceCat)
Expand All @@ -196,7 +202,11 @@ def run(self,
objSourceHistory = diaSrcHistory.loc[srcIndex[0]]
else:
objSourceHistory = None
objDiaForcedSources = diaForcedSources.loc[srcIndex[0]]
if doRunForcedMeasurement:
objDiaForcedSources = diaForcedSources.loc[srcIndex[0]]
else:
# Send empty table with correct columns
objDiaForcedSources = diaForcedSources.loc[[]]
sphPoint = geom.SpherePoint(diaSource["ra"],
diaSource["dec"],
geom.degrees)
Expand Down

0 comments on commit 6179bb6

Please sign in to comment.