Skip to content

Commit

Permalink
CameraMapper: make header stripping optional
Browse files Browse the repository at this point in the history
We have disabled (by default) the header stripping in construction of the
visitInfo, but perhaps someone wants that feature. This change allows
access to that feature through a keyword argument to
CameraMapper._standardizeExposure.
  • Loading branch information
PaulPrice committed Jan 14, 2020
1 parent 148af60 commit 22f8459
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions python/lsst/obs/base/cameraMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ def _setFilter(self, mapping, item, dataId):
self.log.warn("Filter %s not defined. Set to UNKNOWN." % (filterName))

def _standardizeExposure(self, mapping, item, dataId, filter=True,
trimmed=True, setVisitInfo=True):
trimmed=True, setVisitInfo=True, stripHeader=False):
"""Default standardization function for images.
This sets the Detector from the camera geometry
Expand All @@ -1071,6 +1071,8 @@ def _standardizeExposure(self, mapping, item, dataId, filter=True,
Should detector be marked as trimmed?
setVisitInfo : `bool`
Should Exposure have its VisitInfo filled out from the metadata?
stripHeader : `bool`, optional
Strip header keywords used in determining visitInfo?
Returns
-------
Expand All @@ -1079,7 +1081,7 @@ def _standardizeExposure(self, mapping, item, dataId, filter=True,
"""
try:
exposure = exposureFromImage(item, dataId, mapper=self, logger=self.log,
setVisitInfo=setVisitInfo)
setVisitInfo=setVisitInfo, stripHeader=stripHeader)
except Exception as e:
self.log.error("Could not turn item=%r into an exposure: %s" % (repr(item), e))
raise
Expand Down Expand Up @@ -1308,7 +1310,7 @@ def _initWriteRecipes(self):
self._writeRecipes[storageType] = validationMenu[storageType](recipes[storageType])


def exposureFromImage(image, dataId=None, mapper=None, logger=None, setVisitInfo=True):
def exposureFromImage(image, dataId=None, mapper=None, logger=None, setVisitInfo=True, stripHeader=False):
"""Generate an Exposure from an image-like object
If the image is a DecoratedImage then also set its WCS and metadata
Expand All @@ -1320,6 +1322,17 @@ def exposureFromImage(image, dataId=None, mapper=None, logger=None, setVisitInfo
image : Image-like object
Can be one of lsst.afw.image.DecoratedImage, Image, MaskedImage or
Exposure.
dataId : `dict`, optional
Data identifier: keyword-value pairs identifying the data. Used for
setting the exposureId.
mapper : `lsst.obs.base.CameraMapper`, optional
Butler's mapper for this particular camera.
logger : `lsst.log.Log`, optional
Logging object.
setVisitInfo : `bool`, optional
Set visitInfo in the exposure?
stripHeader : `bool`, optional
Strip header keywords used in setting visitInfo?
Returns
-------
Expand Down Expand Up @@ -1348,7 +1361,8 @@ def exposureFromImage(image, dataId=None, mapper=None, logger=None, setVisitInfo
logger.warn("I can only set the VisitInfo if you provide a mapper")
else:
exposureId = mapper._computeCcdExposureId(dataId)
visitInfo = mapper.makeRawVisitInfo(md=metadata, exposureId=exposureId)
visitInfo = mapper.makeRawVisitInfo(md=metadata, exposureId=exposureId,
stripHeader=stripHeader)

exposure.getInfo().setVisitInfo(visitInfo)

Expand Down

0 comments on commit 22f8459

Please sign in to comment.