Skip to content

Commit

Permalink
Merge branch 'tickets/DM-24696'
Browse files Browse the repository at this point in the history
  • Loading branch information
ebellm committed Jun 12, 2020
2 parents 68ad4a0 + 29c340b commit c1420e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 66 deletions.
46 changes: 3 additions & 43 deletions python/lsst/ap/association/packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def run(self,
alerts = []
self._patchDiaSources(diaSourceCat)
self._patchDiaSources(diaSrcHistory)
self._patchDiaObjects(diaObjectCat)
ccdVisitId = diffIm.getInfo().getVisitInfo().getExposureId()
for srcIndex, diaSource in diaSourceCat.iterrows():
# Get all diaSources for the associated diaObject.
Expand Down Expand Up @@ -138,47 +137,12 @@ def _patchDiaSources(self, diaSources):
"""Add the ``programId`` column to the data and change currently
grouped alert data to ``None``.
TODO: The need to change these column values to ``None`` can be removed
after DM-24696 is merged.
Parameters
----------
diaSources : `pandas.DataFrame`
DataFrame of DiaSources to patch.
"""
diaSources["programId"] = 0
diaSources["ra_decl_Cov"] = None
diaSources["x_y_Cov"] = None
diaSources["ps_Cov"] = None
diaSources["trail_Cov"] = None
diaSources["dip_Cov"] = None
diaSources["i_cov"] = None

def _patchDiaObjects(self, diaObjects):
"""Change currently grouped alert data to ``None``.
TODO: The need to change these column values to ``None`` can be removed
after DM-24696 is merged.
Parameters
----------
diaObjects : `pandas.DataFrame`
DataFrame of DiaObjects to patch.
"""
diaObjects["ra_decl_Cov"] = None
diaObjects["pm_parallax_Cov"] = None
diaObjects["uLcPeriodic"] = None
diaObjects["gLcPeriodic"] = None
diaObjects["rLcPeriodic"] = None
diaObjects["iLcPeriodic"] = None
diaObjects["zLcPeriodic"] = None
diaObjects["yLcPeriodic"] = None
diaObjects["uLcNonPeriodic"] = None
diaObjects["gLcNonPeriodic"] = None
diaObjects["rLcNonPeriodic"] = None
diaObjects["iLcNonPeriodic"] = None
diaObjects["zLcNonPeriodic"] = None
diaObjects["yLcNonPeriodic"] = None

def createDiaSourceBBox(self, bboxSize):
"""Create a bounding box for the cutouts given the size of the square
Expand Down Expand Up @@ -218,10 +182,10 @@ def makeAlertDict(self,
DiaObject that ``diaSource`` is matched to.
objDiaSrcHistory : `pandas.DataFrame`
12 month history of ``diaObject`` excluding the latest DiaSource.
diffImCutout : `lsst.afw.image.ExposureF`
diffImCutout : `lsst.afw.image.ExposureF` or `None`
Cutout of the difference image around the location of ``diaSource``
with a size set by the ``cutoutSize`` configurable.
templateCutout : `lsst.afw.image.ExposureF`
templateCutout : `lsst.afw.image.ExposureF` or `None`
Cutout of the template image around the location of ``diaSource``
with a size set by the ``cutoutSize`` configurable.
"""
Expand All @@ -241,11 +205,7 @@ def makeAlertDict(self,

alert['ssObject'] = None

# TODO: fileName to be removed in future Avro schemas. DM-24696
alert['cutoutDifference'] = {
'fileName': '',
'stampData': self.makeCutoutBytes(diffImCutout),
}
alert['cutoutDifference'] = self.makeCutoutBytes(diffImCutout)
# TODO: add template cutouts in DM-24327
alert["cutoutTemplate"] = None

Expand Down
25 changes: 2 additions & 23 deletions tests/test_packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,27 +266,6 @@ def setUp(self):
self.diaObjects.replace(to_replace=[None], value=np.nan, inplace=True)
diaSourceHistory.replace(to_replace=[None], value=np.nan, inplace=True)
diaSourceHistory["programId"] = 0
diaSourceHistory["ra_decl_Cov"] = None
diaSourceHistory["x_y_Cov"] = None
diaSourceHistory["ps_Cov"] = None
diaSourceHistory["trail_Cov"] = None
diaSourceHistory["dip_Cov"] = None
diaSourceHistory["i_cov"] = None

self.diaObjects["ra_decl_Cov"] = None
self.diaObjects["pm_parallax_Cov"] = None
self.diaObjects["uLcPeriodic"] = None
self.diaObjects["gLcPeriodic"] = None
self.diaObjects["rLcPeriodic"] = None
self.diaObjects["iLcPeriodic"] = None
self.diaObjects["zLcPeriodic"] = None
self.diaObjects["yLcPeriodic"] = None
self.diaObjects["uLcNonPeriodic"] = None
self.diaObjects["gLcNonPeriodic"] = None
self.diaObjects["rLcNonPeriodic"] = None
self.diaObjects["iLcNonPeriodic"] = None
self.diaObjects["zLcNonPeriodic"] = None
self.diaObjects["yLcNonPeriodic"] = None

self.diaSources = diaSourceHistory.loc[
[(0, "g", 8), (1, "g", 9)], :]
Expand Down Expand Up @@ -353,7 +332,7 @@ def testMakeAlertDict(self):

self.assertEqual(alert["alertId"], alertId)
self.assertEqual(alert["diaSource"], diaSource.to_dict())
self.assertEqual(alert["cutoutDifference"]["stampData"],
self.assertEqual(alert["cutoutDifference"],
cutputBytes)
self.assertEqual(alert["cutoutTemplate"],
None)
Expand Down Expand Up @@ -395,7 +374,7 @@ def testRun(self):
cutout = self.exposure.getCutout(sphPoint,
geom.Extent2I(self.cutoutSize,
self.cutoutSize))
self.assertEqual(alert["cutoutDifference"]["stampData"],
self.assertEqual(alert["cutoutDifference"],
packageAlerts.makeCutoutBytes(cutout))

shutil.rmtree(tempdir)
Expand Down

0 comments on commit c1420e3

Please sign in to comment.