Skip to content

Commit

Permalink
Add exposure length checking
Browse files Browse the repository at this point in the history
Was not previously checking that the user selected exposures
with equal exposure length. Appears in two places so added it
as a function.
  • Loading branch information
mfisherlevine committed Aug 7, 2018
1 parent cc00421 commit abee516
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions python/lsst/cp/pipe/makeBrighterFatterKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ def run(self, dataRef, visitPairs):
dataRef.dataId['visit'] = v2
exp2 = self.isr.runDataRef(dataRef).exposure
del dataRef.dataId['visit']
self._checkExpLengthEqual(exp1, exp2, v1, v2)

self.log.info('Preparing images for cross-correlation calculation for detector %s' % detNum)
# note the shape of these returns depends on level
Expand Down Expand Up @@ -749,6 +750,35 @@ def estimateGains(self, dataRef, visitPairs):
gains[ampName] = 1.0/slopeToUse
return gains, nomGains

@staticmethod
def _checkExpLengthEqual(exp1, exp2, v1=None, v2=None):
"""Check the exposure lengths of two exposures are equal.
Parameters:
-----------
exp1 : `lsst.afw.image.exposure.ExposureF`
First exposure to check
exp2 : `lsst.afw.image.exposure.ExposureF`
Second exposure to check
v1 : `int` or `str`, optional
First visit of the visit pair
v2 : `int` or `str`, optional
Second visit of the visit pair
Raises:
-------
RuntimeError
Raised if the exposure lengths of the two expsoures are not equal
"""
expTime1 = exp1.getInfo().getVisitInfo().getExposureTime()
expTime2 = exp2.getInfo().getVisitInfo().getExposureTime()
if expTime1 != expTime2:
msg = "Exposure lengths for visit pairs must be equal. " + \
"Found %s and %s" % (expTime1, expTime2)
if v1 and v2:
msg += " for visit pair %s, %s" % (v1, v2)
raise RuntimeError(msg)

def _calcMeansAndVars(self, dataRef, v1, v2):
"""Calculate the means, vars, covars, and retieve the nominal gains,
for each amp in each detector.
Expand Down Expand Up @@ -792,6 +822,7 @@ def _calcMeansAndVars(self, dataRef, v1, v2):
exp2 = self.isr.runDataRef(dataRef).exposure
del dataRef.dataId['visit']
exps = [exp1, exp2]
self._checkExpLengthEqual(exp1, exp2, v1, v2)

detector = exps[0].getDetector() # note we lose the detector in the next line as they belong to exp
ims = [self._convertImagelikeToFloatImage(exp) for exp in exps]
Expand Down

0 comments on commit abee516

Please sign in to comment.