lsst.pipe.tasks gcf00bf066d+02752e367a
Loading...
Searching...
No Matches
lsst.pipe.tasks.calibrateImage.CalibrateImageTask Class Reference
Inheritance diagram for lsst.pipe.tasks.calibrateImage.CalibrateImageTask:

Public Member Functions

 __init__ (self, initial_stars_schema=None, **kwargs)
 
 runQuantum (self, butlerQC, inputRefs, outputRefs)
 
 run (self, *, exposures, id_generator=None, result=None, background_flat=None, illumination_correction=None, camera_model=None, exposure_record=None)
 

Public Attributes

 psf_schema = afwTable.SourceTable.makeMinimalSchema()
 
tuple psf_fields
 
 initial_stars_schema
 

Static Public Attributes

 ConfigClass = CalibrateImageConfig
 

Protected Member Functions

 _apply_illumination_correction (self, exposure, background_flat, illumination_correction)
 
 _compute_psf (self, result, id_generator)
 
 _measure_aperture_correction (self, exposure, bright_sources)
 
 _find_stars (self, exposure, background, id_generator, background_to_photometric_ratio=None, adaptive_det_res_struct=None, num_astrometry_matches=None)
 
 _match_psf_stars (self, psf_stars, stars, psfSigma=None)
 
 _fit_astrometry (self, exposure, stars)
 
 _fit_photometry (self, exposure, stars)
 
 _apply_photometry (self, exposure, background, background_to_photometric_ratio=None)
 
 _summarize (self, exposure, stars, background)
 
 _recordMaskedPixelFractions (self, exposure)
 
 _update_wcs_with_camera_model (self, exposure, cameraModel, exposure_record=None)
 
 _compute_mask_fraction (self, mask, mask_planes, bad_mask_planes)
 
 _compute_per_amp_fraction (self, exposure, detected_fraction, mask_planes, bad_mask_planes)
 
 _remeasure_star_background (self, result, background_to_photometric_ratio=None)
 

Static Protected Attributes

str _DefaultName = "calibrateImage"
 

Detailed Description

Compute the PSF, aperture corrections, astrometric and photometric
calibrations, and summary statistics for a single science exposure, and
produce a catalog of brighter stars that were used to calibrate it.

Parameters
----------
initial_stars_schema : `lsst.afw.table.Schema`
    Schema of the initial_stars output catalog.

Definition at line 709 of file calibrateImage.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.__init__ ( self,
initial_stars_schema = None,
** kwargs )

Definition at line 722 of file calibrateImage.py.

Member Function Documentation

◆ _apply_illumination_correction()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._apply_illumination_correction ( self,
exposure,
background_flat,
illumination_correction )
protected
Apply the illumination correction to a background-flattened image.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure to convert to a photometric-flattened image.
background_flat : `lsst.afw.image.Exposure`
    Flat image that had previously been applied to exposure.
illumination_correction : `lsst.afw.image.Exposure`
    Illumination correction image to convert to photometric-flattened
    image.

Returns
-------
background_to_photometric_ratio : `lsst.afw.image.Image`
    Ratio image to convert a photometric-flattened image to/from
    a background-flattened image. Will be None if task not
    configured to use the illumination correction.

Definition at line 1170 of file calibrateImage.py.

◆ _apply_photometry()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._apply_photometry ( self,
exposure,
background,
background_to_photometric_ratio = None )
protected
Apply the photometric model attached to the exposure to the
exposure's pixels and an associated background model.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure with the target `lsst.afw.image.PhotoCalib` attached.
    On return, pixel values will be calibrated and an identity
    photometric transform will be attached.
background : `lsst.afw.math.BackgroundList`
    Background model to convert to nanojansky units in place.
background_to_photometric_ratio : `lsst.afw.image.Image`, optional
    Image to convert photometric-flattened image to
    background-flattened image.

Definition at line 1682 of file calibrateImage.py.

◆ _compute_mask_fraction()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._compute_mask_fraction ( self,
mask,
mask_planes,
bad_mask_planes )
protected
Evaluate the fraction of masked pixels in a (set of) mask plane(s).

Parameters
----------
mask : `lsst.afw.image.Mask`
    The mask on which to evaluate the fraction.
mask_planes : `list`, `str`
    The mask planes for which to evaluate the fraction.
bad_mask_planes : `list`, `str`
    The mask planes to exclude from the computation.

Returns
-------
detected_fraction : `float`
    The calculated fraction of masked pixels

