CalibrateImageTask

CalibrateImageTask performs “single frame processing” on one (single visit) or two (two snap visit) post- Instrument Signature Removal single detector exposure (post_isr_image). This involves merging two snaps (if provided) into one visit exposure, repairing cosmic rays and defects, detecting and measuring sources on the exposure to make an initial estimation of the point spread function (PSF), using that same catalog of psf stars to compute the astrometric calibration, then re-doing detection and measurement with the fitted PSF to compute the photometric calibrations, and computing summary statistics of the exposure and measured catalog. Its primary outputs are a calibrated, background-subtracted exposure (preliminary_visit_image, pixel values in nanojansky) and catalog (single_visit_star_unstandardized) of bright, well-measured point-like sources that were used as inputs to calibration and that are suitable for downstream use (for example as kernel candidates in difference imaging). This task replaces the two older tasks CharacterizeImageTask (roughly: repair/estimate PSF/aperture correct) and CalibrateTask (roughly: detect/measure/astrometry/photometry).

Processing summary

CalibrateImageTask runs this sequence of operations:

  1. If two snap exposures are input, combine them into one visit exposure.

  2. Find stars to estimate the PSF, via two passes of repair/detect/measure/estimate PSF:

    1. Install a simple Gaussian PSF in the exposure and subtract an initial estimate of the image background.

    2. Perform cosmic ray repair, source detection to S/N>=50, and a minimal list of measurement plugins to compute a first estimate of the PSF.

    3. Install an updated Gaussian PSF representation of that first PSF estimate (to reduce noise and help with convergence) and re-run repair/detect/measure/estimate PSF as above.

    4. Use that final fitted PSF to redo repair and measurement (hopefully with all cosmic rays now removed), resulting in the optional single_visit_psf_star and single_visit_psf_star_footprints output catalogs. Note that these catalogs do not have sky coordinates or calibrated fluxes.

  3. Compute an aperture correction for the exposure using the final catalog measured after the PSF fit.

  4. Perform astrometric fit

    1. Use sources flagged as calib_psf_candidate from the PSF model catalog above, single_visit_psf_star_footprints, in the astrometric calibration.

    2. Fit the astrometry to a reference catalog using an affine WCS fitter that requires a reasonable model of the camera geometry, to produce a SkyWcs for the exposure and compute on-sky coordinates for the catalog of stars. The star/refcat matches used in the astrometric fit is saved as the optional initial_astrometry_match_detector catalog.

  5. Find stars to use as potential photometric calibration sources:

    1. Detect sources with a peak S/N>=10.

    2. For the detected sources, deblend, measure, aperture correct, and set flags based on blendedness, footprint size, and other properties.

    3. Select non-“bad” flagged, unresolved, S/N>=10 sources to pass to the subsequent calibration steps and to be saved as the single_visit_star_unstandardized and single_visit_psf_star_footprints output catalogs. Note that these catalogs do not have sky coordinates or calibrated fluxes: those are computed at a later step.

  6. Match the list of stars from the two steps above, to propagate flags (e.g. calib_psf_candidate, calib_psf_used, and calib_astrometry_used) from the psf/astrometry stars catalog into the second, primary output catalog.

  7. The steps above perform several rounds of background fitting, which together are saved as the preliminary_visit_image_background output; this saved background has been calibrated to be in the same nJy units as the preliminary_visit_image output exposure.

  8. Fit the photometry to a reference catalog, to produce a PhotoCalib for the exposure and calibrate both the image and catalog of stars to have pixels and fluxes respectively in nanojansky. Note that this results in the output exposure having a PhotoCalib identically 1; the applied PhotoCalib is saved as the initial_photoCalib_detector output. The star/refcat matches used in the photometric fit is saved as the optional initial_photometry_match_detector catalog.

  9. Finally, the measurements and fits performed above are combined into a variety of summary statistics which are attached to the exposure, which is saved as the preliminary_visit_image output.

Python API summary

from lsst.pipe.tasks.calibrateImage import CalibrateImageTask
classCalibrateImageTask(initial_stars_schema=None, **kwargs)

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

