19
19
# You should have received a copy of the GNU General Public License
20
20
# along with this program. If not, see <https://www.gnu.org/licenses/>.
21
21
22
- __all__ = ["DetectCoaddSourcesConfig" , "DetectCoaddSourcesTask" ]
22
+ __all__ = ["DetectCoaddSourcesConfig" , "DetectCoaddSourcesTask" ,
23
+ "MeasureMergedCoaddSourcesConfig" , "MeasureMergedCoaddSourcesTask" ,
24
+ ]
23
25
24
26
from lsst .pipe .base import (Struct , PipelineTask , PipelineTaskConfig , PipelineTaskConnections )
25
27
import lsst .pipe .base .connectionTypes as cT
@@ -176,9 +178,13 @@ def __init__(self, schema=None, **kwargs):
176
178
def runQuantum (self , butlerQC , inputRefs , outputRefs ):
177
179
inputs = butlerQC .get (inputRefs )
178
180
idGenerator = self .config .idGenerator .apply (butlerQC .quantum .dataId )
179
- inputs ["idFactory" ] = idGenerator .make_table_id_factory ()
180
- inputs ["expId" ] = idGenerator .catalog_id
181
- outputs = self .run (** inputs )
181
+ exposure = inputs .pop ("exposure" )
182
+ assert not inputs , "runQuantum got more inputs than expected."
183
+ outputs = self .run (
184
+ exposure = exposure ,
185
+ idFactory = idGenerator .make_table_id_factory (),
186
+ expId = idGenerator .catalog_id ,
187
+ )
182
188
butlerQC .put (outputs , outputRefs )
183
189
184
190
def run (self , exposure , idFactory , expId ):
@@ -191,7 +197,7 @@ def run(self, exposure, idFactory, expId):
191
197
Parameters
192
198
----------
193
199
exposure : `lsst.afw.image.Exposure`
194
- Exposure on which to detect (may be backround -subtracted and scaled,
200
+ Exposure on which to detect (may be background -subtracted and scaled,
195
201
depending on configuration).
196
202
idFactory : `lsst.afw.table.IdFactory`
197
203
IdFactory to set source identifiers.
@@ -294,6 +300,14 @@ class MeasureMergedCoaddSourcesConnections(
294
300
multiple = True ,
295
301
deferLoad = True ,
296
302
)
303
+ finalVisitSummaryHandles = cT .Input (
304
+ doc = "Final visit summary table" ,
305
+ name = "finalVisitSummary" ,
306
+ storageClass = "ExposureCatalog" ,
307
+ dimensions = ("instrument" , "visit" ),
308
+ multiple = True ,
309
+ deferLoad = True ,
310
+ )
297
311
# TODO[DM-47797]: remove this deprecated connection.
298
312
inputCatalog = cT .Input (
299
313
doc = ("Name of the input catalog to use."
@@ -573,12 +587,15 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
573
587
574
588
# Set psfcache
575
589
# move this to run after gen2 deprecation
576
- inputs ['exposure' ].getPsf ().setCacheCapacity (self .config .psfCache )
590
+ exposure = inputs .pop ("exposure" )
591
+ exposure .getPsf ().setCacheCapacity (self .config .psfCache )
592
+
593
+ ccdInputs = exposure .getInfo ().getCoaddInputs ().ccds
594
+ apCorrMap = exposure .getInfo ().getApCorrMap ()
577
595
578
596
# Get unique integer ID for IdFactory and RNG seeds; only the latter
579
597
# should really be used as the IDs all come from the input catalog.
580
598
idGenerator = self .config .idGenerator .apply (butlerQC .quantum .dataId )
581
- inputs ['exposureId' ] = idGenerator .catalog_id
582
599
583
600
# Transform inputCatalog
584
601
table = afwTable .SourceTable .make (self .schema , idGenerator .make_table_id_factory ())
@@ -596,7 +613,7 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
596
613
if self .config .doAddFootprints :
597
614
modelData = inputs .pop ('scarletModels' )
598
615
if self .config .doConserveFlux :
599
- imageForRedistribution = inputs [ ' exposure' ]
616
+ imageForRedistribution = exposure
600
617
else :
601
618
imageForRedistribution = None
602
619
updateCatalogFootprints (
@@ -609,7 +626,6 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
609
626
)
610
627
table = sources .getTable ()
611
628
table .setMetadata (self .algMetadata ) # Capture algorithm metadata to write out to the source catalog.
612
- inputs ['sources' ] = sources
613
629
614
630
skyMap = inputs .pop ('skyMap' )
615
631
tractNumber = catalogRef .dataId ['tract' ]
@@ -622,29 +638,45 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
622
638
wcs = tractInfo .getWcs (),
623
639
bbox = patchInfo .getOuterBBox ()
624
640
)
625
- inputs ['skyInfo' ] = skyInfo
626
641
627
642
if self .config .doPropagateFlags :
628
- ccdInputs = inputs ["exposure" ].getInfo ().getCoaddInputs ().ccds
629
- inputs ["ccdInputs" ] = ccdInputs
630
-
631
643
if "sourceTableHandles" in inputs :
632
644
sourceTableHandles = inputs .pop ("sourceTableHandles" )
633
645
sourceTableHandleDict = {handle .dataId ["visit" ]: handle for handle in sourceTableHandles }
634
- inputs ["sourceTableHandleDict" ] = sourceTableHandleDict
646
+ else :
647
+ sourceTableHandleDict = None
635
648
if "finalizedSourceTableHandles" in inputs :
636
649
finalizedSourceTableHandles = inputs .pop ("finalizedSourceTableHandles" )
637
650
finalizedSourceTableHandleDict = {handle .dataId ["visit" ]: handle
638
651
for handle in finalizedSourceTableHandles }
639
- inputs ["finalizedSourceTableHandleDict" ] = finalizedSourceTableHandleDict
640
-
641
- outputs = self .run (** inputs )
652
+ else :
653
+ finalizedSourceTableHandleDict = None
654
+ if "finalVisitSummaryHandles" in inputs :
655
+ finalVisitSummaryHandles = inputs .pop ("finalVisitSummaryHandles" )
656
+ finalVisitSummaryHandleDict = {handle .dataId ["visit" ]: handle
657
+ for handle in finalVisitSummaryHandles }
658
+ else :
659
+ finalVisitSummaryHandleDict = None
660
+
661
+ assert not inputs , "runQuantum got more inputs than expected."
662
+ outputs = self .run (
663
+ exposure = exposure ,
664
+ sources = sources ,
665
+ skyInfo = skyInfo ,
666
+ exposureId = idGenerator .catalog_id ,
667
+ ccdInputs = ccdInputs ,
668
+ sourceTableHandleDict = sourceTableHandleDict ,
669
+ finalizedSourceTableHandleDict = finalizedSourceTableHandleDict ,
670
+ finalVisitSummaryHandleDict = finalVisitSummaryHandleDict ,
671
+ apCorrMap = apCorrMap ,
672
+ )
642
673
# Strip HeavyFootprints to save space on disk
643
674
sources = outputs .outputSources
644
675
butlerQC .put (outputs , outputRefs )
645
676
646
677
def run (self , exposure , sources , skyInfo , exposureId , ccdInputs = None ,
647
- sourceTableHandleDict = None , finalizedSourceTableHandleDict = None ):
678
+ sourceTableHandleDict = None , finalizedSourceTableHandleDict = None , finalVisitSummaryHandleDict = None ,
679
+ apCorrMap = None ):
648
680
"""Run measurement algorithms on the input exposure, and optionally populate the
649
681
resulting catalog with extra information.
650
682
@@ -665,12 +697,16 @@ def run(self, exposure, sources, skyInfo, exposureId, ccdInputs=None,
665
697
the coadd.
666
698
sourceTableHandleDict : `dict` [`int`, `lsst.daf.butler.DeferredDatasetHandle`], optional
667
699
Dict for sourceTable_visit handles (key is visit) for propagating flags.
668
- These tables are derived from the ``CalibrateTask`` sources, and contain
669
- astrometry and photometry flags, and optionally PSF flags.
700
+ These tables contain astrometry and photometry flags, and optionally PSF flags.
670
701
finalizedSourceTableHandleDict : `dict` [`int`, `lsst.daf.butler.DeferredDatasetHandle`], optional
671
702
Dict for finalized_src_table handles (key is visit) for propagating flags.
672
- These tables are derived from ``FinalizeCalibrationTask`` and contain
673
- PSF flags from the finalized PSF estimation.
703
+ These tables contain PSF flags from the finalized PSF estimation.
704
+ finalVisitSummaryHandleDict : `dict` [`int`, `lsst.daf.butler.DeferredDatasetHandle`], optional
705
+ Dict for visit_summary handles (key is visit) for visit-level information.
706
+ These tables contain the WCS information of the single-visit input images.
707
+ apCorrMap : `lsst.afw.image.ApCorrMap`, optional
708
+ Aperture correction map attached to the ``exposure``. If None, it
709
+ will be read from the ``exposure``.
674
710
675
711
Returns
676
712
-------
@@ -683,9 +719,11 @@ def run(self, exposure, sources, skyInfo, exposureId, ccdInputs=None,
683
719
self .measurement .run (sources , exposure , exposureId = exposureId )
684
720
685
721
if self .config .doApCorr :
722
+ if apCorrMap is None :
723
+ apCorrMap = exposure .getInfo ().getApCorrMap ()
686
724
self .applyApCorr .run (
687
725
catalog = sources ,
688
- apCorrMap = exposure . getInfo (). getApCorrMap ()
726
+ apCorrMap = apCorrMap ,
689
727
)
690
728
691
729
# TODO DM-11568: this contiguous check-and-copy could go away if we
@@ -705,7 +743,8 @@ def run(self, exposure, sources, skyInfo, exposureId, ccdInputs=None,
705
743
sources ,
706
744
ccdInputs ,
707
745
sourceTableHandleDict ,
708
- finalizedSourceTableHandleDict
746
+ finalizedSourceTableHandleDict ,
747
+ finalVisitSummaryHandleDict ,
709
748
)
710
749
711
750
results = Struct ()
0 commit comments