LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
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 348 of file calibrateImage.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 361 of file calibrateImage.py.

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

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

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

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

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

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

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

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

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

546 def _handle_snaps(self, exposure):
547 """Combine two snaps into one exposure, or return a single exposure.
548
549 Parameters
550 ----------
551 exposure : `lsst.afw.image.Exposure` or `list` [`lsst.afw.image.Exposure]`
552 One or two exposures to combine as snaps.
553
554 Returns
555 -------
556 exposure : `lsst.afw.image.Exposure`
557 A single exposure to continue processing.
558
559 Raises
560 ------
561 RuntimeError
562 Raised if input does not contain either 1 or 2 exposures.
563 """
564 if isinstance(exposure, lsst.afw.image.Exposure):
565 return exposure
566
567 if isinstance(exposure, collections.abc.Sequence):
568 match len(exposure):
569 case 1:
570 return exposure[0]
571 case 2:
572 return self.snap_combine.run(exposure[0], exposure[1]).exposure
573 case n:
574 raise RuntimeError(f"Can only process 1 or 2 snaps, not {n}.")
575
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 717 of file calibrateImage.py.

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

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

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

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

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

◆ runQuantum()

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

Definition at line 409 of file calibrateImage.py.

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

Member Data Documentation

◆ _DefaultName

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

Definition at line 358 of file calibrateImage.py.

◆ ConfigClass

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

Definition at line 359 of file calibrateImage.py.

◆ initial_stars_schema

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.initial_stars_schema

Definition at line 407 of file calibrateImage.py.

◆ psf_fields

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.psf_fields

Definition at line 383 of file calibrateImage.py.

◆ psf_schema

lsst.pipe.tasks.calibrateImage.CalibrateImageTask.psf_schema

Definition at line 370 of file calibrateImage.py.


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