Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-43402: Add option to turn off forced measurements on the science and differe… #198

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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