Definition at line 1784 of file calibrateImage.py.

◆ _compute_per_amp_fraction()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._compute_per_amp_fraction ( self,
exposure,
detected_fraction,
mask_planes,
bad_mask_planes )
protected
Evaluate the maximum per-amplifier fraction of masked pixels.

Parameters
----------
exposure : `lsst.afw.image.ExposureF`
    The exposure on which to compute the per-amp masked fraction.
detected_fraction : `float`
    The current detected_fraction of the ``mask_planes`` for the
    full detector.
mask_planes : `list`, `str`
    The mask planes for which to evaluate the fraction.
bad_mask_planes : `list`, `str`
    The mask planes to exclude from the computation.

Returns
-------
n_above_max_per_amp : `int`
    The number of amplifiers with masked fractions above a maximum
    value (set by the current full-detector ``detected_fraction``).
highest_detected_fraction_per_amp : `float`
    The highest value of the per-amplifier fraction of masked pixels.
no_zero_det_amps : `bool`
    A boolean representing whether any of the amplifiers has zero
    masked pixels.

Definition at line 1812 of file calibrateImage.py.

◆ _compute_psf()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._compute_psf ( self,
result,
id_generator )
protected
Find bright sources detected on an exposure and fit a PSF model to
them, repairing likely cosmic rays before detection.

Repair, detect, measure, and compute PSF twice, to ensure the PSF
model does not include contributions from cosmic rays.

Parameters
----------
result : `lsst.pipe.base.Struct`
    Result struct that is modified to allow saving of partial outputs
    for some failure conditions. Should contain at least the following
    attributes:

    - exposure : `lsst.afw.image.Exposure`
        Exposure to detect and measure bright stars on.
    - background : `lsst.afw.math.BackgroundList` | `None`
        Background that was fit to the exposure during detection.
    - background_to_photometric_ratio : `lsst.afw.image.Image` | `None`
        Image to convert photometric-flattened image to
        background-flattened image.
id_generator : `lsst.meas.base.IdGenerator`
    Object that generates source IDs and provides random seeds.

Returns
-------
sources : `lsst.afw.table.SourceCatalog`
    Catalog of detected bright sources.
cell_set : `lsst.afw.math.SpatialCellSet`
    PSF candidates returned by the psf determiner.
adaptive_det_res_struct : `lsst.pipe.base.Struct`
    Result struct from the adaptive threshold detection.

Notes
-----
This method modifies the exposure, background and
background_to_photometric_ratio attributes of the result struct
in-place.

Definition at line 1215 of file calibrateImage.py.

◆ _find_stars()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._find_stars ( self,
exposure,
background,
id_generator,
background_to_photometric_ratio = None,
adaptive_det_res_struct = None,
num_astrometry_matches = None )
protected
Detect stars on an exposure that has a PSF model, and measure their
PSF, circular aperture, compensated gaussian fluxes.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure to detect and measure stars on.
background : `lsst.afw.math.BackgroundList`
    Background that was fit to the exposure during detection;
    modified in-place during subsequent detection.
id_generator : `lsst.meas.base.IdGenerator`
    Object that generates source IDs and provides random seeds.
background_to_photometric_ratio : `lsst.afw.image.Image`, optional
    Image to convert photometric-flattened image to
    background-flattened image.

Returns
-------
stars : `SourceCatalog`
    Sources that are very likely to be stars, with a limited set of
    measurements performed on them.

Definition at line 1393 of file calibrateImage.py.

◆ _fit_astrometry()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._fit_astrometry ( self,
exposure,
stars )
protected
Fit an astrometric model to the data and return the reference
matches used in the fit, and the fitted WCS.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure that is being fit, to get PSF and other metadata from.
    Modified to add the fitted skyWcs.
stars : `SourceCatalog`
    Good stars selected for use in calibration, with RA/Dec coordinates
    computed from the pixel positions and fitted WCS.

Returns
-------
matches : `list` [`lsst.afw.table.ReferenceMatch`]
    Reference/stars matches used in the fit.

Definition at line 1605 of file calibrateImage.py.

◆ _fit_photometry()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._fit_photometry ( self,
exposure,
stars )
protected
Fit a photometric model to the data and return the reference
matches used in the fit, and the fitted PhotoCalib.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure that is being fit, to get PSF and other metadata from.
    Has the fit `lsst.afw.image.PhotoCalib` attached, with pixel values
    unchanged.
stars : `lsst.afw.table.SourceCatalog`
    Good stars selected for use in calibration.
