LSST Applications g0603fd7c41+501e3db9f9,g0aad566f14+23d8574c86,g0dd44d6229+a1a4c8b791,g2079a07aa2+86d27d4dc4,g2305ad1205+a62672bbc1,g2bbee38e9b+047b288a59,g337abbeb29+047b288a59,g33d1c0ed96+047b288a59,g3a166c0a6a+047b288a59,g3d1719c13e+23d8574c86,g487adcacf7+cb7fd919b2,g4be5004598+23d8574c86,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+4a9e435310,g63cd9335cc+585e252eca,g858d7b2824+23d8574c86,g88963caddf+0cb8e002cc,g99cad8db69+43388bcaec,g9ddcbc5298+9a081db1e4,ga1e77700b3+a912195c07,gae0086650b+585e252eca,gb0e22166c9+60f28cb32d,gb2522980b2+793639e996,gb3a676b8dc+b4feba26a1,gb4b16eec92+63f8520565,gba4ed39666+c2a2e4ac27,gbb8dafda3b+a5d255a82e,gc120e1dc64+d820f8acdb,gc28159a63d+047b288a59,gc3e9b769f7+f4f1cc6b50,gcf0d15dbbd+a1a4c8b791,gdaeeff99f8+f9a426f77a,gdb0af172c8+b6d5496702,ge79ae78c31+047b288a59,w.2024.19
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Attributes | List of all members
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)
 

Public Attributes

 psf_schema
 
 psf_fields
 
 initial_stars_schema
 

Static Public Attributes

 ConfigClass = CalibrateImageConfig
 

Protected Member Functions

 _handle_snaps (self, exposure)
 
 _compute_psf (self, exposure, id_generator)
 
 _measure_aperture_correction (self, exposure, bright_sources)
 
 _find_stars (self, exposure, background, id_generator)
 
 _match_psf_stars (self, psf_stars, stars)
 
 _fit_astrometry (self, exposure, stars)
 
 _fit_photometry (self, exposure, stars)
 
 _summarize (self, exposure, stars, background)
 

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 352 of file calibrateImage.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 365 of file calibrateImage.py.

365 def __init__(self, initial_stars_schema=None, **kwargs):
366 super().__init__(**kwargs)
367
368 self.makeSubtask("snap_combine")
369
370 # PSF determination subtasks
371 self.makeSubtask("install_simple_psf")
372 self.makeSubtask("psf_repair")
373 self.makeSubtask("psf_subtract_background")
374 self.psf_schema = afwTable.SourceTable.makeMinimalSchema()
375 self.makeSubtask("psf_detection", schema=self.psf_schema)
376 self.makeSubtask("psf_source_measurement", schema=self.psf_schema)
377 self.makeSubtask("psf_measure_psf", schema=self.psf_schema)
378
379 self.makeSubtask("measure_aperture_correction", schema=self.psf_schema)
380
381 # star measurement subtasks
382 if initial_stars_schema is None:
383 initial_stars_schema = afwTable.SourceTable.makeMinimalSchema()
384
385 # These fields let us track which sources were used for psf and
386 # aperture correction calculations.
387 self.psf_fields = ("calib_psf_candidate", "calib_psf_used", "calib_psf_reserved",
388 # TODO DM-39203: these can be removed once apcorr is gone.
389 "apcorr_slot_CalibFlux_used", "apcorr_base_GaussianFlux_used",
390 "apcorr_base_PsfFlux_used")
391 for field in self.psf_fields:
392 item = self.psf_schema.find(field)
393 initial_stars_schema.addField(item.getField())
394
395 afwTable.CoordKey.addErrorFields(initial_stars_schema)
396 self.makeSubtask("star_detection", schema=initial_stars_schema)
397 self.makeSubtask("star_sky_sources", schema=initial_stars_schema)
398 self.makeSubtask("star_deblend", schema=initial_stars_schema)
399 self.makeSubtask("star_measurement", schema=initial_stars_schema)
400 self.makeSubtask("star_apply_aperture_correction", schema=initial_stars_schema)
401 self.makeSubtask("star_catalog_calculation", schema=initial_stars_schema)
402 self.makeSubtask("star_set_primary_flags", schema=initial_stars_schema, isSingleFrame=True)
403 self.makeSubtask("star_selector")
404
405 self.makeSubtask("astrometry", schema=initial_stars_schema)
406 self.makeSubtask("photometry", schema=initial_stars_schema)
407
408 self.makeSubtask("compute_summary_stats")
409
410 # For the butler to persist it.
411 self.initial_stars_schema = afwTable.SourceCatalog(initial_stars_schema)
412

