lsst.pipe.tasks gc8e401de96+03fd671baa
Loading...
Searching...
No Matches
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 1224 of file insertFakes.py.

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

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

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

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

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

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

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):

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.