Skip to content

Commit

Permalink
Load deferred straylight data in Gen3.
Browse files Browse the repository at this point in the history
Use straylight.check() method to determine if stray light correction
should be run.
  • Loading branch information
czwa committed Dec 10, 2019
1 parent 00a6703 commit 3ad9840
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
8 changes: 4 additions & 4 deletions python/lsst/obs/subaru/gen3/hsc/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ def ingestStrayLightData(self, butler, directory, *, transfer=None):
storageClass="StrayLightData",
universe=butler.registry.dimensions)
for detector in self.getCamera():
path = os.path.join(directory, f"yBackground-{detector.getId():03d}.fits")
path = os.path.join(directory, f"ybackground-{detector.getId():03d}.fits")
if not os.path.exists(path):
log.warn(f"No stray light data found for detector {detector.getId()}.")
log.warn(f"No stray light data found for detector {detector.getId()} @ {path}.")
continue
ref = DatasetRef(datasetType, dataId={"instrument": self.getName(),
"detector": detector.getId(),
Expand All @@ -305,6 +305,6 @@ def ingestStrayLightData(self, butler, directory, *, transfer=None):
butler.registry.registerDatasetType(datasetType)
butler.registry.insertDimensionData("calibration_label", {"instrument": self.getName(),
"name": calibrationLabel,
"datetime_begin": datetime.min,
"datetime_begin": datetime.date.min,
"datetime_end": datetime_end})
butler.ingest(datasets, transfer=transfer)
butler.ingest(*datasets, transfer=transfer)
31 changes: 22 additions & 9 deletions python/lsst/obs/subaru/strayLight/yStrayLight.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,26 @@ def readIsrData(self, dataRef, rawExposure):
# Note that this is run only in Gen2; in Gen3 we will rely on having
# a proper butler-recognized dataset type with the right validity
# ranges (though this has not yet been implemented).
detId = rawExposure.getDetector().getId()
if not self.checkFilter(rawExposure):
# No correction to be made
if not self.check(rawExposure):
return None

return SubaruStrayLightData(dataRef.get("yBackground_filename")[0])

def check(self, exposure):
# Docstring inherited from StrayLightTask.check.
detId = exposure.getDetector().getId()
if not self.checkFilter(exposure):
# No correction to be made
return False
if detId in range(104, 112):
# No correction data: assume it's zero
return None
if rawExposure.getInfo().getVisitInfo().getDate().toPython() >= datetime.datetime(2018, 1, 1):
return False
if exposure.getInfo().getVisitInfo().getDate().toPython >= datetime.datetime(2018, 1, 1):
# LEDs causing the stray light have been covered up.
# We believe there is no remaining stray light.
return None
return SubaruStrayLightData(dataRef.get("yBackground_filename")[0])
return False

return True

def run(self, exposure, strayLightData):
"""Subtract the y-band stray light
Expand All @@ -87,9 +95,14 @@ def run(self, exposure, strayLightData):
An opaque object that contains any calibration data used to
correct for stray light.
"""
if not self.check(exposure):
return None

if strayLightData is None:
raise RuntimeError("No strayLightData supplied for correction.")

exposureMetadata = exposure.getMetadata()
detId = exposure.getDetector().getId()

if self.config.doRotatorAngleCorrection:
angleStart, angleEnd = inrStartEnd(exposure.getInfo().getVisitInfo())
self.log.debug(
Expand All @@ -101,7 +114,7 @@ def run(self, exposure, strayLightData):
angleStart = exposureMetadata.getDouble('INR-STR')
angleEnd = None

self.log.info("Correcting y-band background")
self.log.info("Correcting y-band background.")

model = strayLightData.evaluate(angleStart*degrees,
None if angleStart == angleEnd else angleEnd*degrees)
Expand Down

0 comments on commit 3ad9840

Please sign in to comment.