background : `lsst.afw.math.BackgroundList`
    Background that was fit to the exposure during detection of the
    above stars.

Returns
-------
calibrated_stars : `lsst.afw.table.SourceCatalog`
    Star catalog with flux/magnitude columns computed from the fitted
    photoCalib (instFlux columns are retained as well).
matches : `list` [`lsst.afw.table.ReferenceMatch`]
    Reference/stars matches used in the fit.
matchMeta : `lsst.daf.base.PropertyList`
    Metadata needed to unpersist matches, as returned by the matcher.
photo_calib : `lsst.afw.image.PhotoCalib`
    Photometric calibration that was fit to the star catalog.

Definition at line 1649 of file calibrateImage.py.

◆ _match_psf_stars()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._match_psf_stars ( self,
psf_stars,
stars,
psfSigma = None )
protected
Match calibration stars to psf stars, to identify which were psf
candidates, and which were used or reserved during psf measurement
and the astrometric fit.

Parameters
----------
psf_stars : `lsst.afw.table.SourceCatalog`
    PSF candidate stars that were sent to the psf determiner and
    used in the astrometric fit. Used to populate psf and astrometry
    related flag fields.
stars : `lsst.afw.table.SourceCatalog`
    Stars that will be used for calibration; psf-related fields will
    be updated in-place.

Notes
-----
This code was adapted from CalibrateTask.copyIcSourceFields().

Definition at line 1541 of file calibrateImage.py.

◆ _measure_aperture_correction()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._measure_aperture_correction ( self,
exposure,
bright_sources )
protected
Measure and set the ApCorrMap on the Exposure, using
previously-measured bright sources.

This function first normalizes the calibration flux and then
the full set of aperture corrections are measured relative
to this normalized calibration flux.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure to set the ApCorrMap on.
bright_sources : `lsst.afw.table.SourceCatalog`
    Catalog of detected bright sources; modified to include columns
    necessary for point source determination for the aperture
    correction calculation.

Definition at line 1363 of file calibrateImage.py.

◆ _recordMaskedPixelFractions()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._recordMaskedPixelFractions ( self,
exposure )
protected
Record the fraction of all the pixels in an exposure
that are masked with a given flag. Each fraction is
recorded in the task metadata. One record per flag type.

Parameters
----------
exposure : `lsst.afw.image.ExposureF`
    The target exposure to calculate masked pixel fractions for.

Definition at line 1735 of file calibrateImage.py.

◆ _remeasure_star_background()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._remeasure_star_background ( self,
result,
background_to_photometric_ratio = None )
protected
Remeasure the exposure's background with iterative adaptive
threshold detection.

Parameters
----------
result : `lsst.pipe.base.Struct`
    The current state of the result Strut from the run method of
    CalibrateImageTask.  Will be modified in place.
background_to_photometric_ratio : `lsst.afw.image.Image`, optional
    Image to convert photometric-flattened image to
    background-flattened image.

Returns
-------
result : `lsst.pipe.base.Struct`
    The modified result Struct with the new background subtracted.

Definition at line 1873 of file calibrateImage.py.

◆ _summarize()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._summarize ( self,
exposure,
stars,
background )
protected
Compute summary statistics on the exposure and update in-place the
calibrations attached to it.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure that was calibrated, to get PSF and other metadata from.
    Should be in instrumental units with the photometric calibration
    attached.
    Modified to contain the computed summary statistics.
stars : `SourceCatalog`
    Good stars selected used in calibration.
background : `lsst.afw.math.BackgroundList`
    Background that was fit to the exposure during detection of the
    above stars.  Should be in instrumental units.

Definition at line 1715 of file calibrateImage.py.

◆ _update_wcs_with_camera_model()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._update_wcs_with_camera_model ( self,
exposure,
cameraModel,
exposure_record = None )
protected
Replace the existing WCS with one generated using the pointing
and the input camera model.

Parameters
----------
exposure : `lsst.afw.image.ExposureF`
    The exposure whose WCS will be updated.
cameraModel : `lsst.afw.cameraGeom.Camera`
    Camera to be used when constructing updated WCS.
exposure_record : `lsst.daf.butler.DimensionRecord`, optional
    Butler metadata for the ``exposure`` dimension.  Used if
    constructing an updated WCS instead of the boresight and
    orientation angle from the visit info.

Definition at line 1753 of file calibrateImage.py.