attributeconfig

Access configuration fields and retargetable subtasks.

methodrun(*, exposures, id_generator=None, result=None, background_flat=None, illumination_correction=None)

Find stars and perform psf measurement, then do a deeper detection and measurement and calibrate astrometry and photometry from that...

See also

See the CalibrateImageTask API reference for complete details.

Retargetable subtasks

astrometry

Default

lsst.meas.astrom.astrometry.AstrometryTask

Field type

ConfigurableField

Task to perform astrometric calibration to fit a WCS.

compute_summary_stats

Default

lsst.pipe.tasks.computeExposureSummaryStats.ComputeExposureSummaryStatsTask

Field type

ConfigurableField

Task to to compute summary statistics on the calibrated exposure.

install_simple_psf

Default

lsst.meas.algorithms.installGaussianPsf.InstallGaussianPsfTask

Field type

ConfigurableField

Task to install a simple PSF model into the input exposure to use when detecting bright sources for PSF estimation.

measure_aperture_correction

Default

lsst.meas.algorithms.measureApCorr.MeasureApCorrTask

Field type

ConfigurableField

Task to compute the aperture correction from the bright stars.

photometry

Default

lsst.pipe.tasks.photoCal.PhotoCalTask

Field type

ConfigurableField

Task to perform photometric calibration to fit a PhotoCalib.

psf_detection

Default

lsst.meas.algorithms.detection.SourceDetectionTask

Field type

ConfigurableField

Task to detect sources for PSF determination.

psf_measure_psf

Default

lsst.pipe.tasks.measurePsf.MeasurePsfTask

Field type

ConfigurableField

Task to measure the psf on bright sources.

psf_normalized_calibration_flux

Default

lsst.meas.algorithms.normalizedCalibrationFlux.NormalizedCalibrationFluxTask

Field type

ConfigurableField

Task to normalize the calibration flux (e.g. compensated tophats) for the bright stars used for psf estimation.

psf_repair

Default

lsst.pipe.tasks.repair.RepairTask

Field type

ConfigurableField

Task to repair cosmic rays on the exposure before PSF determination.

psf_source_measurement

Default

lsst.meas.base.sfm.SingleFrameMeasurementTask

Field type

ConfigurableField

Task to measure sources to be used for psf estimation.

psf_subtract_background

Default

lsst.meas.algorithms.subtractBackground.SubtractBackgroundTask

Field type

ConfigurableField

Task to perform intial background subtraction, before first detection pass.

snap_combine

Default

lsst.pipe.tasks.snapCombine.SnapCombineTask

Field type

ConfigurableField

Task to combine two snaps to make one exposure.

star_apply_aperture_correction

Default

lsst.meas.base.applyApCorr.ApplyApCorrTask

Field type

ConfigurableField

Task to apply aperture corrections to the selected stars.

star_catalog_calculation

Default

lsst.meas.base.catalogCalculation.CatalogCalculationTask

Field type

ConfigurableField

Task to compute extendedness values on the star catalog, for the star selector to remove extended sources.

star_deblend

Default

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask

Field type

ConfigurableField

Split blended sources into their components.

star_detection

Default

lsst.meas.algorithms.detection.SourceDetectionTask

Field type

ConfigurableField

Task to detect stars to return in the output catalog.

star_measurement

Default

lsst.meas.base.sfm.SingleFrameMeasurementTask

Field type

ConfigurableField

Task to measure stars to return in the output catalog.

star_normalized_calibration_flux

Default

lsst.meas.algorithms.normalizedCalibrationFlux.NormalizedCalibrationFluxTask

Field type

ConfigurableField

Task to apply the normalization for calibration fluxes (e.g. compensated tophats) for the final output star catalog.

star_selector

Default
'science'
Field type

Single-selection RegistryField

Choices
'science'

lsst.meas.algorithms.sourceSelector.ScienceSourceSelectorTask

'references'

lsst.meas.algorithms.sourceSelector.ReferenceSourceSelectorTask

'null'

lsst.meas.algorithms.sourceSelector.NullSourceSelectorTask

