Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-17426 #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions python/lsst/pipe/drivers/skyCorrection.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def makeCameraImage(camera, exposures, filename=None, binning=8):
class SkyCorrectionConfig(Config):
"""Configuration for SkyCorrectionTask"""
bgModel = ConfigField(dtype=FocalPlaneBackgroundConfig, doc="Background model")
bgModel2 = ConfigField(dtype=FocalPlaneBackgroundConfig, doc="2nd Background model")
sky = ConfigurableField(target=SkyMeasurementTask, doc="Sky measurement")
maskObjects = ConfigurableField(target=MaskObjectsTask, doc="Mask Objects")
doMaskObjects = Field(dtype=bool, default=True, doc="Mask objects to find good sky?")
Expand All @@ -51,6 +52,7 @@ class SkyCorrectionConfig(Config):
def setDefaults(self):
Config.setDefaults(self)
self.maskObjects.doInterpolate = False

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why disable interpolation here? Because you don't want to destroy the image?
It sounds like doInterpolate shouldn't be a configuration parameter, but a functional parameter for MaskObjectsTask.run.

self.bgModel2.doSmooth = True

def validate(self):
assert not self.maskObjects.doInterpolate
Expand Down Expand Up @@ -99,7 +101,10 @@ def run(self, expRef):
algorithms. We optionally apply:

1. A large-scale background model.
This step removes very-large-scale sky such as moonlight.
2. A sky frame.
3. A medium-scale background model.
This step removes residual sky (This is smooth on the focal plane).

Only the master node executes this method. The data is held on
the slave nodes, which do all the hard work.
Expand Down Expand Up @@ -156,12 +161,30 @@ def run(self, expRef):
calibs = pool.mapToPrevious(self.collectSky, dataIdList)
makeCameraImage(camera, calibs, "sky" + extension)

exposures = self.smoothFocalPlaneSubtraction(camera, pool, dataIdList)

# Persist camera-level image of calexp
image = makeCameraImage(camera, exposures)
expRef.put(image, "calexp_camera")

pool.mapToPrevious(self.write, dataIdList)

def smoothFocalPlaneSubtraction(self, camera, pool, dataIdList):
'''Do 2nd Focal Plane subtraction

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use numpydoc style for docstrings.


After doSky, we get smooth focal plane image.
(Before doSky, sky pistons remain in HSC-G)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is a bit too terse to understand what you mean.

Now make smooth focal plane background and subtract it.
'''
bgModel = FocalPlaneBackground.fromCamera(self.config.bgModel2, camera)
data = [Struct(dataId=dataId, bgModel=bgModel.clone()) for dataId in dataIdList]
bgModelList = pool.mapToPrevious(self.accumulateModel, data)
for ii, bg in enumerate(bgModelList):
self.log.info("Background %d: %d pixels", ii, bg._numbers.array.sum())
bgModel.merge(bg)
exposures = pool.mapToPrevious(self.subtractModel, dataIdList, bgModel)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same code as before (lines 138-143). Can you factor it into a common method so the code isn't duplicated?

return exposures

def loadImage(self, cache, dataId):
"""Load original image and restore the sky

Expand Down