lsst.pipe.tasks gd5638573c2+392ae78cd2
Loading...
Searching...
No Matches
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()

_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 : `logging.Logger`, optional
    Logger.

◆ _isWCSGalsimDefault()

_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.

◆ addFakeSources()

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.

◆ addPixCoords()

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`

◆ cleanCat()

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

◆ mkFakeGalsimGalaxies()

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.

◆ mkFakeStars()

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.

◆ processImagesForInsertion()

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.

◆ trimFakeCat()

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