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-33010: Modernize CreateRandomApFakesTask config use #97

Merged
merged 2 commits into from
Dec 18, 2021
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
22 changes: 10 additions & 12 deletions python/lsst/ap/pipe/createApFakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,14 @@ def run(self, tractId, skyMap):
**self.createRandomPositions(nFakes, tractBoundingCircle, rng),
**self.createVisitCoaddSubdivision(nFakes),
**self.createRandomMagnitudes(nFakes, rng),
self.config.diskHLR: np.ones(nFakes, dtype="float"),
self.config.bulgeHLR: np.ones(nFakes, dtype="float"),
self.config.nDisk: np.ones(nFakes, dtype="float"),
self.config.nBulge: np.ones(nFakes, dtype="float"),
self.config.aDisk: np.ones(nFakes, dtype="float"),
self.config.aBulge: np.ones(nFakes, dtype="float"),
self.config.bDisk: np.ones(nFakes, dtype="float"),
self.config.bBulge: np.ones(nFakes, dtype="float"),
self.config.paDisk: np.ones(nFakes, dtype="float"),
self.config.paBulge: np.ones(nFakes, dtype="float"),
self.config.disk_semimajor_col: np.ones(nFakes, dtype="float"),
self.config.bulge_semimajor_col: np.ones(nFakes, dtype="float"),
self.config.disk_n_col: np.ones(nFakes, dtype="float"),
self.config.bulge_n_col: np.ones(nFakes, dtype="float"),
self.config.disk_axis_ratio_col: np.ones(nFakes, dtype="float"),
self.config.bulge_axis_ratio_col: np.ones(nFakes, dtype="float"),
self.config.disk_pa_col: np.zeros(nFakes, dtype="float"),
self.config.bulge_pa_col: np.ones(nFakes, dtype="float"),
self.config.sourceType: nFakes * ["star"]}

return Struct(fakeCat=pd.DataFrame(data=randData))
Expand Down Expand Up @@ -212,8 +210,8 @@ def createRandomPositions(self, nFakes, boundingCircle, rng):
decs = np.arcsin(randVect[:, 2])
ras = np.arctan2(randVect[:, 1], randVect[:, 0])

return {self.config.decColName: decs,
self.config.raColName: ras}
return {self.config.dec_col: decs,
self.config.ra_col: ras}

def _createRotMatrix(self, boundingCircle):
"""Compute the 3d rotation matrix to rotate the dec=90 pole to the
Expand Down
12 changes: 6 additions & 6 deletions tests/test_createApFakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def testRun(self):
for idx, row in fakeCat.iterrows():
self.assertTrue(
bCircle.contains(
geom.SpherePoint(row[fakesTask.config.raColName],
row[fakesTask.config.decColName],
geom.SpherePoint(row[fakesTask.config.ra_col],
row[fakesTask.config.dec_col],
geom.radians).getVector()))
self.assertEqual(fakeCat[fakesConfig.visitSourceFlagCol].sum(),
self.nInVisit)
Expand All @@ -133,13 +133,13 @@ def testCreateRandomPositions(self):
nFakes=self.nSources,
boundingCircle=bCircle,
rng=self.rng)
self.assertEqual(self.nSources, len(randData[fakesTask.config.raColName]))
self.assertEqual(self.nSources, len(randData[fakesTask.config.decColName]))
self.assertEqual(self.nSources, len(randData[fakesTask.config.ra_col]))
self.assertEqual(self.nSources, len(randData[fakesTask.config.dec_col]))
for idx in range(self.nSources):
self.assertTrue(
bCircle.contains(
geom.SpherePoint(randData[fakesTask.config.raColName][idx],
randData[fakesTask.config.decColName][idx],
geom.SpherePoint(randData[fakesTask.config.ra_col][idx],
randData[fakesTask.config.dec_col][idx],
geom.radians).getVector()))

def testCreateRotMatrix(self):
Expand Down