Skip to content

Commit

Permalink
Respond to review.
Browse files Browse the repository at this point in the history
Change new dia object creation behavior.

Remove superfluous log statement.
  • Loading branch information
morriscb committed Oct 8, 2021
1 parent d5c29e9 commit 2d97f39
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
21 changes: 9 additions & 12 deletions python/lsst/ap/association/diaPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class DiaPipelineConfig(pipeBase.PipelineTaskConfig,
doSolarSystemAssociation = pexConfig.Field(
dtype=bool,
default=False,
doc="",
doc="Process SolarSystem objects through the pipeline.",
)
solarSystemAssociator = pexConfig.ConfigurableField(
target=SolarSystemAssociationTask,
Expand Down Expand Up @@ -499,19 +499,16 @@ def createNewDiaObjects(self, unAssocDiaSources):
unassociated DiaSources. (`pandas.DataFrame`)
- ``nNewDiaObjects`` : Number of newly created diaObjects.(`int`)
"""
newDiaObjectsList = []
for idx, diaSource in unAssocDiaSources.iterrows():
newDiaObjectsList.append(
self._initialize_dia_object(diaSource["diaSourceId"]))
unAssocDiaSources.loc[idx, "diaObjectId"] = diaSource["diaSourceId"]
if len(newDiaObjectsList) > 0:
newDiaObjects = pd.DataFrame(data=newDiaObjectsList)
else:
if len(unAssocDiaSources) == 0:
tmpObj = self._initialize_dia_object(0)
newDiaObjects = pd.DataFrame(data=newDiaObjectsList,
newDiaObjects = pd.DataFrame(data=[],
columns=tmpObj.keys())
else:
newDiaObjects = unAssocDiaSources["diaSourceId"].apply(
self._initialize_dia_object)
unAssocDiaSources["diaObjectId"] = unAssocDiaSources["diaSourceId"]
return pipeBase.Struct(diaSources=unAssocDiaSources,
newDiaObjects=pd.DataFrame(data=newDiaObjects),
newDiaObjects=newDiaObjects,
nNewDiaObjects=len(newDiaObjects))

def _initialize_dia_object(self, objId):
Expand Down Expand Up @@ -550,7 +547,7 @@ def _initialize_dia_object(self, objId):
"flags": 0}
for f in ["u", "g", "r", "i", "z", "y"]:
new_dia_object["%sPSFluxNdata" % f] = 0
return new_dia_object
return pd.Series(data=new_dia_object)

def testDataFrameIndex(self, df):
"""Test the sorted DataFrame index for duplicates.
Expand Down
1 change: 0 additions & 1 deletion python/lsst/ap/association/skyBotEphemerisQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def run(self, visitInfos, visit):

# Midpoint time of the exposure in MJD
expMidPointEPOCH = visitInfo.date.get(system=DateTime.JD)
self.log.info(f"Exposure midpoint: {expMidPointEPOCH}")

# Boresight of the exposure on sky.
expCenter = visitInfo.boresightRaDec
Expand Down
9 changes: 5 additions & 4 deletions tests/test_diaPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,22 @@ def tearDown(self):
def testRun(self):
"""Test running while creating and packaging alerts.
"""
self._testRun(True, True)
self._testRun(doPackageAlerts=True, doSolarSystemAssociation=True)

def testRunWithSolarSystemAssociation(self):
"""Test running while creating and packaging alerts.
"""
self._testRun(False, True)
self._testRun(doPackageAlerts=False, doSolarSystemAssociation=True)

def testRunWithAlerts(self):
"""Test running while creating and packaging alerts.
"""
self._testRun(True, False)
self._testRun(doPackageAlerts=True, doSolarSystemAssociation=False)

def testRunWithoutAlertsOrSolarSystem(self):
"""Test running without creating and packaging alerts.
"""
self._testRun(False, False)
self._testRun(doPackageAlerts=False, doSolarSystemAssociation=False)

def _testRun(self, doPackageAlerts=False, doSolarSystemAssociation=False):
"""Test the normal workflow of each ap_pipe step.
Expand Down Expand Up @@ -120,6 +120,7 @@ def concatMock(data):
with patch('lsst.ap.association.diaPipe.pd.concat',
new=concatMock):
result = task.run(diaSrc,
ssObjects,
diffIm,
exposure,
template,
Expand Down

0 comments on commit 2d97f39

Please sign in to comment.