Skip to content

Commit

Permalink
Merge pull request #317 from lsst/tickets/DM-43601
Browse files Browse the repository at this point in the history
DM-43601: Add applyGains to new ISR Task
  • Loading branch information
aferte committed Apr 4, 2024
2 parents 521a1de + 2d631bd commit 2ab2c8e
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions python/lsst/ip/isr/isrTaskLSST.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,15 @@ class IsrTaskLSSTConfig(pipeBase.PipelineTaskConfig,
default=True,
)

# Normalize gain.
doGainNormalize = pexConfig.Field(
# Gains.
doGainsCorrection = pexConfig.Field(
dtype=bool,
doc="Normalize by the gain.",
doc="Apply temperature correction to the gains?",
default=False,
)
doApplyGains = pexConfig.Field(
dtype=bool,
doc="Apply gains to the image?",
default=True,
)

Expand Down Expand Up @@ -505,7 +510,7 @@ def validateInput(self, inputs):
'bias': self.config.doBias,
'deferredChargeCalib': self.config.doDeferredCharge,
'linearizer': self.config.doLinearize,
'ptc': self.config.doGainNormalize,
'ptc': self.config.doApplyGains,
'crosstalk': doCrosstalk,
'defects': self.config.doDefect,
'bfKernel': self.config.doBrighterFatter,
Expand Down Expand Up @@ -768,7 +773,7 @@ def getLinearizer(self, detector):

return linearizer

def gainNormalize(self, **kwargs):
def gainsCorrection(self, **kwargs):
# TODO DM 36639
gains = []
readNoise = []
Expand Down Expand Up @@ -1214,6 +1219,8 @@ def run(self, *, ccdExposure, dnlLUT=None, bias=None, deferredChargeCalib=None,

overscanDetectorConfig = self.config.overscanCamera.getOverscanDetectorConfig(detector)

gains = ptc.gain

if self.config.doHeaderProvenance:
# Inputs have been validated, so we can add their date
# information to the output header.
Expand Down Expand Up @@ -1310,11 +1317,16 @@ def run(self, *, ccdExposure, dnlLUT=None, bias=None, deferredChargeCalib=None,
self.log.info("Applying bias correction.")
isrFunctions.biasCorrection(ccdExposure.getMaskedImage(), bias.getMaskedImage())

if self.config.doGainNormalize:
if self.config.doGainsCorrection:
# TODO DM 36639
self.log.info("Apply temperature dependence to the gains.")
gains, readNoise = self.gainsCorrection(**kwargs)

if self.config.doApplyGains:
# Input units: ADU
# Output units: electrons
# TODO DM 36639
gains, readNoise = self.gainNormalize(**kwargs)
self.log.info("Apply PTC gains (temperature corrected or not) to the image.")
isrFunctions.applyGains(ccdExposure, normalizeGains=False, ptcGains=gains)

if self.config.doDeferredCharge:
# Input units: electrons
Expand Down

0 comments on commit 2ab2c8e

Please sign in to comment.