LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
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

 fakeCat = fakeCat.rename(columns=replace_dict, copy=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 1163 of file insertFakes.py.

1163  def addFakeSources(self, image, fakeImages, sourceType):
1164  """Add the fake sources to the given image
1165 
1166  Parameters
1167  ----------
1168  image : `lsst.afw.image.exposure.exposure.ExposureF`
1169  The image into which the fake sources should be added
1170  fakeImages : `typing.Iterator` [`tuple` ['lsst.afw.image.ImageF`, `lsst.geom.Point2d`]]
1171  An iterator of tuples that contains (or generates) images of fake sources,
1172  and the locations they are to be inserted at.
1173  sourceType : `str`
1174  The type (star/galaxy) of fake sources input
1175 
1176  Returns
1177  -------
1178  image : `lsst.afw.image.exposure.exposure.ExposureF`
1179 
1180  Notes
1181  -----
1182  Uses the x, y information in the ``fakeCat`` to position an image of the fake interpolated onto the
1183  pixel grid of the image. Sets the ``FAKE`` mask plane for the pixels added with the fake source.
1184  """
1185 
1186  imageBBox = image.getBBox()
1187  imageMI = image.maskedImage
1188 
1189  for (fakeImage, xy) in fakeImages:
1190  X0 = xy.getX() - fakeImage.getWidth()/2 + 0.5
1191  Y0 = xy.getY() - fakeImage.getHeight()/2 + 0.5
1192  self.log.debug("Adding fake source at %d, %d", xy.getX(), xy.getY())
1193  if sourceType == "galaxy":
1194  interpFakeImage = afwMath.offsetImage(fakeImage, X0, Y0, "lanczos3")
1195  else:
1196  interpFakeImage = fakeImage
1197 
1198  interpFakeImBBox = interpFakeImage.getBBox()
1199  interpFakeImBBox.clip(imageBBox)
1200 
1201  if interpFakeImBBox.getArea() > 0:
1202  imageMIView = imageMI[interpFakeImBBox]
1203  clippedFakeImage = interpFakeImage[interpFakeImBBox]
1204  clippedFakeImageMI = afwImage.MaskedImageF(clippedFakeImage)
1205  clippedFakeImageMI.mask.set(self.bitmask)
1206  imageMIView += clippedFakeImageMI
1207 
1208  return image
1209 
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 938 of file insertFakes.py.

938  def addPixCoords(self, fakeCat, image):
939 
940  """Add pixel coordinates to the catalog of fakes.
941 
942  Parameters
943  ----------
944  fakeCat : `pandas.core.frame.DataFrame`
945  The catalog of fake sources to be input
946  image : `lsst.afw.image.exposure.exposure.ExposureF`
947  The image into which the fake sources should be added
948 
949  Returns
950  -------
951  fakeCat : `pandas.core.frame.DataFrame`
952  """
953  wcs = image.getWcs()
954  ras = fakeCat['ra'].values
955  decs = fakeCat['dec'].values
956  xs, ys = wcs.skyToPixelArray(ras, decs)
957  fakeCat["x"] = xs
958  fakeCat["y"] = ys
959 
960  return fakeCat
961 
def addPixCoords(self, fakeCat, image)
Definition: insertFakes.py:938

◆ 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 1122 of file insertFakes.py.

1122  def cleanCat(self, fakeCat, starCheckVal):
1123  """Remove rows from the fakes catalog which have HLR = 0 for either the buldge or disk component,
1124  also remove galaxies that have Sersic index outside the galsim min and max
1125  allowed (0.3 <= n <= 6.2).
1126 
1127  Parameters
1128  ----------
1129  fakeCat : `pandas.core.frame.DataFrame`
1130  The catalog of fake sources to be input
1131  starCheckVal : `str`, `bytes` or `int`
1132  The value that is set in the sourceType column to specifiy an object is a star.
1133 
1134  Returns
1135  -------
1136  fakeCat : `pandas.core.frame.DataFrame`
1137  The input catalog of fake sources but with the bad objects removed
1138  """
1139 
1140  rowsToKeep = (((fakeCat['bulge_semimajor'] != 0.0) & (fakeCat['disk_semimajor'] != 0.0))
1141  | (fakeCat[self.config.sourceType] == starCheckVal))
1142  numRowsNotUsed = len(fakeCat) - len(np.where(rowsToKeep)[0])
1143  self.log.info("Removing %d rows with HLR = 0 for either the bulge or disk", numRowsNotUsed)
1144  fakeCat = fakeCat[rowsToKeep]
1145 
1146  minN = galsim.Sersic._minimum_n
1147  maxN = galsim.Sersic._maximum_n
1148  rowsWithGoodSersic = (((fakeCat['bulge_n'] >= minN) & (fakeCat['bulge_n'] <= maxN)
1149  & (fakeCat['disk_n'] >= minN) & (fakeCat['disk_n'] <= maxN))
1150  | (fakeCat[self.config.sourceType] == starCheckVal))
1151  numRowsNotUsed = len(fakeCat) - len(np.where(rowsWithGoodSersic)[0])
1152  self.log.info("Removing %d rows of galaxies with nBulge or nDisk outside of %0.2f <= n <= %0.2f",
1153  numRowsNotUsed, minN, maxN)
1154  fakeCat = fakeCat[rowsWithGoodSersic]
1155 
1156  if self.config.doSubSelectSources:
1157  numRowsNotUsed = len(fakeCat) - len(fakeCat['select'])
1158  self.log.info("Removing %d rows which were not designated as template sources", numRowsNotUsed)
1159  fakeCat = fakeCat[fakeCat['select']]
1160 
1161  return fakeCat
1162 
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 991 of file insertFakes.py.

991  def mkFakeGalsimGalaxies(self, fakeCat, band, photoCalib, pixelScale, psf, image):
992  """Make images of fake galaxies using GalSim.
993 
994  Parameters
995  ----------
996  band : `str`
997  pixelScale : `float`
998  psf : `lsst.meas.extensions.psfex.psfexPsf.PsfexPsf`
999  The PSF information to use to make the PSF images
1000  fakeCat : `pandas.core.frame.DataFrame`
1001  The catalog of fake sources to be input
1002  photoCalib : `lsst.afw.image.photoCalib.PhotoCalib`
1003  Photometric calibration to be used to calibrate the fake sources
1004 
1005  Yields
1006  -------
1007  galImages : `generator`
1008  A generator of tuples of `lsst.afw.image.exposure.exposure.ExposureF` and
1009  `lsst.geom.Point2D` of their locations.
1010 
1011  Notes
1012  -----
1013 
1014  Fake galaxies are made by combining two sersic profiles, one for the bulge and one for the disk. Each
1015  component has an individual sersic index (n), a, b and position angle (PA). The combined profile is
1016  then convolved with the PSF at the specified x, y position on the image.
1017 
1018  The names of the columns in the ``fakeCat`` are configurable and are the column names from the
1019  University of Washington simulations database as default. For more information see the doc strings
1020  attached to the config options.
1021 
1022  See mkFakeStars doc string for an explanation of calibration to instrumental flux.
1023  """
1024 
1025  self.log.info("Making %d fake galaxy images", len(fakeCat))
1026 
1027  for (index, row) in fakeCat.iterrows():
1028  xy = geom.Point2D(row["x"], row["y"])
1029 
1030  # We put these two PSF calculations within this same try block so that we catch cases
1031  # where the object's position is outside of the image.
1032  try:
1033  correctedFlux = psf.computeApertureFlux(self.config.calibFluxRadius, xy)
1034  psfKernel = psf.computeKernelImage(xy).getArray()
1035  psfKernel /= correctedFlux
1036 
1037  except InvalidParameterError:
1038  self.log.info("Galaxy at %0.4f, %0.4f outside of image", row["x"], row["y"])
1039  continue
1040 
1041  try:
1042  flux = photoCalib.magnitudeToInstFlux(row['mag'], xy)
1043  except LogicError:
1044  flux = 0
1045 
1046  # GalSim convention: HLR = sqrt(a * b) = a * sqrt(b / a)
1047  bulge_gs_HLR = row['bulge_semimajor']*np.sqrt(row['bulge_axis_ratio'])
1048  bulge = galsim.Sersic(n=row['bulge_n'], half_light_radius=bulge_gs_HLR)
1049  bulge = bulge.shear(q=row['bulge_axis_ratio'], beta=((90 - row['bulge_pa'])*galsim.degrees))
1050 
1051  disk_gs_HLR = row['disk_semimajor']*np.sqrt(row['disk_axis_ratio'])
1052  disk = galsim.Sersic(n=row['disk_n'], half_light_radius=disk_gs_HLR)
1053  disk = disk.shear(q=row['disk_axis_ratio'], beta=((90 - row['disk_pa'])*galsim.degrees))
1054 
1055  gal = bulge*row['bulge_disk_flux_ratio'] + disk
1056  gal = gal.withFlux(flux)
1057 
1058  psfIm = galsim.InterpolatedImage(galsim.Image(psfKernel), scale=pixelScale)
1059  gal = galsim.Convolve([gal, psfIm])
1060  try:
1061  galIm = gal.drawImage(scale=pixelScale, method="real_space").array
1062  except (galsim.errors.GalSimFFTSizeError, MemoryError):
1063  continue
1064 
1065  yield (afwImage.ImageF(galIm), xy)
1066 
def mkFakeGalsimGalaxies(self, fakeCat, band, photoCalib, pixelScale, psf, image)
Definition: insertFakes.py:991

◆ 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 1067 of file insertFakes.py.

1067  def mkFakeStars(self, fakeCat, band, photoCalib, psf, image):
1068 
1069  """Make fake stars based off the properties in the fakeCat.
1070 
1071  Parameters
1072  ----------
1073  band : `str`
1074  psf : `lsst.meas.extensions.psfex.psfexPsf.PsfexPsf`
1075  The PSF information to use to make the PSF images
1076  fakeCat : `pandas.core.frame.DataFrame`
1077  The catalog of fake sources to be input
1078  image : `lsst.afw.image.exposure.exposure.ExposureF`
1079  The image into which the fake sources should be added
1080  photoCalib : `lsst.afw.image.photoCalib.PhotoCalib`
1081  Photometric calibration to be used to calibrate the fake sources
1082 
1083  Yields
1084  -------
1085  starImages : `generator`
1086  A generator of tuples of `lsst.afw.image.ImageF` of fake stars and
1087  `lsst.geom.Point2D` of their locations.
1088 
1089  Notes
1090  -----
1091  To take a given magnitude and translate to the number of counts in the image
1092  we use photoCalib.magnitudeToInstFlux, which returns the instrumental flux for the
1093  given calibration radius used in the photometric calibration step.
1094  Thus `calibFluxRadius` should be set to this same radius so that we can normalize
1095  the PSF model to the correct instrumental flux within calibFluxRadius.
1096  """
1097 
1098  self.log.info("Making %d fake star images", len(fakeCat))
1099 
1100  for (index, row) in fakeCat.iterrows():
1101  xy = geom.Point2D(row["x"], row["y"])
1102 
1103  # We put these two PSF calculations within this same try block so that we catch cases
1104  # where the object's position is outside of the image.
1105  try:
1106  correctedFlux = psf.computeApertureFlux(self.config.calibFluxRadius, xy)
1107  starIm = psf.computeImage(xy)
1108  starIm /= correctedFlux
1109 
1110  except InvalidParameterError:
1111  self.log.info("Star at %0.4f, %0.4f outside of image", row["x"], row["y"])
1112  continue
1113 
1114  try:
1115  flux = photoCalib.magnitudeToInstFlux(row['mag'], xy)
1116  except LogicError:
1117  flux = 0
1118 
1119  starIm *= flux
1120  yield ((starIm.convertF(), xy))
1121 
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 851 of file insertFakes.py.

851  def processImagesForInsertion(self, fakeCat, wcs, psf, photoCalib, band, pixelScale):
852  """Process images from files into the format needed for insertion.
853 
854  Parameters
855  ----------
856  fakeCat : `pandas.core.frame.DataFrame`
857  The catalog of fake sources to be input
858  wcs : `lsst.afw.geom.skyWcs.skyWcs.SkyWc`
859  WCS to use to add fake sources
860  psf : `lsst.meas.algorithms.coaddPsf.coaddPsf.CoaddPsf` or
861  `lsst.meas.extensions.psfex.psfexPsf.PsfexPsf`
862  The PSF information to use to make the PSF images
863  photoCalib : `lsst.afw.image.photoCalib.PhotoCalib`
864  Photometric calibration to be used to calibrate the fake sources
865  band : `str`
866  The filter band that the observation was taken in.
867  pixelScale : `float`
868  The pixel scale of the image the sources are to be added to.
869 
870  Returns
871  -------
872  galImages : `list`
873  A list of tuples of `lsst.afw.image.exposure.exposure.ExposureF` and
874  `lsst.geom.Point2D` of their locations.
875  For sources labelled as galaxy.
876  starImages : `list`
877  A list of tuples of `lsst.afw.image.exposure.exposure.ExposureF` and
878  `lsst.geom.Point2D` of their locations.
879  For sources labelled as star.
880 
881  Notes
882  -----
883  The input fakes catalog needs to contain the absolute path to the image in the
884  band that is being used to add images to. It also needs to have the R.A. and
885  declination of the fake source in radians and the sourceType of the object.
886  """
887  galImages = []
888  starImages = []
889 
890  self.log.info("Processing %d fake images", len(fakeCat))
891 
892  for (imFile, sourceType, mag, x, y) in zip(fakeCat[band + "imFilename"].array,
893  fakeCat["sourceType"].array,
894  fakeCat['mag'].array,
895  fakeCat["x"].array, fakeCat["y"].array):
896 
897  im = afwImage.ImageF.readFits(imFile)
898 
899  xy = geom.Point2D(x, y)
900 
901  # We put these two PSF calculations within this same try block so that we catch cases
902  # where the object's position is outside of the image.
903  try:
904  correctedFlux = psf.computeApertureFlux(self.config.calibFluxRadius, xy)
905  psfKernel = psf.computeKernelImage(xy).getArray()
906  psfKernel /= correctedFlux
907 
908  except InvalidParameterError:
909  self.log.info("%s at %0.4f, %0.4f outside of image", sourceType, x, y)
910  continue
911 
912  psfIm = galsim.InterpolatedImage(galsim.Image(psfKernel), scale=pixelScale)
913  galsimIm = galsim.InterpolatedImage(galsim.Image(im.array), scale=pixelScale)
914  convIm = galsim.Convolve([galsimIm, psfIm])
915 
916  try:
917  outIm = convIm.drawImage(scale=pixelScale, method="real_space").array
918  except (galsim.errors.GalSimFFTSizeError, MemoryError):
919  continue
920 
921  imSum = np.sum(outIm)
922  divIm = outIm/imSum
923 
924  try:
925  flux = photoCalib.magnitudeToInstFlux(mag, xy)
926  except LogicError:
927  flux = 0
928 
929  imWithFlux = flux*divIm
930 
931  if sourceType == b"galaxy":
932  galImages.append((afwImage.ImageF(imWithFlux), xy))
933  if sourceType == b"star":
934  starImages.append((afwImage.ImageF(imWithFlux), xy))
935 
936  return galImages, starImages
937 
def processImagesForInsertion(self, fakeCat, wcs, psf, photoCalib, band, pixelScale)
Definition: insertFakes.py:851

◆ trimFakeCat()

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

`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 962 of file insertFakes.py.

962  def trimFakeCat(self, fakeCat, image):
963  """Trim the fake cat to about the size of the input image.
964 
965  `fakeCat` must be processed with addPixCoords before using this method.
966 
967  Parameters
968  ----------
969  fakeCat : `pandas.core.frame.DataFrame`
970  The catalog of fake sources to be input
971  image : `lsst.afw.image.exposure.exposure.ExposureF`
972  The image into which the fake sources should be added
973 
974  Returns
975  -------
976  fakeCat : `pandas.core.frame.DataFrame`
977  The original fakeCat trimmed to the area of the image
978  """
979 
980  bbox = Box2D(image.getBBox()).dilatedBy(self.config.trimBuffer)
981  xs = fakeCat["x"].values
982  ys = fakeCat["y"].values
983 
984  isContained = xs >= bbox.minX
985  isContained &= xs <= bbox.maxX
986  isContained &= ys >= bbox.minY
987  isContained &= ys <= bbox.maxY
988 
989  return fakeCat[isContained]
990 
def trimFakeCat(self, fakeCat, image)
Definition: insertFakes.py:962

Variable Documentation

◆ fakeCat

lsst.pipe.tasks.insertFakes.fakeCat = fakeCat.rename(columns=replace_dict, copy=False)
# 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,
)

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",
)

# 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",
)

# 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` 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` 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 685 of file insertFakes.py.