lsst.pipe.tasks g1d60b36b41+87fc17aa12
Loading...
Searching...
No Matches
Classes | Functions | Variables
lsst.pipe.tasks.insertFakes Namespace Reference

Classes

class  InsertFakesConnections
 

Functions

 _add_fake_sources (exposure, objects, calibFluxRadius=12.0, logger=None)
 
 _isWCSGalsimDefault (wcs, hdr)
 
 processImagesForInsertion (self, fakeCat, wcs, psf, photoCalib, band, pixelScale)
 
 addPixCoords (self, fakeCat, image)
 
 trimFakeCat (self, fakeCat, image)
 
 mkFakeGalsimGalaxies (self, fakeCat, band, photoCalib, pixelScale, psf, image)
 
 mkFakeStars (self, fakeCat, band, photoCalib, psf, image)
 
 cleanCat (self, fakeCat, starCheckVal)
 
 addFakeSources (self, image, fakeImages, sourceType)
 

Variables

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

Detailed Description

Insert fakes into deepCoadds

Function Documentation

◆ _add_fake_sources()

lsst.pipe.tasks.insertFakes._add_fake_sources ( exposure,
objects,
calibFluxRadius = 12.0,
logger = None )
protected
Add fake sources to the given exposure

Parameters
----------
exposure : `lsst.afw.image.exposure.exposure.ExposureF`
    The exposure into which the fake sources should be added
objects : `typing.Iterator` [`tuple` ['lsst.geom.SpherePoint`, `galsim.GSObject`]]
    An iterator of tuples that contains (or generates) locations and object
    surface brightness profiles to inject.
calibFluxRadius : `float`, optional
    Aperture radius (in pixels) used to define the calibration for this
    exposure+catalog.  This is used to produce the correct instrumental fluxes
    within the radius.  The value should match that of the field defined in
    slot_CalibFlux_instFlux.
logger : `lsst.log.log.log.Log` or `logging.Logger`, optional
    Logger.

Definition at line 44 of file insertFakes.py.

◆ _isWCSGalsimDefault()

lsst.pipe.tasks.insertFakes._isWCSGalsimDefault ( wcs,
hdr )
protected
Decide if wcs = galsim.PixelScale(1.0) is explicitly present in header,
or if it's just the galsim default.

Parameters
----------
wcs : galsim.BaseWCS
    Potentially default WCS.
hdr : galsim.fits.FitsHeader
    Header as read in by galsim.

Returns
-------
isDefault : bool
    True if default, False if explicitly set in header.

Definition at line 145 of file insertFakes.py.

◆ addFakeSources()

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

◆ addPixCoords()

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

◆ cleanCat()

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

◆ mkFakeGalsimGalaxies()

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

◆ mkFakeStars()

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

◆ processImagesForInsertion()

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

◆ trimFakeCat()

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

Variable Documentation

◆ bitmask

lsst.pipe.tasks.insertFakes.bitmask

Definition at line 1266 of file insertFakes.py.

◆ linWcs

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

Definition at line 890 of file insertFakes.py.

◆ mat

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

Definition at line 891 of file insertFakes.py.

◆ obj

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

Definition at line 900 of file insertFakes.py.

◆ wcs

lsst.pipe.tasks.insertFakes.wcs

Definition at line 892 of file insertFakes.py.