25 import lsst.pipe.base
as pipeBase
26 import lsst.pipe.base.connectionTypes
as cT
27 from lsst.pipe.tasks.repair
import RepairTask
32 __all__ = [
"CpDarkTask",
"CpDarkTaskConfig"]
36 dimensions=(
"instrument",
"exposure",
"detector")):
39 doc=
"Input pre-processed exposures to combine.",
40 storageClass=
"Exposure",
41 dimensions=(
"instrument",
"exposure",
"detector"),
44 outputExp = cT.Output(
46 doc=
"Output combined proposed calibration.",
47 storageClass=
"Exposure",
48 dimensions=(
"instrument",
"exposure",
"detector"),
53 pipelineConnections=CpDarkConnections):
54 psfFwhm = pexConfig.Field(
57 doc=
"Repair PSF FWHM (pixels).",
59 psfSize = pexConfig.Field(
62 doc=
"Repair PSF size (pixels).",
64 crGrow = pexConfig.Field(
67 doc=
"Grow radius for CR (pixels).",
69 repair = pexConfig.ConfigurableField(
71 doc=
"Repair task to use.",
76 pipeBase.CmdLineTask):
77 """Combine pre-processed dark frames into a proposed master calibration.
80 ConfigClass = CpDarkTaskConfig
81 _DefaultName =
"cpDark"
85 self.makeSubtask(
"repair")
87 def run(self, inputExp):
88 """Preprocess input exposures prior to DARK combination.
90 This task detects and repairs cosmic rays strikes.
94 inputExp : `lsst.afw.image.Exposure`
95 Pre-processed dark frame data to combine.
99 outputExp : `lsst.afw.image.Exposure`
100 CR rejected, ISR processed Dark Frame."
102 psf = measAlg.SingleGaussianPsf(self.config.psfSize,
104 self.config.psfFwhm/(2*math.sqrt(2*math.log(2))))
106 scaleExp = inputExp.clone()
107 mi = scaleExp.getMaskedImage()
111 scale = inputExp.getInfo().getVisitInfo().getDarkTime()
112 if np.isfinite(scale)
and scale != 0.0:
115 self.repair.
run(scaleExp, keepCRs=
False)
116 if self.config.crGrow > 0:
117 crMask = inputExp.getMaskedImage().getMask().getPlaneBitMask(
"CR")
118 spans = afwGeom.SpanSet.fromMask(inputExp.mask, crMask)
119 spans = spans.dilated(self.config.crGrow)
120 spans.setMask(inputExp.mask, crMask)
123 if np.isfinite(scale)
and scale != 0.0:
126 return pipeBase.Struct(
def __init__(self, **kwargs)