Skip to content

Commit 6f3262f

Browse files
committed
Flake8 and comment consistency fixes
1 parent 8449ab8 commit 6f3262f

File tree

1 file changed

+47
-34
lines changed

1 file changed

+47
-34
lines changed

python/lsst/pipe/tasks/characterizeImage.py

+47-34
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ class CharacterizeImageConfig(pipeBase.PipelineTaskConfig,
220220
target=ApplyApCorrTask,
221221
doc="Subtask to apply aperture corrections"
222222
)
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.
225226
catalogCalculation = pexConfig.ConfigurableField(
226227
target=CatalogCalculationTask,
227228
doc="Subtask to run catalogCalculation plugins on catalog"
@@ -287,27 +288,28 @@ class CharacterizeImageConfig(pipeBase.PipelineTaskConfig,
287288
def setDefaults(self):
288289
super().setDefaults()
289290
# 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
292293
# thresholdValue * includeThresholdMultiplier. The low thresholdValue
293294
# ensures that the footprints are large enough for the noise replacer
294295
# to mask out faint undetected neighbors that are not to be measured.
295296
self.detection.thresholdValue = 5.0
296297
self.detection.includeThresholdMultiplier = 10.0
297298
# do not deblend, as it makes a mess
298299
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.
301303
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.
305307
selector = self.measureApCorr.sourceSelector["science"]
306308
selector.doUnresolved = False
307309
selector.flags.good = ["calib_psf_used"]
308310
selector.flags.bad = []
309311

310-
# minimal set of measurements needed to determine PSF
312+
# Minimal set of measurements needed to determine PSF.
311313
self.measurement.plugins.names = [
312314
"base_PixelFlags",
313315
"base_SdssCentroid",
@@ -324,7 +326,7 @@ def validate(self):
324326
if self.doApCorr and not self.measurePsf:
325327
raise RuntimeError("Must measure PSF to measure aperture correction, "
326328
"because flags determined by PSF measurement are used to identify "
327-
"sources used to measure aperture correction")
329+
"sources used to measure aperture correction.")
328330

329331

330332
class CharacterizeImageTask(pipeBase.PipelineTask):
@@ -351,21 +353,25 @@ class CharacterizeImageTask(pipeBase.PipelineTask):
351353
CharacterizeImageTask has a debug dictionary with the following keys:
352354
353355
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).
355358
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.
357360
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.
359363
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.
362367
psf
363368
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.
365371
repair
366-
bool; if True display image and sources after final repair
372+
bool; if True display image and sources after final repair.
367373
measure
368-
bool; if True display image and sources after final measurement
374+
bool; if True display image and sources after final measurement.
369375
"""
370376

371377
ConfigClass = CharacterizeImageConfig
@@ -413,8 +419,10 @@ def run(self, exposure, background=None, idGenerator=None):
413419
"""Characterize a science image.
414420
415421
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)
418426
- interpolate over cosmic rays
419427
- perform final measurement
420428
@@ -439,7 +447,8 @@ def run(self, exposure, background=None, idGenerator=None):
439447
``background``
440448
Model of subtracted background (`lsst.afw.math.BackgroundList`).
441449
``psfCellSet``
442-
Spatial cells of PSF candidates (`lsst.afw.math.SpatialCellSet`).
450+
Spatial cells of PSF candidates
451+
(`lsst.afw.math.SpatialCellSet`).
443452
``characterized``
444453
Another reference to ``exposure`` for compatibility.
445454
``backgroundModel``
@@ -519,17 +528,17 @@ def run(self, exposure, background=None, idGenerator=None):
519528

520529
self.display("psf", exposure=dmeRes.exposure, sourceCat=dmeRes.sourceCat)
521530

522-
# perform final repair with final PSF
531+
# Perform final repair with final PSF.
523532
self.repair.run(exposure=dmeRes.exposure)
524533
self.display("repair", exposure=dmeRes.exposure, sourceCat=dmeRes.sourceCat)
525534

526-
# mask streaks
535+
# Mask streaks.
527536
# TODO: Remove in DM-44658, streak masking to happen only in ip_diffim
528537
if self.config.doMaskStreaks:
529538
_ = self.maskStreaks.run(dmeRes.exposure)
530539

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.
533542
self.measurement.run(measCat=dmeRes.sourceCat, exposure=dmeRes.exposure,
534543
exposureId=idGenerator.catalog_id)
535544

@@ -557,7 +566,8 @@ def run(self, exposure, background=None, idGenerator=None):
557566
# downstream.
558567
dmeRes.exposure.info.setApCorrMap(None)
559568
else:
560-
# Need to merge the aperture correction map from the normalization.
569+
# Need to merge the aperture correction map from the
570+
# normalization.
561571
if normApCorrMap:
562572
for key in normApCorrMap:
563573
apCorrMap[key] = normApCorrMap[key]
@@ -585,12 +595,13 @@ def detectMeasureAndEstimatePsf(self, exposure, idGenerator, background):
585595
Performs the following operations:
586596
587597
- 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)
590600
591601
- interpolate over cosmic rays with keepCRs=True
592602
- 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;
594605
- if config.doMeasurePsf:
595606
- measure PSF
596607
@@ -615,19 +626,21 @@ def detectMeasureAndEstimatePsf(self, exposure, idGenerator, background):
615626
``background``
616627
Model of subtracted background (`lsst.afw.math.BackgroundList`).
617628
``psfCellSet``
618-
Spatial cells of PSF candidates (`lsst.afw.math.SpatialCellSet`).
629+
Spatial cells of PSF candidates
630+
(`lsst.afw.math.SpatialCellSet`).
619631
620632
Raises
621633
------
622634
LengthError
623635
Raised if there are too many CR pixels.
624636
"""
625-
# install a simple PSF model, if needed or wanted
637+
# Install a simple PSF model, if needed or wanted.
626638
if not exposure.hasPsf() or (self.config.doMeasurePsf and self.config.useSimplePsf):
627639
self.log.info("PSF estimation initialized with 'simple' PSF")
628640
self.installSimplePsf.run(exposure=exposure)
629641

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).
631644
if self.config.requireCrForPsf:
632645
self.repair.run(exposure=exposure, keepCRs=True)
633646
else:
@@ -654,7 +667,7 @@ def detectMeasureAndEstimatePsf(self, exposure, idGenerator, background):
654667

655668
if self.config.doDeblend:
656669
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.
658671
if not sourceCat.isContiguous():
659672
sourceCat = sourceCat.copy(deep=True)
660673

0 commit comments

Comments
 (0)