Skip to content

Commit

Permalink
Merge pull request #77 from lsst-sitcom/tickets/DM-40517
Browse files Browse the repository at this point in the history
DM-40517: add unit test for quickLook
  • Loading branch information
isullivan authored Jan 27, 2024
2 parents 49e103b + 0a50ce5 commit 2fd5394
Show file tree
Hide file tree
Showing 2 changed files with 363 additions and 14 deletions.
66 changes: 52 additions & 14 deletions python/lsst/summit/utils/quickLook.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,35 @@ class QuickLookIsrTask(pipeBase.PipelineTask):
ConfigClass = QuickLookIsrTaskConfig
_DefaultName = "quickLook"

def __init__(self, **kwargs):
def __init__(self, isrTask=IsrTask, **kwargs):
super().__init__(**kwargs)
# Pass in IsrTask so that we can modify it slightly for unit tests.
# Note that this is not an instance of the IsrTask class, but the class
# itself, which is then instantiated later on, in the run() method,
# with the dynamically generated config.
self.isrTask = IsrTask

def run(self, ccdExposure, *,
camera=None,
bias=None,
dark=None,
flat=None,
fringes=None,
defects=None,
linearizer=None,
crosstalk=None,
bfKernel=None,
bfGains=None,
newBFKernel=None,
ptc=None,
crosstalkSources=None,
isrBaseConfig=None
isrBaseConfig=None,
filterTransmission=None,
opticsTransmission=None,
strayLightData=None,
sensorTransmission=None,
atmosphereTransmission=None,
deferredChargeCalib=None,
illumMaskedImage=None,
):
"""Run isr and cosmic ray repair using, doing as much isr as possible.
Expand Down Expand Up @@ -144,12 +157,11 @@ def run(self, ccdExposure, *,
the detector in question.
defects : `lsst.ip.isr.Defects`, optional
List of defects.
fringes : `lsst.pipe.base.Struct`, optional
Struct containing the fringe correction data, with
elements:
- ``fringes``: fringe calibration frame (`afw.image.Exposure`)
- ``seed``: random seed derived from the ccdExposureId for random
number generator (`uint32`)
fringes : `afw.image.Exposure`, optional
The fringe correction data.
This input is slightly different than the `fringes` keyword to
`lsst.ip.isr.IsrTask`, since the processing done in that task's
`runQuantum` method is instead done here.
opticsTransmission: `lsst.afw.image.TransmissionCurve`, optional
A ``TransmissionCurve`` that represents the throughput of the,
optics, to be evaluated in focal-plane coordinates.
Expand Down Expand Up @@ -211,7 +223,10 @@ def run(self, ccdExposure, *,
isrConfig.doFlat = True
self.log.info("Running with flat correction")

# TODO: deal with fringes here
if fringes:
isrConfig.doFringe = True
self.log.info("Running with fringe correction")

if defects:
isrConfig.doDefect = True
self.log.info("Running with defect correction")
Expand All @@ -224,7 +239,14 @@ def run(self, ccdExposure, *,
isrConfig.doCrosstalk = True
self.log.info("Running with crosstalk correction")

if bfKernel:
if newBFKernel is not None:
bfGains = newBFKernel.gain
isrConfig.doBrighterFatter = True
self.log.info("Running with new brighter-fatter correction")
else:
bfGains = None

if bfKernel is not None and bfGains is None:
isrConfig.doBrighterFatter = True
self.log.info("Running with brighter-fatter correction")

Expand All @@ -233,20 +255,36 @@ def run(self, ccdExposure, *,
self.log.info("Running with ptc correction")

isrConfig.doWrite = False
isrTask = IsrTask(config=isrConfig)
isrTask = self.isrTask(config=isrConfig)

if fringes:
# Must be run after isrTask is instantiated.
isrTask.fringe.loadFringes(fringes,
expId=ccdExposure.info.id,
assembler=isrTask.assembleCcd
if isrConfig.doAssembleIsrExposures else None)

result = isrTask.run(ccdExposure,
camera=camera,
bias=bias,
dark=dark,
flat=flat,
# fringes=pipeBase.Struct(fringes=None),
fringes=fringes,
defects=defects,
linearizer=linearizer,
crosstalk=crosstalk,
bfKernel=bfKernel,
bfGains=bfGains,
ptc=ptc,
crosstalkSources=crosstalkSources,)
crosstalkSources=crosstalkSources,
filterTransmission=filterTransmission,
opticsTransmission=opticsTransmission,
sensorTransmission=sensorTransmission,
atmosphereTransmission=atmosphereTransmission,
strayLightData=strayLightData,
deferredChargeCalib=deferredChargeCalib,
illumMaskedImage=illumMaskedImage,
)

postIsr = result.exposure

Expand Down
Loading

0 comments on commit 2fd5394

Please sign in to comment.