Skip to content

Commit

Permalink
Sort by detector id to ensure reproducibility
Browse files Browse the repository at this point in the history
Order of inputs is not guaranteed, and the weighting per detector to the
full focal plane sky model can depend (very weakly) on the order of inputs,
so sort them by detector to guarantee reproducible results for the same set
of inputs.
  • Loading branch information
laurenam committed Dec 20, 2021
1 parent 016d7c0 commit 9533a96
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion python/lsst/pipe/drivers/skyCorrection.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,13 @@ class SkyCorrectionTask(pipeBase.PipelineTask, BatchPoolTask):

def runQuantum(self, butlerQC, inputRefs, outputRefs):

# reorder skyCalibs and calBkgArray per calExpArray
# Reorder the skyCalibs, calBkgArray, and calExpArray inputRefs and the
# skyCorr outputRef sorted by detector id to ensure reproducibility.
detectorOrder = [ref.dataId['detector'] for ref in inputRefs.calExpArray]
detectorOrder.sort()
inputRefs.calExpArray = reorderAndPadList(inputRefs.calExpArray,
[ref.dataId['detector'] for ref in inputRefs.calExpArray],
detectorOrder)
inputRefs.skyCalibs = reorderAndPadList(inputRefs.skyCalibs,
[ref.dataId['detector'] for ref in inputRefs.skyCalibs],
detectorOrder)
Expand Down Expand Up @@ -286,6 +291,9 @@ def runDataRef(self, expRef):

dataIdList = [ccdRef.dataId for ccdRef in expRef.subItems("ccd") if
ccdRef.datasetExists(self.config.calexpType)]
ccdList = [dataId["ccd"] for dataId in dataIdList]
# Order inputs sorted by detector id to ensure reproducibility
dataIdList = [dataId for _, dataId in sorted(zip(ccdList, dataIdList))]

exposures = pool.map(self.loadImage, dataIdList)
if DEBUG:
Expand Down

0 comments on commit 9533a96

Please sign in to comment.