◆ run()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.run ( self,
* ,
exposures,
id_generator = None,
result = None,
background_flat = None,
illumination_correction = None,
camera_model = None,
exposure_record = None )
Find stars and perform psf measurement, then do a deeper detection
and measurement and calibrate astrometry and photometry from that.

Parameters
----------
exposures : `lsst.afw.image.Exposure` or \
            `list` [`lsst.afw.image.Exposure`]
    Post-ISR exposure(s), with an initial WCS, VisitInfo, and Filter.
    Modified in-place during processing if only one is passed.
    If two exposures are passed, treat them as snaps and combine
    before doing further processing.
id_generator : `lsst.meas.base.IdGenerator`, optional
    Object that generates source IDs and provides random seeds.
result : `lsst.pipe.base.Struct`, optional
    Result struct that is modified to allow saving of partial outputs
    for some failure conditions. If the task completes successfully,
    this is also returned.
background_flat : `lsst.afw.image.Exposure`, optional
    Background flat-field image.
illumination_correction : `lsst.afw.image.Exposure`, optional
    Illumination correction image.
camera_model : `lsst.afw.cameraGeom.Camera`, optional
    Camera to be used if constructing updated WCS.
exposure_record : `lsst.daf.butler.DimensionRecord`, optional
    Butler metadata for the ``exposure`` dimension.  Used if
    constructing an updated WCS instead of the boresight and
    orientation angle from the visit info.

Returns
-------
result : `lsst.pipe.base.Struct`
    Results as a struct with attributes:

    ``exposure``
        Calibrated exposure, with pixels in nJy units.
        (`lsst.afw.image.Exposure`)
    ``stars``
        Stars that were used to calibrate the exposure, with
        calibrated fluxes and magnitudes.
        (`astropy.table.Table`)
    ``stars_footprints``
        Footprints of stars that were used to calibrate the exposure.
        (`lsst.afw.table.SourceCatalog`)
    ``psf_stars``
        Stars that were used to determine the image PSF.
        (`astropy.table.Table`)
    ``psf_stars_footprints``
        Footprints of stars that were used to determine the image PSF.
        (`lsst.afw.table.SourceCatalog`)
    ``background``
        Background that was fit to the exposure when detecting
        ``stars``. (`lsst.afw.math.BackgroundList`)
    ``applied_photo_calib``
        Photometric calibration that was fit to the star catalog and
        applied to the exposure. (`lsst.afw.image.PhotoCalib`)
        This is `None` if ``config.do_calibrate_pixels`` is `False`.
    ``astrometry_matches``
        Reference catalog stars matches used in the astrometric fit.
        (`list` [`lsst.afw.table.ReferenceMatch`] or
        `lsst.afw.table.BaseCatalog`).
    ``photometry_matches``
        Reference catalog stars matches used in the photometric fit.
        (`list` [`lsst.afw.table.ReferenceMatch`] or
        `lsst.afw.table.BaseCatalog`).
    ``mask``
        Copy of the mask plane of `exposure`.
        (`lsst.afw.image.Mask`)

Definition at line 878 of file calibrateImage.py.

◆ runQuantum()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.runQuantum ( self,
butlerQC,
inputRefs,
outputRefs )

Definition at line 799 of file calibrateImage.py.

Member Data Documentation

◆ _DefaultName

str lsst.pipe.tasks.calibrateImage.CalibrateImageTask._DefaultName = "calibrateImage"
staticprotected

Definition at line 719 of file calibrateImage.py.

◆ ConfigClass

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.ConfigClass = CalibrateImageConfig
static

Definition at line 720 of file calibrateImage.py.

◆ initial_stars_schema

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.initial_stars_schema
Initial value:
= dummy_photo_calib.calibrateCatalog(
afwTable.SourceCatalog(initial_stars_schema)
)

Definition at line 795 of file calibrateImage.py.

◆ psf_fields

tuple lsst.pipe.tasks.calibrateImage.CalibrateImageTask.psf_fields
Initial value:
= ("calib_psf_candidate", "calib_psf_used", "calib_psf_reserved",
"calib_astrometry_used",
# TODO DM-39203:
# these can be removed once apcorr is gone.
"apcorr_slot_CalibFlux_used", "apcorr_base_GaussianFlux_used",
"apcorr_base_PsfFlux_used",)

Definition at line 752 of file calibrateImage.py.

◆ psf_schema

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.psf_schema = afwTable.SourceTable.makeMinimalSchema()

Definition at line 730 of file calibrateImage.py.


The documentation for this class was generated from the following file: