Skip to content

Commit

Permalink
Update positionGalsimFakes for LSST
Browse files Browse the repository at this point in the history
Make the PositionGalsimFakes task compatible with the LSST fake
object pipeline hooks.
  • Loading branch information
natelust committed Jul 28, 2017
1 parent 9a6204a commit 478cac5
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions python/fakes/positionGalSimFakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import lsst.afw.coord
import lsst.pex.config as lsstConfig

from lsst.pipe.tasks.fakes import FakeSourcesConfig, FakeSourcesTask
from lsst.pipe.tasks.fakes import BaseFakeSourcesConfig, BaseFakeSourcesTask

import FakeSourceLib as fsl
import makeFakeGalaxy as makeFake


class PositionGalSimFakesConfig(FakeSourcesConfig):
class PositionGalSimFakesConfig(BaseFakeSourcesConfig):
galList = lsstConfig.Field(dtype=str,
doc="catalog of galaxies to add")
maxMargin = lsstConfig.Field(dtype=int, default=600,
Expand Down Expand Up @@ -52,13 +52,13 @@ class PositionGalSimFakesConfig(FakeSourcesConfig):
doc='Exclusion level')


class PositionGalSimFakesTask(FakeSourcesTask):
class PositionGalSimFakesTask(BaseFakeSourcesTask):
ConfigClass = PositionGalSimFakesConfig

def __init__(self, **kwargs):
FakeSourcesTask.__init__(self, **kwargs)
print "RNG seed:", self.config.seed
self.rng = lsst.afw.math.Random(self.config.seed)
BaseFakeSourcesTask.__init__(self, **kwargs)
print("RNG seed:", self.config.seed)
self.rng = lsst.afw.math.Random(seed=self.config.seed)
self.npRand = np.random.RandomState(self.config.seed)
self.galData = fits.open(self.config.galList)[1].data

Expand Down Expand Up @@ -245,11 +245,12 @@ def run(self, exposure, background):
galXY.getY()))

galMaskedImage.getMask().set(self.bitmask)
try:
galMaskedImage.getMask().removeAndClearMaskPlane('FAKE',
True)
except Exception:
pass
if not self.config.addMask:
try:
galMaskedImage.getMask().removeAndClearMaskPlane('FAKE',
True)
except Exception:
pass
try:
galMaskedImage.getMask().removeAndClearMaskPlane('CROSSTALK',
True)
Expand All @@ -272,10 +273,11 @@ def run(self, exposure, background):
True)
except Exception:
pass
try:
maskedImage.getMask().removeAndClearMaskPlane('FAKE', True)
except Exception:
pass
if not self.config.addMask:
try:
maskedImage.getMask().removeAndClearMaskPlane('FAKE', True)
except Exception:
pass

BBox = galMaskedImage.getBBox(PARENT)
subMaskedImage = maskedImage.Factory(exposure.getMaskedImage(),
Expand Down

0 comments on commit 478cac5

Please sign in to comment.