Skip to content

Commit

Permalink
add science cutout to alert packet
Browse files Browse the repository at this point in the history
  • Loading branch information
ebellm committed Mar 19, 2024
1 parent 5912515 commit d13cb9c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions python/lsst/ap/association/diaPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ def run(self,
loaderResult.diaSources,
diaForcedSources,
diffIm,
exposure,
template)

return pipeBase.Struct(apdbMarker=self.config.apdb.value,
Expand Down
20 changes: 20 additions & 0 deletions python/lsst/ap/association/packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def run(self,
diaSrcHistory,
diaForcedSources,
diffIm,
calexp,
template,
):
"""Package DiaSources/Object and exposure data into Avro alerts.
Expand Down Expand Up @@ -172,6 +173,8 @@ def run(self,
``["diaObjectId"]``
diffIm : `lsst.afw.image.ExposureF`
Difference image the sources in ``diaSourceCat`` were detected in.
calexp : `lsst.afw.image.ExposureF`
Calexp used to create the ``diffIm``.
template : `lsst.afw.image.ExposureF` or `None`
Template image used to create the ``diffIm``.
"""
Expand All @@ -180,6 +183,7 @@ def run(self,
self._patchDiaSources(diaSrcHistory)
ccdVisitId = diffIm.info.id
diffImPhotoCalib = diffIm.getPhotoCalib()
calexpPhotoCalib = calexp.getPhotoCalib()
templatePhotoCalib = template.getPhotoCalib()
for srcIndex, diaSource in diaSourceCat.iterrows():
# Get all diaSources for the associated diaObject.
Expand All @@ -204,6 +208,12 @@ def run(self,
cutoutExtent,
diffImPhotoCalib,
diaSource["diaSourceId"])
calexpCutout = self.createCcdDataCutout(
calexp,
sphPoint,
cutoutExtent,
calexpPhotoCalib,
diaSource["diaSourceId"])
templateCutout = self.createCcdDataCutout(
template,
sphPoint,
Expand All @@ -220,6 +230,7 @@ def run(self,
objSourceHistory,
objDiaForcedSources,
diffImCutout,
calexpCutout,
templateCutout))

if self.config.doProduceAlerts:
Expand Down Expand Up @@ -398,6 +409,7 @@ def makeAlertDict(self,
objDiaSrcHistory,
objDiaForcedSources,
diffImCutout,
calexpCutout,
templateCutout):
"""Convert data and package into a dictionary alert.
Expand All @@ -414,6 +426,9 @@ def makeAlertDict(self,
diffImCutout : `astropy.nddata.CCDData` or `None`
Cutout of the difference image around the location of ``diaSource``
with a min size set by the ``cutoutSize`` configurable.
calexpCutout : `astropy.nddata.CCDData` or `None`
Cutout of the calexp around the location of ``diaSource``
with a min size set by the ``cutoutSize`` configurable.
templateCutout : `astropy.nddata.CCDData` or `None`
Cutout of the template image around the location of ``diaSource``
with a min size set by the ``cutoutSize`` configurable.
Expand Down Expand Up @@ -442,6 +457,11 @@ def makeAlertDict(self,
else:
alert['cutoutDifference'] = self.streamCcdDataToBytes(diffImCutout)

if calexpCutout is None:
alert['cutoutScience'] = None
else:
alert['cutoutScience'] = self.streamCcdDataToBytes(calexpCutout)

if templateCutout is None:
alert["cutoutTemplate"] = None
else:
Expand Down
6 changes: 5 additions & 1 deletion tests/test_packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,16 @@ def testMakeAlertDict(self):
objSources,
objForcedSources,
ccdCutout,
ccdCutout,
ccdCutout)
self.assertEqual(len(alert), 9)
self.assertEqual(len(alert), 10)

self.assertEqual(alert["alertId"], alertId)
self.assertEqual(alert["diaSource"], diaSource.to_dict())
self.assertEqual(alert["cutoutDifference"],
cutoutBytes)
self.assertEqual(alert["cutoutScience"],
cutoutBytes)
self.assertEqual(alert["cutoutTemplate"],
cutoutBytes)

Expand Down Expand Up @@ -471,6 +474,7 @@ def testRun_without_produce(self):
self.diaSourceHistory,
self.diaForcedSources,
self.exposure,
self.exposure,
self.exposure)

ccdVisitId = self.exposure.info.id
Expand Down

0 comments on commit d13cb9c

Please sign in to comment.