Member Function Documentation

◆ _compute_psf()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._compute_psf ( self,
exposure,
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
----------
exposure : `lsst.afw.image.Exposure`
    Exposure to detect and measure bright stars on.
id_generator : `lsst.meas.base.IdGenerator`, optional
    Object that generates source IDs and provides random seeds.

Returns
-------
sources : `lsst.afw.table.SourceCatalog`
    Catalog of detected bright sources.
background : `lsst.afw.math.BackgroundList`
    Background that was fit to the exposure during detection.
cell_set : `lsst.afw.math.SpatialCellSet`
    PSF candidates returned by the psf determiner.

Definition at line 580 of file calibrateImage.py.

580 def _compute_psf(self, exposure, id_generator):
581 """Find bright sources detected on an exposure and fit a PSF model to
582 them, repairing likely cosmic rays before detection.
583
584 Repair, detect, measure, and compute PSF twice, to ensure the PSF
585 model does not include contributions from cosmic rays.
586
587 Parameters
588 ----------
589 exposure : `lsst.afw.image.Exposure`
590 Exposure to detect and measure bright stars on.
591 id_generator : `lsst.meas.base.IdGenerator`, optional
592 Object that generates source IDs and provides random seeds.
593
594 Returns
595 -------
596 sources : `lsst.afw.table.SourceCatalog`
597 Catalog of detected bright sources.
598 background : `lsst.afw.math.BackgroundList`
599 Background that was fit to the exposure during detection.
600 cell_set : `lsst.afw.math.SpatialCellSet`
601 PSF candidates returned by the psf determiner.
602 """
603 def log_psf(msg):
604 """Log the parameters of the psf and background, with a prepended
605 message.
606 """
607 position = exposure.psf.getAveragePosition()
608 sigma = exposure.psf.computeShape(position).getDeterminantRadius()
609 dimensions = exposure.psf.computeImage(position).getDimensions()
610 median_background = np.median(background.getImage().array)
611 self.log.info("%s sigma=%0.4f, dimensions=%s; median background=%0.2f",
612 msg, sigma, dimensions, median_background)
613
614 self.log.info("First pass detection with Guassian PSF FWHM=%s pixels",
615 self.config.install_simple_psf.fwhm)
616 self.install_simple_psf.run(exposure=exposure)
617
618 background = self.psf_subtract_background.run(exposure=exposure).background
619 log_psf("Initial PSF:")
620 self.psf_repair.run(exposure=exposure, keepCRs=True)
621
622 table = afwTable.SourceTable.make(self.psf_schema, id_generator.make_table_id_factory())
623 # Re-estimate the background during this detection step, so that
624 # measurement uses the most accurate background-subtraction.
625 detections = self.psf_detection.run(table=table, exposure=exposure, background=background)
626 self.psf_source_measurement.run(detections.sources, exposure)
627 psf_result = self.psf_measure_psf.run(exposure=exposure, sources=detections.sources)
628 # Replace the initial PSF with something simpler for the second
629 # repair/detect/measure/measure_psf step: this can help it converge.
630 self.install_simple_psf.run(exposure=exposure)
631
632 log_psf("Rerunning with simple PSF:")
633 # TODO investigation: Should we only re-run repair here, to use the
634 # new PSF? Maybe we *do* need to re-run measurement with PsfFlux, to
635 # use the fitted PSF?
636 # TODO investigation: do we need a separate measurement task here
637 # for the post-psf_measure_psf step, since we only want to do PsfFlux
638 # and GaussianFlux *after* we have a PSF? Maybe that's not relevant
639 # once DM-39203 is merged?
640 self.psf_repair.run(exposure=exposure, keepCRs=True)
641 # Re-estimate the background during this detection step, so that
642 # measurement uses the most accurate background-subtraction.
643 detections = self.psf_detection.run(table=table, exposure=exposure, background=background)
644 self.psf_source_measurement.run(detections.sources, exposure)
645 psf_result = self.psf_measure_psf.run(exposure=exposure, sources=detections.sources)
646
647 log_psf("Final PSF:")
648
649 # Final repair with final PSF, removing cosmic rays this time.
650 self.psf_repair.run(exposure=exposure)
651 # Final measurement with the CRs removed.
652 self.psf_source_measurement.run(detections.sources, exposure)
653
654 # PSF is set on exposure; only return candidates for optional saving.
655 return detections.sources, background, psf_result.cellSet
656

◆ _find_stars()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._find_stars ( self,
exposure,
background,
id_generator )
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 set the ApCorrMap 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.

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

Definition at line 673 of file calibrateImage.py.

673 def _find_stars(self, exposure, background, id_generator):
674 """Detect stars on an exposure that has a PSF model, and measure their
675 PSF, circular aperture, compensated gaussian fluxes.
676
677 Parameters
678 ----------
679 exposure : `lsst.afw.image.Exposure`
680 Exposure to set the ApCorrMap on.
681 background : `lsst.afw.math.BackgroundList`
682 Background that was fit to the exposure during detection;
683 modified in-place during subsequent detection.
684 id_generator : `lsst.meas.base.IdGenerator`
685 Object that generates source IDs and provides random seeds.
686
687 Returns
688 -------
689 stars : `SourceCatalog`
690 Sources that are very likely to be stars, with a limited set of
691 measurements performed on them.
692 """
693 table = afwTable.SourceTable.make(self.initial_stars_schema.schema,
694 id_generator.make_table_id_factory())
695 # Re-estimate the background during this detection step, so that
696 # measurement uses the most accurate background-subtraction.
697 detections = self.star_detection.run(table=table, exposure=exposure, background=background)
698 sources = detections.sources
699 self.star_sky_sources.run(exposure.mask, id_generator.catalog_id, sources)
700
701 # TODO investigation: Could this deblender throw away blends of non-PSF sources?
702 self.star_deblend.run(exposure=exposure, sources=sources)
703 # The deblender may not produce a contiguous catalog; ensure
704 # contiguity for subsequent tasks.
705 if not sources.isContiguous():
706 sources = sources.copy(deep=True)
707
708 # Measure everything, and use those results to select only stars.
709 self.star_measurement.run(sources, exposure)
710 self.star_apply_aperture_correction.run(sources, exposure.info.getApCorrMap())
711 self.star_catalog_calculation.run(sources)
712 self.star_set_primary_flags.run(sources)
713
714 result = self.star_selector.run(sources)
715 # The star selector may not produce a contiguous catalog.
716 if not result.sourceCat.isContiguous():
717 return result.sourceCat.copy(deep=True)
718 else:
719 return result.sourceCat
720

◆ _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 781 of file calibrateImage.py.

781 def _fit_astrometry(self, exposure, stars):
782 """Fit an astrometric model to the data and return the reference
783 matches used in the fit, and the fitted WCS.
784
785 Parameters
786 ----------
787 exposure : `lsst.afw.image.Exposure`
788 Exposure that is being fit, to get PSF and other metadata from.
789 Modified to add the fitted skyWcs.
790 stars : `SourceCatalog`
791 Good stars selected for use in calibration, with RA/Dec coordinates
792 computed from the pixel positions and fitted WCS.
793
794 Returns
795 -------
796 matches : `list` [`lsst.afw.table.ReferenceMatch`]
797 Reference/stars matches used in the fit.
798 """
799 result = self.astrometry.run(stars, exposure)
800 return result.matches, result.matchMeta
801

◆ _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.
    Modified to be in nanojanksy units, with an assigned photoCalib
    identically 1.
stars : `lsst.afw.table.SourceCatalog`
    Good stars selected for use in calibration.

Returns
-------
calibrated_stars : `lsst.afw.table.SourceCatalog`
    Star catalog with flux/magnitude columns computed from the fitted
    photoCalib.
matches : `list` [`lsst.afw.table.ReferenceMatch`]
    Reference/stars matches used in the fit.
photoCalib : `lsst.afw.image.PhotoCalib`
    Photometric calibration that was fit to the star catalog.

Definition at line 802 of file calibrateImage.py.

802 def _fit_photometry(self, exposure, stars):
803 """Fit a photometric model to the data and return the reference
804 matches used in the fit, and the fitted PhotoCalib.
805
806 Parameters
807 ----------
808 exposure : `lsst.afw.image.Exposure`
809 Exposure that is being fit, to get PSF and other metadata from.
810 Modified to be in nanojanksy units, with an assigned photoCalib
811 identically 1.
812 stars : `lsst.afw.table.SourceCatalog`
813 Good stars selected for use in calibration.
814
815 Returns
816 -------
817 calibrated_stars : `lsst.afw.table.SourceCatalog`
818 Star catalog with flux/magnitude columns computed from the fitted
819 photoCalib.
820 matches : `list` [`lsst.afw.table.ReferenceMatch`]
821 Reference/stars matches used in the fit.
822 photoCalib : `lsst.afw.image.PhotoCalib`
823 Photometric calibration that was fit to the star catalog.
824 """
825 result = self.photometry.run(exposure, stars)
826 calibrated_stars = result.photoCalib.calibrateCatalog(stars)
827 exposure.maskedImage = result.photoCalib.calibrateImage(exposure.maskedImage)
828 identity = afwImage.PhotoCalib(1.0,
829 result.photoCalib.getCalibrationErr(),
830 bbox=exposure.getBBox())
831 exposure.setPhotoCalib(identity)
832
833 return calibrated_stars, result.matches, result.matchMeta, result.photoCalib
834
The photometric calibration of an exposure.
Definition PhotoCalib.h:114

◆ _handle_snaps()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask._handle_snaps ( self,
exposure )
protected
Combine two snaps into one exposure, or return a single exposure.

Parameters
----------
exposure : `lsst.afw.image.Exposure` or `list` [`lsst.afw.image.Exposure]`
    One or two exposures to combine as snaps.

Returns
-------
exposure : `lsst.afw.image.Exposure`
    A single exposure to continue processing.

Raises
------
RuntimeError
    Raised if input does not contain either 1 or 2 exposures.

Definition at line 550 of file calibrateImage.py.

550 def _handle_snaps(self, exposure):
551 """Combine two snaps into one exposure, or return a single exposure.
552
553 Parameters
554 ----------
555 exposure : `lsst.afw.image.Exposure` or `list` [`lsst.afw.image.Exposure]`
556 One or two exposures to combine as snaps.
557
558 Returns
559 -------
560 exposure : `lsst.afw.image.Exposure`
561 A single exposure to continue processing.
562
563 Raises
564 ------
565 RuntimeError
566 Raised if input does not contain either 1 or 2 exposures.
567 """
568 if isinstance(exposure, lsst.afw.image.Exposure):
569 return exposure
570
571 if isinstance(exposure, collections.abc.Sequence):
572 match len(exposure):
573 case 1:
574 return exposure[0]
575 case 2:
576 return self.snap_combine.run(exposure[0], exposure[1]).exposure
577 case n:
578 raise RuntimeError(f"Can only process 1 or 2 snaps, not {n}.")
579
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition Exposure.h:72

◆ _match_psf_stars()

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

Parameters
----------
psf_stars : `lsst.afw.table.SourceCatalog`
    PSF candidate stars that were sent to the psf determiner. Used to
    populate psf-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 721 of file calibrateImage.py.

721 def _match_psf_stars(self, psf_stars, stars):
722 """Match calibration stars to psf stars, to identify which were psf
723 candidates, and which were used or reserved during psf measurement.
724
725 Parameters
726 ----------
727 psf_stars : `lsst.afw.table.SourceCatalog`
728 PSF candidate stars that were sent to the psf determiner. Used to
729 populate psf-related flag fields.
730 stars : `lsst.afw.table.SourceCatalog`
731 Stars that will be used for calibration; psf-related fields will
732 be updated in-place.
733
734 Notes
735 -----
736 This code was adapted from CalibrateTask.copyIcSourceFields().
737 """
738 control = afwTable.MatchControl()
739 # Return all matched objects, to separate blends.
740 control.findOnlyClosest = False
741 matches = afwTable.matchXy(psf_stars, stars, 3.0, control)
742 deblend_key = stars.schema["deblend_nChild"].asKey()
743 matches = [m for m in matches if m[1].get(deblend_key) == 0]
744
745 # Because we had to allow multiple matches to handle parents, we now
746 # need to prune to the best (closest) matches.
747 # Closest matches is a dict of psf_stars source ID to Match record
748 # (psf_stars source, sourceCat source, distance in pixels).
749 best = {}
750 for match_psf, match_stars, d in matches:
751 match = best.get(match_psf.getId())
752 if match is None or d <= match[2]:
753 best[match_psf.getId()] = (match_psf, match_stars, d)
754 matches = list(best.values())
755 # We'll use this to construct index arrays into each catalog.
756 ids = np.array([(match_psf.getId(), match_stars.getId()) for match_psf, match_stars, d in matches]).T
757
758 # Check that no stars sources are listed twice; we already know
759 # that each match has a unique psf_stars id, due to using as the key
760 # in best above.
761 n_matches = len(matches)
762 n_unique = len(set(m[1].getId() for m in matches))
763 if n_unique != n_matches:
764 self.log.warning("%d psf_stars matched only %d stars; ",
765 n_matches, n_unique)
766 if n_matches == 0:
767 msg = (f"0 psf_stars out of {len(psf_stars)} matched {len(stars)} calib stars."
768 " Downstream processes probably won't have useful stars in this case."
769 " Is `star_source_selector` too strict?")
770 # TODO DM-39842: Turn this into an AlgorithmicError.
771 raise RuntimeError(msg)
772
773 # The indices of the IDs, so we can update the flag fields as arrays.
774 idx_psf_stars = np.searchsorted(psf_stars["id"], ids[0])
775 idx_stars = np.searchsorted(stars["id"], ids[1])
776 for field in self.psf_fields:
777 result = np.zeros(len(stars), dtype=bool)
778 result[idx_stars] = psf_stars[field][idx_psf_stars]
779 stars[field] = result
780
Pass parameters to algorithms that match list of sources.
Definition Match.h:45
daf::base::PropertySet * set
Definition fits.cc:931
SourceMatchVector matchXy(SourceCatalog const &cat1, SourceCatalog const &cat2, double radius, MatchControl const &mc=MatchControl())
Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between...
Definition Match.cc:305

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

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 657 of file calibrateImage.py.

657 def _measure_aperture_correction(self, exposure, bright_sources):
658 """Measure and set the ApCorrMap on the Exposure, using
659 previously-measured bright sources.
660
661 Parameters
662 ----------
663 exposure : `lsst.afw.image.Exposure`
664 Exposure to set the ApCorrMap on.
665 bright_sources : `lsst.afw.table.SourceCatalog`
666 Catalog of detected bright sources; modified to include columns
667 necessary for point source determination for the aperture correction
668 calculation.
669 """
670 result = self.measure_aperture_correction.run(exposure, bright_sources)
671 exposure.setApCorrMap(result.apCorrMap)
672

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

Definition at line 835 of file calibrateImage.py.

835 def _summarize(self, exposure, stars, background):
836 """Compute summary statistics on the exposure and update in-place the
837 calibrations attached to it.
838
839 Parameters
840 ----------
841 exposure : `lsst.afw.image.Exposure`
842 Exposure that was calibrated, to get PSF and other metadata from.
843 Modified to contain the computed summary statistics.
844 stars : `SourceCatalog`
845 Good stars selected used in calibration.
846 background : `lsst.afw.math.BackgroundList`
847 Background that was fit to the exposure during detection of the
848 above stars.
849 """
850 # TODO investigation: because this takes the photoCalib from the
851 # exposure, photometric summary values may be "incorrect" (i.e. they
852 # will reflect the ==1 nJy calibration on the exposure, not the
853 # applied calibration). This needs to be checked.
854 summary = self.compute_summary_stats.run(exposure, stars, background)
855 exposure.info.setSummaryStats(summary)

◆ run()

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.run ( self,
* exposures,
id_generator = None,
result = 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.

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

Definition at line 459 of file calibrateImage.py.

459 def run(self, *, exposures, id_generator=None, result=None):
460 """Find stars and perform psf measurement, then do a deeper detection
461 and measurement and calibrate astrometry and photometry from that.
462
463 Parameters
464 ----------
465 exposures : `lsst.afw.image.Exposure` or `list` [`lsst.afw.image.Exposure`]
466 Post-ISR exposure(s), with an initial WCS, VisitInfo, and Filter.
467 Modified in-place during processing if only one is passed.
468 If two exposures are passed, treat them as snaps and combine
469 before doing further processing.
470 id_generator : `lsst.meas.base.IdGenerator`, optional
471 Object that generates source IDs and provides random seeds.
472 result : `lsst.pipe.base.Struct`, optional
473 Result struct that is modified to allow saving of partial outputs
474 for some failure conditions. If the task completes successfully,
475 this is also returned.
476
477 Returns
478 -------
479 result : `lsst.pipe.base.Struct`
480 Results as a struct with attributes:
481
482 ``exposure``
483 Calibrated exposure, with pixels in nJy units.
484 (`lsst.afw.image.Exposure`)
485 ``stars``
486 Stars that were used to calibrate the exposure, with
487 calibrated fluxes and magnitudes.
488 (`astropy.table.Table`)
489 ``stars_footprints``
490 Footprints of stars that were used to calibrate the exposure.
491 (`lsst.afw.table.SourceCatalog`)
492 ``psf_stars``
493 Stars that were used to determine the image PSF.
494 (`astropy.table.Table`)
495 ``psf_stars_footprints``
496 Footprints of stars that were used to determine the image PSF.
497 (`lsst.afw.table.SourceCatalog`)
498 ``background``
499 Background that was fit to the exposure when detecting
500 ``stars``. (`lsst.afw.math.BackgroundList`)
501 ``applied_photo_calib``
502 Photometric calibration that was fit to the star catalog and
503 applied to the exposure. (`lsst.afw.image.PhotoCalib`)
504 ``astrometry_matches``
505 Reference catalog stars matches used in the astrometric fit.
506 (`list` [`lsst.afw.table.ReferenceMatch`] or `lsst.afw.table.BaseCatalog`)
507 ``photometry_matches``
508 Reference catalog stars matches used in the photometric fit.
509 (`list` [`lsst.afw.table.ReferenceMatch`] or `lsst.afw.table.BaseCatalog`)
510 """
511 if result is None:
512 result = pipeBase.Struct()
513 if id_generator is None:
514 id_generator = lsst.meas.base.IdGenerator()
515
516 result.exposure = self._handle_snaps(exposures)
517
518 # TODO remove on DM-43083: work around the fact that we don't want
519 # to run streak detection in this task in production.
520 result.exposure.mask.addMaskPlane("STREAK")
521
522 result.psf_stars_footprints, result.background, candidates = self._compute_psf(result.exposure,
523 id_generator)
524 result.psf_stars = result.psf_stars_footprints.asAstropy()
525
526 self._measure_aperture_correction(result.exposure, result.psf_stars)
527
528 result.stars_footprints = self._find_stars(result.exposure, result.background, id_generator)
529 self._match_psf_stars(result.psf_stars_footprints, result.stars_footprints)
530 result.stars = result.stars_footprints.asAstropy()
531
532 astrometry_matches, astrometry_meta = self._fit_astrometry(result.exposure, result.stars_footprints)
533 if self.config.optional_outputs:
534 result.astrometry_matches = lsst.meas.astrom.denormalizeMatches(astrometry_matches,
535 astrometry_meta)
536
537 result.stars_footprints, photometry_matches, \
538 photometry_meta, result.applied_photo_calib = self._fit_photometry(result.exposure,
539 result.stars_footprints)
540 # fit_photometry returns a new catalog, so we need a new astropy table view.
541 result.stars = result.stars_footprints.asAstropy()
542 if self.config.optional_outputs:
543 result.photometry_matches = lsst.meas.astrom.denormalizeMatches(photometry_matches,
544 photometry_meta)
545
546 self._summarize(result.exposure, result.stars_footprints, result.background)
547
548 return result
549

◆ runQuantum()

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

Definition at line 413 of file calibrateImage.py.

413 def runQuantum(self, butlerQC, inputRefs, outputRefs):
414 inputs = butlerQC.get(inputRefs)
415 exposures = inputs.pop("exposures")
416
417 id_generator = self.config.id_generator.apply(butlerQC.quantum.dataId)
418
420 dataIds=[ref.datasetRef.dataId for ref in inputRefs.astrometry_ref_cat],
421 refCats=inputs.pop("astrometry_ref_cat"),
422 name=self.config.connections.astrometry_ref_cat,
423 config=self.config.astrometry_ref_loader, log=self.log)
424 self.astrometry.setRefObjLoader(astrometry_loader)
425
427 dataIds=[ref.datasetRef.dataId for ref in inputRefs.photometry_ref_cat],
428 refCats=inputs.pop("photometry_ref_cat"),
429 name=self.config.connections.photometry_ref_cat,
430 config=self.config.photometry_ref_loader, log=self.log)
431 self.photometry.match.setRefObjLoader(photometry_loader)
432
433 # This should not happen with a properly configured execution context.
434 assert not inputs, "runQuantum got more inputs than expected"
435
436 # Specify the fields that `annotate` needs below, to ensure they
437 # exist, even as None.
438 result = pipeBase.Struct(exposure=None,
439 stars_footprints=None,
440 psf_stars_footprints=None,
441 )
442 try:
443 self.run(exposures=exposures, result=result, id_generator=id_generator)
444 except pipeBase.AlgorithmError as e:
445 error = pipeBase.AnnotatedPartialOutputsError.annotate(
446 e,
447 self,
448 result.exposure,
449 result.psf_stars_footprints,
450 result.stars_footprints,
451 log=self.log
452 )
453 butlerQC.put(result, outputRefs)
454 raise error from e
455
456 butlerQC.put(result, outputRefs)
457

Member Data Documentation

◆ _DefaultName

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

Definition at line 362 of file calibrateImage.py.

◆ ConfigClass

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

Definition at line 363 of file calibrateImage.py.

◆ initial_stars_schema

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.initial_stars_schema

Definition at line 411 of file calibrateImage.py.

◆ psf_fields

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.psf_fields

Definition at line 387 of file calibrateImage.py.

◆ psf_schema

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.psf_schema

Definition at line 374 of file calibrateImage.py.


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