@@ -220,8 +220,9 @@ class CharacterizeImageConfig(pipeBase.PipelineTaskConfig,
220
220
target = ApplyApCorrTask ,
221
221
doc = "Subtask to apply aperture corrections"
222
222
)
223
- # If doApCorr is False, and the exposure does not have apcorrections already applied, the
224
- # active plugins in catalogCalculation almost certainly should not contain the characterization plugin
223
+ # If doApCorr is False, and the exposure does not have apcorrections
224
+ # already applied, the active plugins in catalogCalculation almost
225
+ # certainly should not contain the characterization plugin.
225
226
catalogCalculation = pexConfig .ConfigurableField (
226
227
target = CatalogCalculationTask ,
227
228
doc = "Subtask to run catalogCalculation plugins on catalog"
@@ -287,27 +288,28 @@ class CharacterizeImageConfig(pipeBase.PipelineTaskConfig,
287
288
def setDefaults (self ):
288
289
super ().setDefaults ()
289
290
# Just detect bright stars.
290
- # The thresholdValue sets the minimum flux in a pixel to be included in the
291
- # footprint, while peaks are only detected when they are above
291
+ # The thresholdValue sets the minimum flux in a pixel to be included
292
+ # in the footprint, while peaks are only detected when they are above
292
293
# thresholdValue * includeThresholdMultiplier. The low thresholdValue
293
294
# ensures that the footprints are large enough for the noise replacer
294
295
# to mask out faint undetected neighbors that are not to be measured.
295
296
self .detection .thresholdValue = 5.0
296
297
self .detection .includeThresholdMultiplier = 10.0
297
298
# do not deblend, as it makes a mess
298
299
self .doDeblend = False
299
- # measure and apply aperture correction; note: measuring and applying aperture
300
- # correction are disabled until the final measurement, after PSF is measured
300
+ # Measure and apply aperture correction; note: measuring and applying
301
+ # aperture correction are disabled until the final measurement, after
302
+ # PSF is measured.
301
303
self .doApCorr = True
302
- # During characterization, we don't have full source measurement information,
303
- # so must do the aperture correction with only psf stars, combined with the
304
- # default signal-to-noise cuts in MeasureApCorrTask.
304
+ # During characterization, we don't have full source measurement
305
+ # information, so must do the aperture correction with only psf stars,
306
+ # combined with the default signal-to-noise cuts in MeasureApCorrTask.
305
307
selector = self .measureApCorr .sourceSelector ["science" ]
306
308
selector .doUnresolved = False
307
309
selector .flags .good = ["calib_psf_used" ]
308
310
selector .flags .bad = []
309
311
310
- # minimal set of measurements needed to determine PSF
312
+ # Minimal set of measurements needed to determine PSF.
311
313
self .measurement .plugins .names = [
312
314
"base_PixelFlags" ,
313
315
"base_SdssCentroid" ,
@@ -324,7 +326,7 @@ def validate(self):
324
326
if self .doApCorr and not self .measurePsf :
325
327
raise RuntimeError ("Must measure PSF to measure aperture correction, "
326
328
"because flags determined by PSF measurement are used to identify "
327
- "sources used to measure aperture correction" )
329
+ "sources used to measure aperture correction. " )
328
330
329
331
330
332
class CharacterizeImageTask (pipeBase .PipelineTask ):
@@ -351,21 +353,25 @@ class CharacterizeImageTask(pipeBase.PipelineTask):
351
353
CharacterizeImageTask has a debug dictionary with the following keys:
352
354
353
355
frame
354
- int: if specified, the frame of first debug image displayed (defaults to 1)
356
+ int: if specified, the frame of first debug image displayed (defaults
357
+ to 1).
355
358
repair_iter
356
- bool; if True display image after each repair in the measure PSF loop
359
+ bool; if True display image after each repair in the measure PSF loop.
357
360
background_iter
358
- bool; if True display image after each background subtraction in the measure PSF loop
361
+ bool; if True display image after each background subtraction in the
362
+ measure PSF loop.
359
363
measure_iter
360
- bool; if True display image and sources at the end of each iteration of the measure PSF loop
361
- See `~lsst.meas.astrom.displayAstrometry` for the meaning of the various symbols.
364
+ bool; if True display image and sources at the end of each iteration
365
+ of the measure PSF loop. See `~lsst.meas.astrom.displayAstrometry` for
366
+ the meaning of the various symbols.
362
367
psf
363
368
bool; if True display image and sources after PSF is measured;
364
- this will be identical to the final image displayed by measure_iter if measure_iter is true
369
+ this will be identical to the final image displayed by measure_iter if
370
+ measure_iter is true.
365
371
repair
366
- bool; if True display image and sources after final repair
372
+ bool; if True display image and sources after final repair.
367
373
measure
368
- bool; if True display image and sources after final measurement
374
+ bool; if True display image and sources after final measurement.
369
375
"""
370
376
371
377
ConfigClass = CharacterizeImageConfig
@@ -413,8 +419,10 @@ def run(self, exposure, background=None, idGenerator=None):
413
419
"""Characterize a science image.
414
420
415
421
Peforms the following operations:
416
- - Iterate the following config.psfIterations times, or once if config.doMeasurePsf false:
417
- - detect and measure sources and estimate PSF (see detectMeasureAndEstimatePsf for details)
422
+ - Iterate the following config.psfIterations times, or once if
423
+ config.doMeasurePsf false:
424
+ - detect and measure sources and estimate PSF (see
425
+ detectMeasureAndEstimatePsf for details)
418
426
- interpolate over cosmic rays
419
427
- perform final measurement
420
428
@@ -439,7 +447,8 @@ def run(self, exposure, background=None, idGenerator=None):
439
447
``background``
440
448
Model of subtracted background (`lsst.afw.math.BackgroundList`).
441
449
``psfCellSet``
442
- Spatial cells of PSF candidates (`lsst.afw.math.SpatialCellSet`).
450
+ Spatial cells of PSF candidates
451
+ (`lsst.afw.math.SpatialCellSet`).
443
452
``characterized``
444
453
Another reference to ``exposure`` for compatibility.
445
454
``backgroundModel``
@@ -519,17 +528,17 @@ def run(self, exposure, background=None, idGenerator=None):
519
528
520
529
self .display ("psf" , exposure = dmeRes .exposure , sourceCat = dmeRes .sourceCat )
521
530
522
- # perform final repair with final PSF
531
+ # Perform final repair with final PSF.
523
532
self .repair .run (exposure = dmeRes .exposure )
524
533
self .display ("repair" , exposure = dmeRes .exposure , sourceCat = dmeRes .sourceCat )
525
534
526
- # mask streaks
535
+ # Mask streaks.
527
536
# TODO: Remove in DM-44658, streak masking to happen only in ip_diffim
528
537
if self .config .doMaskStreaks :
529
538
_ = self .maskStreaks .run (dmeRes .exposure )
530
539
531
- # perform final measurement with final PSF, including measuring and applying aperture correction,
532
- # if wanted
540
+ # Perform final measurement with final PSF, including measuring and
541
+ # applying aperture correction, if wanted.
533
542
self .measurement .run (measCat = dmeRes .sourceCat , exposure = dmeRes .exposure ,
534
543
exposureId = idGenerator .catalog_id )
535
544
@@ -557,7 +566,8 @@ def run(self, exposure, background=None, idGenerator=None):
557
566
# downstream.
558
567
dmeRes .exposure .info .setApCorrMap (None )
559
568
else :
560
- # Need to merge the aperture correction map from the normalization.
569
+ # Need to merge the aperture correction map from the
570
+ # normalization.
561
571
if normApCorrMap :
562
572
for key in normApCorrMap :
563
573
apCorrMap [key ] = normApCorrMap [key ]
@@ -585,12 +595,13 @@ def detectMeasureAndEstimatePsf(self, exposure, idGenerator, background):
585
595
Performs the following operations:
586
596
587
597
- if config.doMeasurePsf or not exposure.hasPsf():
588
-
589
- - install a simple PSF model (replacing the existing one, if need be)
598
+ - install a simple PSF model (replacing the existing one, if
599
+ need be)
590
600
591
601
- interpolate over cosmic rays with keepCRs=True
592
602
- estimate background and subtract it from the exposure
593
- - detect, deblend and measure sources, and subtract a refined background model;
603
+ - detect, deblend and measure sources, and subtract a refined
604
+ background model;
594
605
- if config.doMeasurePsf:
595
606
- measure PSF
596
607
@@ -615,19 +626,21 @@ def detectMeasureAndEstimatePsf(self, exposure, idGenerator, background):
615
626
``background``
616
627
Model of subtracted background (`lsst.afw.math.BackgroundList`).
617
628
``psfCellSet``
618
- Spatial cells of PSF candidates (`lsst.afw.math.SpatialCellSet`).
629
+ Spatial cells of PSF candidates
630
+ (`lsst.afw.math.SpatialCellSet`).
619
631
620
632
Raises
621
633
------
622
634
LengthError
623
635
Raised if there are too many CR pixels.
624
636
"""
625
- # install a simple PSF model, if needed or wanted
637
+ # Install a simple PSF model, if needed or wanted.
626
638
if not exposure .hasPsf () or (self .config .doMeasurePsf and self .config .useSimplePsf ):
627
639
self .log .info ("PSF estimation initialized with 'simple' PSF" )
628
640
self .installSimplePsf .run (exposure = exposure )
629
641
630
- # run repair, but do not interpolate over cosmic rays (do that elsewhere, with the final PSF model)
642
+ # Run repair, but do not interpolate over cosmic rays (do that
643
+ # elsewhere, with the final PSF model).
631
644
if self .config .requireCrForPsf :
632
645
self .repair .run (exposure = exposure , keepCRs = True )
633
646
else :
@@ -654,7 +667,7 @@ def detectMeasureAndEstimatePsf(self, exposure, idGenerator, background):
654
667
655
668
if self .config .doDeblend :
656
669
self .deblend .run (exposure = exposure , sources = sourceCat )
657
- # We need the output catalog to be contiguous for further processing.
670
+ # The output catalog needs to be contiguous for further processing.
658
671
if not sourceCat .isContiguous ():
659
672
sourceCat = sourceCat .copy (deep = True )
660
673
0 commit comments