15 Helper functions for making fake sources 20 """A version of lsst.pipe.base.DataIdContainer specialized for loading a skyMap 21 in the make fake source catalog scripts. These scripts use the data id in a 22 unique way, such that they only need a tract number. This class supports that 23 use case and should not be used in any other contexts in the LSST stack. 24 Required because butler.subset does not support only tract 28 """Make self.refList from self.idList 31 for dataId
in self.idList:
32 if "tract" not in dataId:
33 raise RuntimeError(
"id must specify which tract to process tract")
37 namespace.log.warn(
"'{}' specified in --id is unused and will be ignored".format(key))
40 self.refList += [namespace.butler.dataRef(datasetType=
"deepCoadd_skyMap", dataId=addId)
45 Crops the Fake image to fit inside the exposure BBox 46 Note that the bboxes need to have the correct offsets applied 48 fakeImage: fake image object 49 expBBox: bounding box for CCD exposure (integer type, BBoxI) 50 and with offsets applied 53 New cropped fake image 55 fakeBBox = fakeImage.getBBox(lsst.afw.image.PARENT)
57 if not expBBox.contains(fakeBBox):
58 newBBox = fakeImage.getBBox(lsst.afw.image.PARENT)
60 fakeImage = fakeImage.Factory(fakeImage, newBBox,
61 lsst.afw.image.PARENT)
65 def addNoise(galImage, detector, rand_gen=None):
67 adds noise to the the image and returns a variance plane 68 INPUT: image to add noise to 69 detector where the image will be located, this sets the gain 70 NOTE: this assumes float type images and will break if given doubles 71 RETURN: a MaskedImageF with the image with additional noise and the 73 giving the variance due to the object 76 varImage = galImage.Factory(galImage,
True)
79 scale = np.sqrt(np.abs(varImage.getArray())) + 1e-12
80 noiseArray = rand_gen.normal(loc=0.0,
82 size=(galImage.getHeight(),
84 noiseImage = lsst.afw.image.ImageF(noiseArray.astype(np.float32))
85 galImage += noiseImage
87 return lsst.afw.image.MaskedImageF(galImage,
None, varImage)
def cropFakeImage(fakeImage, expBBox)
def addNoise(galImage, detector, rand_gen=None)
def makeDataRefList(self, namespace)