'objectSize'

lsst.meas.algorithms.objectSizeStarSelector.ObjectSizeStarSelectorTask

'flagged'

lsst.meas.algorithms.flaggedSourceSelector.FlaggedSourceSelectorTask

Task to select reliable stars to use for calibration.

star_set_primary_flags

Default

lsst.meas.algorithms.setPrimaryFlags.SetPrimaryFlagsTask

Field type

ConfigurableField

Task to add isPrimary to the catalog.

star_sky_sources

Default

lsst.meas.algorithms.skyObjects.SkyObjectsTask

Field type

ConfigurableField

Task to generate sky sources (‘empty’ regions where there are no detections).

Configuration fields

astrometry_ref_loader

Data type

lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsConfig

Field type

ConfigField

Configuration of reference object loader for astrometric fit.

connections

Data type

lsst.pipe.base.config.CalibrateImageConfigConnections

Field type

ConfigField

Configurations describing the connections of the PipelineTask to datatypes

do_calibrate_pixels

Default
True
Field type

bool Field

If True, apply the photometric calibration to the image pixels and background model, and attach an identity PhotoCalib to the output image to reflect this. If False`, leave the image and background uncalibrated and attach the PhotoCalib that maps them to physical units.

do_downsample_footprints

Default
False
Field type

bool Field

Downsample footprints prior to deblending to optimize speed?

do_illumination_correction

Default
False
Field type

bool Field

If True, apply the illumination correction. This assumes that the input image has already been flat-fielded such that it is suitable for background subtraction.

do_include_astrometric_errors

Default
True
Field type

bool Field

If True, include astrometric errors in the output catalog.

downsample_max_footprints

Default
1000
Field type

int Field

Maximum number of non-sky-source footprints to use if do_downsample_footprints is True,

id_generator

Data type

lsst.meas.base._id_generator.DetectorVisitIdGeneratorConfig

Field type

ConfigField

Configuration for how to generate catalog IDs from data IDs.

optional_outputs

Default
['psf_stars', 'psf_stars_footprints', 'astrometry_matches', 'photometry_matches']
Field type

str ListField

Which optional outputs to save (as their connection name)?

photometry_ref_loader

Data type

lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsConfig

Field type

ConfigField

Configuration of reference object loader for photometric fit.

saveLogOutput

Default
True
Field type

bool Field

Flag to enable/disable saving of log output for a task, enabled by default.

In Depth

Catalog cross-matching

The catalog of calibrated stars (single_visit_star_unstandardized) produced by this task has different source ids than the catalog of stars that were detected for PSF determination (single_visit_psf_star), because those subtasks used different detection configurations. The stars catalog contains a psf_id field, which if non-zero is the source id of the corresponding record in the psf stars catalog. This also applies to the reference/source match catalogs for astrometry (initial_astrometry_match_detector) and photometry (initial_photometry_match_detector). We use the psf star catalog for the astrometry fit, so the src_id values in the astrometry match catalog refer to the psf stars, not the calibrated stars.

For how to find the matching objects in the respective astropy Table output catalogs, see this example:

import esutil

matches = esutil.numpy_util.match(psf_stars["id"], stars["psf_id"])
# psf_stars[matches[0]] and stars[matched[1]] are the matching objects.

matches = esutil.numpy_util.match(astrometry_matches["src_id"], photometry_matches["src_psf_id"])
# astrometry_matches[matches[0]] and photometry_matches[matched[1]] are the matching objects.

Warning

Only boolean index arrays are supported on lsst.afw.table Catalogs, so you cannot use the matched index arrays shown in the examples above with the astrometry_matches or photometry_matches catalogs directly. You can instead access by column first, or convert the table to astropy:

# raises error
astrometry_matches[matches[0]]

# column-first access
ra = astrometry_matches["src_ra"][matches[0]]
dec = astrometry_matches["src_dec"][matches[0]]

# astropy conversion
astrometry_matches_astropy = astrometry_matches.asAstropy()
astrometry_matches_astropy[matches[0]]  # all columns