LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Classes | Functions | Variables
lsst.pipe.tasks.insertFakes Namespace Reference

Classes

class  InsertFakesConnections
 

Functions

def processImagesForInsertion (self, fakeCat, wcs, psf, photoCalib, band, pixelScale)
 
def addPixCoords (self, fakeCat, image)
 
def trimFakeCat (self, fakeCat, image)
 
def mkFakeGalsimGalaxies (self, fakeCat, band, photoCalib, pixelScale, psf, image)
 
def mkFakeStars (self, fakeCat, band, photoCalib, psf, image)
 
def cleanCat (self, fakeCat, starCheckVal)
 
def addFakeSources (self, image, fakeImages, sourceType)
 

Variables

 linWcs = wcs.linearizePixelToSky(skyCoord, geom.arcseconds)
 
 mat = linWcs.getMatrix()
 
 wcs
 
 obj = galsim.InterpolatedImage(im, calculate_stepk=False)
 

Function Documentation

◆ addFakeSources()

def lsst.pipe.tasks.insertFakes.addFakeSources (   self,
  image,
  fakeImages,
  sourceType 
)
Add the fake sources to the given image

Parameters
----------
image : `lsst.afw.image.exposure.exposure.ExposureF`
            The image into which the fake sources should be added
fakeImages : `typing.Iterator` [`tuple` ['lsst.afw.image.ImageF`, `lsst.geom.Point2d`]]
            An iterator of tuples that contains (or generates) images of fake sources,
            and the locations they are to be inserted at.
sourceType : `str`
            The type (star/galaxy) of fake sources input

Returns
-------
image : `lsst.afw.image.exposure.exposure.ExposureF`

Notes
-----
Uses the x, y information in the ``fakeCat`` to position an image of the fake interpolated onto the
pixel grid of the image. Sets the ``FAKE`` mask plane for the pixels added with the fake source.

Definition at line 1270 of file insertFakes.py.

1270 def addFakeSources(self, image, fakeImages, sourceType):
1271 """Add the fake sources to the given image
1272
1273 Parameters
1274 ----------
1275 image : `lsst.afw.image.exposure.exposure.ExposureF`
1276 The image into which the fake sources should be added
1277 fakeImages : `typing.Iterator` [`tuple` ['lsst.afw.image.ImageF`, `lsst.geom.Point2d`]]
1278 An iterator of tuples that contains (or generates) images of fake sources,
1279 and the locations they are to be inserted at.
1280 sourceType : `str`
1281 The type (star/galaxy) of fake sources input
1282
1283 Returns
1284 -------
1285 image : `lsst.afw.image.exposure.exposure.ExposureF`
1286
1287 Notes
1288 -----
1289 Uses the x, y information in the ``fakeCat`` to position an image of the fake interpolated onto the
1290 pixel grid of the image. Sets the ``FAKE`` mask plane for the pixels added with the fake source.
1291 """
1292
1293 imageBBox = image.getBBox()
1294 imageMI = image.maskedImage
1295
1296 for (fakeImage, xy) in fakeImages:
1297 X0 = xy.getX() - fakeImage.getWidth()/2 + 0.5
1298 Y0 = xy.getY() - fakeImage.getHeight()/2 + 0.5
1299 self.log.debug("Adding fake source at %d, %d", xy.getX(), xy.getY())
1300 if sourceType == "galaxy":
1301 interpFakeImage = afwMath.offsetImage(fakeImage, X0, Y0, "lanczos3")
1302 else:
1303 interpFakeImage = fakeImage
1304
1305 interpFakeImBBox = interpFakeImage.getBBox()
1306 interpFakeImBBox.clip(imageBBox)
1307
1308 if interpFakeImBBox.getArea() > 0:
1309 imageMIView = imageMI[interpFakeImBBox]
1310 clippedFakeImage = interpFakeImage[interpFakeImBBox]
1311 clippedFakeImageMI = afwImage.MaskedImageF(clippedFakeImage)
1312 clippedFakeImageMI.mask.set(self.bitmask)
1313 imageMIView += clippedFakeImageMI
1314
1315 return image
1316
std::shared_ptr< ImageT > offsetImage(ImageT const &image, float dx, float dy, std::string const &algorithmName="lanczos5", unsigned int buffer=0)
Return an image offset by (dx, dy) using the specified algorithm.
Definition: offsetImage.cc:41
def addFakeSources(self, image, fakeImages, sourceType)

◆ addPixCoords()

def lsst.pipe.tasks.insertFakes.addPixCoords (   self,
  fakeCat,
  image 
)
Add pixel coordinates to the catalog of fakes.

Parameters
----------
fakeCat : `pandas.core.frame.DataFrame`
            The catalog of fake sources to be input
image : `lsst.afw.image.exposure.exposure.ExposureF`
            The image into which the fake sources should be added

Returns
-------
fakeCat : `pandas.core.frame.DataFrame`

Definition at line 1037 of file insertFakes.py.

1037 def addPixCoords(self, fakeCat, image):
1038
1039 """Add pixel coordinates to the catalog of fakes.
1040
1041 Parameters
1042 ----------
1043 fakeCat : `pandas.core.frame.DataFrame`
1044 The catalog of fake sources to be input
1045 image : `lsst.afw.image.exposure.exposure.ExposureF`
1046 The image into which the fake sources should be added
1047
1048 Returns
1049 -------
1050 fakeCat : `pandas.core.frame.DataFrame`
1051 """
1052 wcs = image.getWcs()
1053 ras = fakeCat['ra'].values
1054 decs = fakeCat['dec'].values
1055 xs, ys = wcs.skyToPixelArray(ras, decs)
1056 fakeCat["x"] = xs
1057 fakeCat["y"] = ys
1058
1059 return fakeCat
1060
def addPixCoords(self, fakeCat, image)

◆ cleanCat()

def lsst.pipe.tasks.insertFakes.cleanCat (   self,
  fakeCat,
  starCheckVal 
)
Remove rows from the fakes catalog which have HLR = 0 for either the buldge or disk component,
   also remove galaxies that have Sersic index outside the galsim min and max
   allowed (0.3 <= n <= 6.2).

Parameters
----------
fakeCat : `pandas.core.frame.DataFrame`
            The catalog of fake sources to be input
starCheckVal : `str`, `bytes` or `int`
            The value that is set in the sourceType column to specifiy an object is a star.

Returns
-------
fakeCat : `pandas.core.frame.DataFrame`
            The input catalog of fake sources but with the bad objects removed

Definition at line 1229 of file insertFakes.py.

1229 def cleanCat(self, fakeCat, starCheckVal):
1230 """Remove rows from the fakes catalog which have HLR = 0 for either the buldge or disk component,
1231 also remove galaxies that have Sersic index outside the galsim min and max
1232 allowed (0.3 <= n <= 6.2).
1233
1234 Parameters
1235 ----------
1236 fakeCat : `pandas.core.frame.DataFrame`
1237 The catalog of fake sources to be input
1238 starCheckVal : `str`, `bytes` or `int`
1239 The value that is set in the sourceType column to specifiy an object is a star.
1240
1241 Returns
1242 -------
1243 fakeCat : `pandas.core.frame.DataFrame`
1244 The input catalog of fake sources but with the bad objects removed
1245 """
1246
1247 rowsToKeep = (((fakeCat['bulge_semimajor'] != 0.0) & (fakeCat['disk_semimajor'] != 0.0))
1248 | (fakeCat[self.config.sourceType] == starCheckVal))
1249 numRowsNotUsed = len(fakeCat) - len(np.where(rowsToKeep)[0])
1250 self.log.info("Removing %d rows with HLR = 0 for either the bulge or disk", numRowsNotUsed)
1251 fakeCat = fakeCat[rowsToKeep]
1252
1253 minN = galsim.Sersic._minimum_n
1254 maxN = galsim.Sersic._maximum_n
1255 rowsWithGoodSersic = (((fakeCat['bulge_n'] >= minN) & (fakeCat['bulge_n'] <= maxN)
1256 & (fakeCat['disk_n'] >= minN) & (fakeCat['disk_n'] <= maxN))
1257 | (fakeCat[self.config.sourceType] == starCheckVal))
1258 numRowsNotUsed = len(fakeCat) - len(np.where(rowsWithGoodSersic)[0])
1259 self.log.info("Removing %d rows of galaxies with nBulge or nDisk outside of %0.2f <= n <= %0.2f",
1260 numRowsNotUsed, minN, maxN)
1261 fakeCat = fakeCat[rowsWithGoodSersic]
1262
1263 if self.config.doSubSelectSources:
1264 numRowsNotUsed = len(fakeCat) - len(fakeCat['select'])
1265 self.log.info("Removing %d rows which were not designated as template sources", numRowsNotUsed)
1266 fakeCat = fakeCat[fakeCat['select']]
1267
1268 return fakeCat
1269
def cleanCat(self, fakeCat, starCheckVal)

◆ mkFakeGalsimGalaxies()

def lsst.pipe.tasks.insertFakes.mkFakeGalsimGalaxies (   self,
  fakeCat,
  band,
  photoCalib,
  pixelScale,
  psf,
  image 
)
Make images of fake galaxies using GalSim.

Parameters
----------
band : `str`
pixelScale : `float`
psf : `lsst.meas.extensions.psfex.psfexPsf.PsfexPsf`
            The PSF information to use to make the PSF images
fakeCat : `pandas.core.frame.DataFrame`
            The catalog of fake sources to be input
photoCalib : `lsst.afw.image.photoCalib.PhotoCalib`
            Photometric calibration to be used to calibrate the fake sources

Yields
-------
galImages : `generator`
            A generator of tuples of `lsst.afw.image.exposure.exposure.ExposureF` and
            `lsst.geom.Point2D` of their locations.

Notes
-----

Fake galaxies are made by combining two sersic profiles, one for the bulge and one for the disk. Each
component has an individual sersic index (n), a, b and position angle (PA). The combined profile is
then convolved with the PSF at the specified x, y position on the image.

The names of the columns in the ``fakeCat`` are configurable and are the column names from the
University of Washington simulations database as default. For more information see the doc strings
attached to the config options.

See mkFakeStars doc string for an explanation of calibration to instrumental flux.

Definition at line 1098 of file insertFakes.py.

1098 def mkFakeGalsimGalaxies(self, fakeCat, band, photoCalib, pixelScale, psf, image):
1099 """Make images of fake galaxies using GalSim.
1100
1101 Parameters
1102 ----------
1103 band : `str`
1104 pixelScale : `float`
1105 psf : `lsst.meas.extensions.psfex.psfexPsf.PsfexPsf`
1106 The PSF information to use to make the PSF images
1107 fakeCat : `pandas.core.frame.DataFrame`
1108 The catalog of fake sources to be input
1109 photoCalib : `lsst.afw.image.photoCalib.PhotoCalib`
1110 Photometric calibration to be used to calibrate the fake sources
1111
1112 Yields
1113 -------
1114 galImages : `generator`
1115 A generator of tuples of `lsst.afw.image.exposure.exposure.ExposureF` and
1116 `lsst.geom.Point2D` of their locations.
1117
1118 Notes
1119 -----
1120
1121 Fake galaxies are made by combining two sersic profiles, one for the bulge and one for the disk. Each
1122 component has an individual sersic index (n), a, b and position angle (PA). The combined profile is
1123 then convolved with the PSF at the specified x, y position on the image.
1124
1125 The names of the columns in the ``fakeCat`` are configurable and are the column names from the
1126 University of Washington simulations database as default. For more information see the doc strings
1127 attached to the config options.
1128
1129 See mkFakeStars doc string for an explanation of calibration to instrumental flux.
1130 """
1131
1132 self.log.info("Making %d fake galaxy images", len(fakeCat))
1133
1134 for (index, row) in fakeCat.iterrows():
1135 xy = geom.Point2D(row["x"], row["y"])
1136
1137 # We put these two PSF calculations within this same try block so that we catch cases
1138 # where the object's position is outside of the image.
1139 try:
1140 correctedFlux = psf.computeApertureFlux(self.config.calibFluxRadius, xy)
1141 psfKernel = psf.computeKernelImage(xy).getArray()
1142 psfKernel /= correctedFlux
1143
1144 except InvalidParameterError:
1145 self.log.info("Galaxy at %0.4f, %0.4f outside of image", row["x"], row["y"])
1146 continue
1147
1148 try:
1149 flux = photoCalib.magnitudeToInstFlux(row['mag'], xy)
1150 except LogicError:
1151 flux = 0
1152
1153 # GalSim convention: HLR = sqrt(a * b) = a * sqrt(b / a)
1154 bulge_gs_HLR = row['bulge_semimajor']*np.sqrt(row['bulge_axis_ratio'])
1155 bulge = galsim.Sersic(n=row['bulge_n'], half_light_radius=bulge_gs_HLR)
1156 bulge = bulge.shear(q=row['bulge_axis_ratio'], beta=((90 - row['bulge_pa'])*galsim.degrees))
1157
1158 disk_gs_HLR = row['disk_semimajor']*np.sqrt(row['disk_axis_ratio'])
1159 disk = galsim.Sersic(n=row['disk_n'], half_light_radius=disk_gs_HLR)
1160 disk = disk.shear(q=row['disk_axis_ratio'], beta=((90 - row['disk_pa'])*galsim.degrees))
1161
1162 gal = bulge*row['bulge_disk_flux_ratio'] + disk
1163 gal = gal.withFlux(flux)
1164
1165 psfIm = galsim.InterpolatedImage(galsim.Image(psfKernel), scale=pixelScale)
1166 gal = galsim.Convolve([gal, psfIm])
1167 try:
1168 galIm = gal.drawImage(scale=pixelScale, method="real_space").array
1169 except (galsim.errors.GalSimFFTSizeError, MemoryError):
1170 continue
1171
1172 yield (afwImage.ImageF(galIm), xy)
1173
def mkFakeGalsimGalaxies(self, fakeCat, band, photoCalib, pixelScale, psf, image)

◆ mkFakeStars()

def lsst.pipe.tasks.insertFakes.mkFakeStars (   self,
  fakeCat,
  band,
  photoCalib,
  psf,
  image 
)
Make fake stars based off the properties in the fakeCat.

Parameters
----------
band : `str`
psf : `lsst.meas.extensions.psfex.psfexPsf.PsfexPsf`
            The PSF information to use to make the PSF images
fakeCat : `pandas.core.frame.DataFrame`
            The catalog of fake sources to be input
image : `lsst.afw.image.exposure.exposure.ExposureF`
            The image into which the fake sources should be added
photoCalib : `lsst.afw.image.photoCalib.PhotoCalib`
            Photometric calibration to be used to calibrate the fake sources

Yields
-------
starImages : `generator`
            A generator of tuples of `lsst.afw.image.ImageF` of fake stars and
            `lsst.geom.Point2D` of their locations.

Notes
-----
To take a given magnitude and translate to the number of counts in the image
we use photoCalib.magnitudeToInstFlux, which returns the instrumental flux for the
given calibration radius used in the photometric calibration step.
Thus `calibFluxRadius` should be set to this same radius so that we can normalize
the PSF model to the correct instrumental flux within calibFluxRadius.

Definition at line 1174 of file insertFakes.py.

1174 def mkFakeStars(self, fakeCat, band, photoCalib, psf, image):
1175
1176 """Make fake stars based off the properties in the fakeCat.
1177
1178 Parameters
1179 ----------
1180 band : `str`
1181 psf : `lsst.meas.extensions.psfex.psfexPsf.PsfexPsf`
1182 The PSF information to use to make the PSF images
1183 fakeCat : `pandas.core.frame.DataFrame`
1184 The catalog of fake sources to be input
1185 image : `lsst.afw.image.exposure.exposure.ExposureF`
1186 The image into which the fake sources should be added
1187 photoCalib : `lsst.afw.image.photoCalib.PhotoCalib`
1188 Photometric calibration to be used to calibrate the fake sources
1189
1190 Yields
1191 -------
1192 starImages : `generator`
1193 A generator of tuples of `lsst.afw.image.ImageF` of fake stars and
1194 `lsst.geom.Point2D` of their locations.
1195
1196 Notes
1197 -----
1198 To take a given magnitude and translate to the number of counts in the image
1199 we use photoCalib.magnitudeToInstFlux, which returns the instrumental flux for the
1200 given calibration radius used in the photometric calibration step.
1201 Thus `calibFluxRadius` should be set to this same radius so that we can normalize
1202 the PSF model to the correct instrumental flux within calibFluxRadius.
1203 """
1204
1205 self.log.info("Making %d fake star images", len(fakeCat))
1206
1207 for (index, row) in fakeCat.iterrows():
1208 xy = geom.Point2D(row["x"], row["y"])
1209
1210 # We put these two PSF calculations within this same try block so that we catch cases
1211 # where the object's position is outside of the image.
1212 try:
1213 correctedFlux = psf.computeApertureFlux(self.config.calibFluxRadius, xy)
1214 starIm = psf.computeImage(xy)
1215 starIm /= correctedFlux
1216
1217 except InvalidParameterError:
1218 self.log.info("Star at %0.4f, %0.4f outside of image", row["x"], row["y"])
1219 continue
1220
1221 try:
1222 flux = photoCalib.magnitudeToInstFlux(row['mag'], xy)
1223 except LogicError:
1224 flux = 0
1225
1226 starIm *= flux
1227 yield ((starIm.convertF(), xy))
1228
def mkFakeStars(self, fakeCat, band, photoCalib, psf, image)

◆ processImagesForInsertion()

def lsst.pipe.tasks.insertFakes.processImagesForInsertion (   self,
  fakeCat,
  wcs,
  psf,
  photoCalib,
  band,
  pixelScale 
)
Process images from files into the format needed for insertion.

Parameters
----------
fakeCat : `pandas.core.frame.DataFrame`
            The catalog of fake sources to be input
wcs : `lsst.afw.geom.skyWcs.skyWcs.SkyWc`
            WCS to use to add fake sources
psf : `lsst.meas.algorithms.coaddPsf.coaddPsf.CoaddPsf` or
      `lsst.meas.extensions.psfex.psfexPsf.PsfexPsf`
            The PSF information to use to make the PSF images
photoCalib : `lsst.afw.image.photoCalib.PhotoCalib`
            Photometric calibration to be used to calibrate the fake sources
band : `str`
            The filter band that the observation was taken in.
pixelScale : `float`
            The pixel scale of the image the sources are to be added to.

Returns
-------
galImages : `list`
            A list of tuples of `lsst.afw.image.exposure.exposure.ExposureF` and
            `lsst.geom.Point2D` of their locations.
            For sources labelled as galaxy.
starImages : `list`
            A list of tuples of `lsst.afw.image.exposure.exposure.ExposureF` and
            `lsst.geom.Point2D` of their locations.
            For sources labelled as star.

Notes
-----
The input fakes catalog needs to contain the absolute path to the image in the
band that is being used to add images to. It also needs to have the R.A. and
declination of the fake source in radians and the sourceType of the object.

Definition at line 950 of file insertFakes.py.

950 def processImagesForInsertion(self, fakeCat, wcs, psf, photoCalib, band, pixelScale):
951 """Process images from files into the format needed for insertion.
952
953 Parameters
954 ----------
955 fakeCat : `pandas.core.frame.DataFrame`
956 The catalog of fake sources to be input
957 wcs : `lsst.afw.geom.skyWcs.skyWcs.SkyWc`
958 WCS to use to add fake sources
959 psf : `lsst.meas.algorithms.coaddPsf.coaddPsf.CoaddPsf` or
960 `lsst.meas.extensions.psfex.psfexPsf.PsfexPsf`
961 The PSF information to use to make the PSF images
962 photoCalib : `lsst.afw.image.photoCalib.PhotoCalib`
963 Photometric calibration to be used to calibrate the fake sources
964 band : `str`
965 The filter band that the observation was taken in.
966 pixelScale : `float`
967 The pixel scale of the image the sources are to be added to.
968
969 Returns
970 -------
971 galImages : `list`
972 A list of tuples of `lsst.afw.image.exposure.exposure.ExposureF` and
973 `lsst.geom.Point2D` of their locations.
974 For sources labelled as galaxy.
975 starImages : `list`
976 A list of tuples of `lsst.afw.image.exposure.exposure.ExposureF` and
977 `lsst.geom.Point2D` of their locations.
978 For sources labelled as star.
979
980 Notes
981 -----
982 The input fakes catalog needs to contain the absolute path to the image in the
983 band that is being used to add images to. It also needs to have the R.A. and
984 declination of the fake source in radians and the sourceType of the object.
985 """
986 galImages = []
987 starImages = []
988
989 self.log.info("Processing %d fake images", len(fakeCat))
990
991 for (imFile, sourceType, mag, x, y) in zip(fakeCat[band + "imFilename"].array,
992 fakeCat["sourceType"].array,
993 fakeCat['mag'].array,
994 fakeCat["x"].array, fakeCat["y"].array):
995
996 im = afwImage.ImageF.readFits(imFile)
997
998 xy = geom.Point2D(x, y)
999
1000 # We put these two PSF calculations within this same try block so that we catch cases
1001 # where the object's position is outside of the image.
1002 try:
1003 correctedFlux = psf.computeApertureFlux(self.config.calibFluxRadius, xy)
1004 psfKernel = psf.computeKernelImage(xy).getArray()
1005 psfKernel /= correctedFlux
1006
1007 except InvalidParameterError:
1008 self.log.info("%s at %0.4f, %0.4f outside of image", sourceType, x, y)
1009 continue
1010
1011 psfIm = galsim.InterpolatedImage(galsim.Image(psfKernel), scale=pixelScale)
1012 galsimIm = galsim.InterpolatedImage(galsim.Image(im.array), scale=pixelScale)
1013 convIm = galsim.Convolve([galsimIm, psfIm])
1014
1015 try:
1016 outIm = convIm.drawImage(scale=pixelScale, method="real_space").array
1017 except (galsim.errors.GalSimFFTSizeError, MemoryError):
1018 continue
1019
1020 imSum = np.sum(outIm)
1021 divIm = outIm/imSum
1022
1023 try:
1024 flux = photoCalib.magnitudeToInstFlux(mag, xy)
1025 except LogicError:
1026 flux = 0
1027
1028 imWithFlux = flux*divIm
1029
1030 if sourceType == b"galaxy":
1031 galImages.append((afwImage.ImageF(imWithFlux), xy))
1032 if sourceType == b"star":
1033 starImages.append((afwImage.ImageF(imWithFlux), xy))
1034
1035 return galImages, starImages
1036
def processImagesForInsertion(self, fakeCat, wcs, psf, photoCalib, band, pixelScale)
Definition: insertFakes.py:950

◆ trimFakeCat()

def lsst.pipe.tasks.insertFakes.trimFakeCat (   self,
  fakeCat,
  image 
)
Trim the fake cat to the size of the input image plus trimBuffer padding.

`fakeCat` must be processed with addPixCoords before using this method.

Parameters
----------
fakeCat : `pandas.core.frame.DataFrame`
            The catalog of fake sources to be input
image : `lsst.afw.image.exposure.exposure.ExposureF`
            The image into which the fake sources should be added

Returns
-------
fakeCat : `pandas.core.frame.DataFrame`
            The original fakeCat trimmed to the area of the image

Definition at line 1061 of file insertFakes.py.

1061 def trimFakeCat(self, fakeCat, image):
1062 """Trim the fake cat to the size of the input image plus trimBuffer padding.
1063
1064 `fakeCat` must be processed with addPixCoords before using this method.
1065
1066 Parameters
1067 ----------
1068 fakeCat : `pandas.core.frame.DataFrame`
1069 The catalog of fake sources to be input
1070 image : `lsst.afw.image.exposure.exposure.ExposureF`
1071 The image into which the fake sources should be added
1072
1073 Returns
1074 -------
1075 fakeCat : `pandas.core.frame.DataFrame`
1076 The original fakeCat trimmed to the area of the image
1077 """
1078 wideBbox = Box2D(image.getBBox()).dilatedBy(self.config.trimBuffer)
1079
1080 # prefilter in ra/dec to avoid cases where the wcs incorrectly maps
1081 # input fakes which are really off the chip onto it.
1082 ras = fakeCat[self.config.ra_col].values * u.rad
1083 decs = fakeCat[self.config.dec_col].values * u.rad
1084
1085 isContainedRaDec = image.containsSkyCoords(ras, decs, padding=self.config.trimBuffer)
1086
1087 # also filter on the image BBox in pixel space
1088 xs = fakeCat["x"].values
1089 ys = fakeCat["y"].values
1090
1091 isContainedXy = xs >= wideBbox.minX
1092 isContainedXy &= xs <= wideBbox.maxX
1093 isContainedXy &= ys >= wideBbox.minY
1094 isContainedXy &= ys <= wideBbox.maxY
1095
1096 return fakeCat[isContainedRaDec & isContainedXy]
1097
def trimFakeCat(self, fakeCat, image)

Variable Documentation

◆ linWcs

lsst.pipe.tasks.insertFakes.linWcs = wcs.linearizePixelToSky(skyCoord, geom.arcseconds)
# Unchanged

doCleanCat = pexConfig.Field(
    doc="If true removes bad sources from the catalog.",
    dtype=bool,
    default=True,
)

fakeType = pexConfig.Field(
    doc="What type of fake catalog to use, snapshot (includes variability in the magnitudes calculated "
        "from the MJD of the image), static (no variability) or filename for a user defined fits"
        "catalog.",
    dtype=str,
    default="static",
)

calibFluxRadius = pexConfig.Field(
    doc="Aperture radius (in pixels) that was used to define the calibration for this image+catalog. "
    "This will be used to produce the correct instrumental fluxes within the radius. "
    "This value should match that of the field defined in slot_CalibFlux_instFlux.",
    dtype=float,
    default=12.0,
)

coaddName = pexConfig.Field(
    doc="The name of the type of coadd used",
    dtype=str,
    default="deep",
)

doSubSelectSources = pexConfig.Field(
    doc="Set to True if you wish to sub select sources to be input based on the value in the column"
        "set in the sourceSelectionColName config option.",
    dtype=bool,
    default=False
)

insertImages = pexConfig.Field(
    doc="Insert images directly? True or False.",
    dtype=bool,
    default=False,
)

insertOnlyStars = pexConfig.Field(
    doc="Insert only stars? True or False.",
    dtype=bool,
    default=False,
)

doProcessAllDataIds = pexConfig.Field(
    doc="If True, all input data IDs will be processed, even those containing no fake sources.",
    dtype=bool,
    default=False,
)

trimBuffer = pexConfig.Field(
    doc="Size of the pixel buffer surrounding the image. Only those fake sources with a centroid"
    "falling within the image+buffer region will be considered for fake source injection.",
    dtype=int,
    default=100,
)

sourceType = pexConfig.Field(
    doc="The column name for the source type used in the fake source catalog.",
    dtype=str,
    default="sourceType",
)

fits_alignment = pexConfig.ChoiceField(
    doc="How should injections from FITS files be aligned?",
    dtype=str,
    allowed={
        "wcs": (
            "Input image will be transformed such that the local WCS in "
            "the FITS header matches the local WCS in the target image. "
            "I.e., North, East, and angular distances in the input image "
            "will match North, East, and angular distances in the target "
            "image."
        ),
        "pixel": (
            "Input image will _not_ be transformed.  Up, right, and pixel "
            "distances in the input image will match up, right and pixel "
            "distances in the target image."
        )
    },
    default="pixel"
)

# New source catalog config variables

ra_col = pexConfig.Field(
    doc="Source catalog column name for RA (in radians).",
    dtype=str,
    default="ra",
)

dec_col = pexConfig.Field(
    doc="Source catalog column name for dec (in radians).",
    dtype=str,
    default="dec",
)

bulge_semimajor_col = pexConfig.Field(
    doc="Source catalog column name for the semimajor axis (in arcseconds) "
        "of the bulge half-light ellipse.",
    dtype=str,
    default="bulge_semimajor",
)

bulge_axis_ratio_col = pexConfig.Field(
    doc="Source catalog column name for the axis ratio of the bulge "
        "half-light ellipse.",
    dtype=str,
    default="bulge_axis_ratio",
)

bulge_pa_col = pexConfig.Field(
    doc="Source catalog column name for the position angle (measured from "
        "North through East in degrees) of the semimajor axis of the bulge "
        "half-light ellipse.",
    dtype=str,
    default="bulge_pa",
)

bulge_n_col = pexConfig.Field(
    doc="Source catalog column name for the Sersic index of the bulge.",
    dtype=str,
    default="bulge_n",
)

disk_semimajor_col = pexConfig.Field(
    doc="Source catalog column name for the semimajor axis (in arcseconds) "
        "of the disk half-light ellipse.",
    dtype=str,
    default="disk_semimajor",
)

disk_axis_ratio_col = pexConfig.Field(
    doc="Source catalog column name for the axis ratio of the disk "
        "half-light ellipse.",
    dtype=str,
    default="disk_axis_ratio",
)

disk_pa_col = pexConfig.Field(
    doc="Source catalog column name for the position angle (measured from "
        "North through East in degrees) of the semimajor axis of the disk "
        "half-light ellipse.",
    dtype=str,
    default="disk_pa",
)

disk_n_col = pexConfig.Field(
    doc="Source catalog column name for the Sersic index of the disk.",
    dtype=str,
    default="disk_n",
)

bulge_disk_flux_ratio_col = pexConfig.Field(
    doc="Source catalog column name for the bulge/disk flux ratio.",
    dtype=str,
    default="bulge_disk_flux_ratio",
)

mag_col = pexConfig.Field(
    doc="Source catalog column name template for magnitudes, in the format "
        "``filter name``_mag_col.  E.g., if this config variable is set to "
        "``%s_mag``, then the i-band magnitude will be searched for in the "
        "``i_mag`` column of the source catalog.",
    dtype=str,
    default="%s_mag"
)

select_col = pexConfig.Field(
    doc="Source catalog column name to be used to select which sources to "
        "add.",
    dtype=str,
    default="select",
)

length_col = pexConfig.Field(
    doc="Source catalog column name for trail length (in pixels).",
    dtype=str,
    default="trail_length",
)

angle_col = pexConfig.Field(
    doc="Source catalog column name for trail angle (in radians).",
    dtype=str,
    default="trail_angle",
)

# Deprecated config variables

raColName = pexConfig.Field(
    doc="RA column name used in the fake source catalog.",
    dtype=str,
    default="raJ2000",
    deprecated="Use `ra_col` instead."
)

decColName = pexConfig.Field(
    doc="Dec. column name used in the fake source catalog.",
    dtype=str,
    default="decJ2000",
    deprecated="Use `dec_col` instead."
)

diskHLR = pexConfig.Field(
    doc="Column name for the disk half light radius used in the fake source catalog.",
    dtype=str,
    default="DiskHalfLightRadius",
    deprecated=(
        "Use `disk_semimajor_col`, `disk_axis_ratio_col`, and `disk_pa_col`"
        " to specify disk half-light ellipse."
    )
)

aDisk = pexConfig.Field(
    doc="The column name for the semi major axis length of the disk component used in the fake source"
        "catalog.",
    dtype=str,
    default="a_d",
    deprecated=(
        "Use `disk_semimajor_col`, `disk_axis_ratio_col`, and `disk_pa_col`"
        " to specify disk half-light ellipse."
    )
)

bDisk = pexConfig.Field(
    doc="The column name for the semi minor axis length of the disk component.",
    dtype=str,
    default="b_d",
    deprecated=(
        "Use `disk_semimajor_col`, `disk_axis_ratio_col`, and `disk_pa_col`"
        " to specify disk half-light ellipse."
    )
)

paDisk = pexConfig.Field(
    doc="The column name for the PA of the disk component used in the fake source catalog.",
    dtype=str,
    default="pa_disk",
    deprecated=(
        "Use `disk_semimajor_col`, `disk_axis_ratio_col`, and `disk_pa_col`"
        " to specify disk half-light ellipse."
    )
)

nDisk = pexConfig.Field(
    doc="The column name for the sersic index of the disk component used in the fake source catalog.",
    dtype=str,
    default="disk_n",
    deprecated="Use `disk_n_col` instead."
)

bulgeHLR = pexConfig.Field(
    doc="Column name for the bulge half light radius used in the fake source catalog.",
    dtype=str,
    default="BulgeHalfLightRadius",
    deprecated=(
        "Use `bulge_semimajor_col`, `bulge_axis_ratio_col`, and "
        "`bulge_pa_col` to specify disk half-light ellipse."
    )
)

aBulge = pexConfig.Field(
    doc="The column name for the semi major axis length of the bulge component.",
    dtype=str,
    default="a_b",
    deprecated=(
        "Use `bulge_semimajor_col`, `bulge_axis_ratio_col`, and "
        "`bulge_pa_col` to specify disk half-light ellipse."
    )
)

bBulge = pexConfig.Field(
    doc="The column name for the semi minor axis length of the bulge component used in the fake source "
        "catalog.",
    dtype=str,
    default="b_b",
    deprecated=(
        "Use `bulge_semimajor_col`, `bulge_axis_ratio_col`, and "
        "`bulge_pa_col` to specify disk half-light ellipse."
    )
)

paBulge = pexConfig.Field(
    doc="The column name for the PA of the bulge component used in the fake source catalog.",
    dtype=str,
    default="pa_bulge",
    deprecated=(
        "Use `bulge_semimajor_col`, `bulge_axis_ratio_col`, and "
        "`bulge_pa_col` to specify disk half-light ellipse."
    )
)

nBulge = pexConfig.Field(
    doc="The column name for the sersic index of the bulge component used in the fake source catalog.",
    dtype=str,
    default="bulge_n",
    deprecated="Use `bulge_n_col` instead."
)

magVar = pexConfig.Field(
    doc="The column name for the magnitude calculated taking variability into account. In the format "
        "``filter name``magVar, e.g. imagVar for the magnitude in the i band.",
    dtype=str,
    default="%smagVar",
    deprecated="Use `mag_col` instead."
)

sourceSelectionColName = pexConfig.Field(
    doc="The name of the column in the input fakes catalogue to be used to determine which sources to"
        "add, default is none and when this is used all sources are added.",
    dtype=str,
    default="templateSource",
    deprecated="Use `select_col` instead."
)


class InsertFakesTask(PipelineTask, CmdLineTask):

Definition at line 936 of file insertFakes.py.

◆ mat

lsst.pipe.tasks.insertFakes.mat = linWcs.getMatrix()

Definition at line 937 of file insertFakes.py.

◆ obj

lsst.pipe.tasks.insertFakes.obj = galsim.InterpolatedImage(im, calculate_stepk=False)

Definition at line 946 of file insertFakes.py.

◆ wcs

lsst.pipe.tasks.insertFakes.wcs

Definition at line 938 of file insertFakes.py.