Skip to content

Commit

Permalink
Respond to reviewer.
Browse files Browse the repository at this point in the history
Fix up docs.
Change output and name to _trimToPatch.

Fix name of diaObjectTable in output struct.

Fix linting.

Fix typo.

Fix typo in DRP yaml output name.

Remove merge text.
  • Loading branch information
morriscb committed May 28, 2021
1 parent c54e253 commit 0b8c844
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 33 deletions.
5 changes: 1 addition & 4 deletions pipelines/DRP.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ tasks:
connections.coaddName: goodSeeing
connections.diaSourceTables: goodSeeingDiff_diaSrcTable
connections.assocDiaSourceTable: goodSeeingDiff_assocDiaSrcTable
connections.diaDiaObjectTable: goodSeeingDiff_diaObjTable
connections.diaObjectTable: goodSeeingDiff_diaObjTable
forcedPhotDiffim:
class: lsst.meas.base.ForcedPhotCcdTask
config:
Expand Down Expand Up @@ -180,8 +180,5 @@ contracts:
- templateGen.connections.coaddExposure == imageDifference.connections.coaddExposures
- imageDifference.connections.subtractedExposure == transformDiaSourceCat.connections.diffIm
- imageDifference.connections.subtractedExposure == forcedPhotDiffim.connections.exposure
<<<<<<< HEAD
- transformDiaSourceCat.connections.diaSourceTable == consolidateDiaSourceTable.connections.inputCatalogs
=======
- transformDiaSourceCat.connections.diaSourceTable == drpAssociation.connections.diaSourceTables
>>>>>>> 4fe93738 (Add DiaAssociationPipe to DRP.yaml)
46 changes: 23 additions & 23 deletions python/lsst/pipe/tasks/drpAssociationPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
import pandas as pd

import lsst.geom as geom
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
from .coaddBase import makeSkyInfo
from lsst.skymap import BaseSkyMap

from .coaddBase import makeSkyInfo

__all__ = ["DrpAssociationPipeTask",
"DrpAssociationPipeConfig",
"DrpAssociationPipeConnections"]
Expand All @@ -43,7 +43,7 @@ class DrpAssociationPipeConnections(pipeBase.PipelineTaskConnections,
"warpTypeSuffix": "",
"fakesType": ""}):
diaSourceTables = pipeBase.connectionTypes.Input(
doc="Catalog of calibrated DiaSources.",
doc="Set of catalogs of calibrated DiaSources.",
name="{fakesType}{coaddName}Diff_diaSrcTable",
storageClass="DataFrame",
dimensions=("instrument", "visit", "detector"),
Expand All @@ -64,8 +64,9 @@ class DrpAssociationPipeConnections(pipeBase.PipelineTaskConnections,
storageClass="DataFrame",
dimensions=("tract", "patch"),
)
diaDiaObjectTable = pipeBase.connectionTypes.Output(
doc="Catalog of associated DiaSources into DiaObjects.",
diaObjectTable = pipeBase.connectionTypes.Output(
doc="Catalog of DiaObjects created from spatially associating "
"DiaSources.",
name="{fakesType}{coaddName}Diff_diaObjTable",
storageClass="DataFrame",
dimensions=("tract", "patch"),
Expand Down Expand Up @@ -98,7 +99,7 @@ def run(self, diaSourceTables, skyMap, tractId, patchId):
"""Trim DiaSources to the current Patch and run association.
Takes in the set of DiaSource catalogs that covers the current patch,
trims to them to the dimensions of the patch, and [TODO: eventually]
trims them to the dimensions of the patch, and [TODO: eventually]
runs association on the concatenated DiaSource Catalog.
Parameters
Expand All @@ -120,7 +121,7 @@ def run(self, diaSourceTables, skyMap, tractId, patchId):
``assocDiaSourceTable``
Table of DiaSources with updated value for diaObjectId.
(`pandas.DataFrame`)
``diaDiaObjectTable``
``diaObjectTable``
Table of DiaObjects from matching DiaSources
(`pandas.DataFrame`).
"""
Expand All @@ -138,10 +139,9 @@ def run(self, diaSourceTables, skyMap, tractId, patchId):
datasetType=self.config.connections.diaSourceTables,
immediate=True)

patchGen = self._trimToPatchGen(cat,
innerPatchBox,
skyInfo.wcs)
isInTractPatch = np.array(list(patchGen))
isInTractPatch = self._trimToPatch(cat,
innerPatchBox,
skyInfo.wcs)

nDiaSrc = isInTractPatch.sum()
self.log.info(
Expand All @@ -165,11 +165,11 @@ def run(self, diaSourceTables, skyMap, tractId, patchId):
% (len(diaSourceHistoryCat), patchId, tractId))

return pipeBase.Struct(
diaDiaObjectTable=pd.DataFrame(columns=["diaObjectId",
"nDiaSources"]),
diaObjectTable=pd.DataFrame(columns=["diaObjectId",
"nDiaSources"]),
assocDiaSourceTable=diaSourceHistoryCat)

def _trimToPatchGen(self, cat, innerPatchBox, wcs):
def _trimToPatch(self, cat, innerPatchBox, wcs):
"""Create generator testing if a set of DiaSources are in the
patch/tract.
Expand All @@ -181,16 +181,16 @@ def _trimToPatchGen(self, cat, innerPatchBox, wcs):
Bounding box of the patch.
wcs : `lsst.geom.SkyWcs`
Wcs of the tract.
skyMap : ``
SkyMap containing the patch and tract.
Yields
Returns
------
isInTractPatch : `bool`
Boolean representing if the DiaSource is contained within the
isInPatch : `numpy.ndarray`, (N,)
Booleans representing if the DiaSources are contained within the
current patch and tract.
"""
for idx, row in cat.iterrows():
sphPoint = geom.SpherePoint(row["ra"], row["decl"], geom.degrees)
inPatch = innerPatchBox.contains(wcs.skyToPixel(sphPoint))
yield inPatch
isInPatch = np.array([
innerPatchBox.contains(
wcs.skyToPixel(
geom.SpherePoint(row["ra"], row["decl"], geom.degrees)))
for idx, row in cat.iterrows()])
return isInPatch
12 changes: 6 additions & 6 deletions tests/test_drpAssociationPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def testTrimToPatch(self):
dpaTask = DrpAssociationPipeTask()

self.assertEqual(
np.sum(list(dpaTask._trimToPatchGen(self.diaSrcCatIn,
self.innerPatchBox,
self.skyInfo.wcs))),
np.sum(dpaTask._trimToPatch(self.diaSrcCatIn,
self.innerPatchBox,
self.skyInfo.wcs)),
self.nSources)

self.assertEqual(
np.sum(list(dpaTask._trimToPatchGen(self.diaSrcCatOut,
self.innerPatchBox,
self.skyInfo.wcs))),
np.sum(dpaTask._trimToPatch(self.diaSrcCatOut,
self.innerPatchBox,
self.skyInfo.wcs)),
0)


Expand Down

0 comments on commit 0b8c844

Please sign in to comment.