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-20154: Implement new initial WCS design #113

Merged
merged 3 commits into from
Aug 23, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 25 additions & 9 deletions python/lsst/obs/decam/decamMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#
import os
import re
import traceback

import numpy as np

Expand All @@ -30,7 +31,8 @@
import lsst.afw.image.utils as afwImageUtils
from lsst.afw.fits import readMetadata
from lsst.afw.geom import makeSkyWcs
from lsst.obs.base import CameraMapper, exposureFromImage
from lsst.obs.base import CameraMapper
from lsst.obs.base.utils import createInitialSkyWcs, InitialSkyWcsError
from lsst.daf.persistence import ButlerLocation, Storage, Policy
from .makeDecamRawVisitInfo import MakeDecamRawVisitInfo

Expand Down Expand Up @@ -263,16 +265,30 @@ def std_raw(self, item, dataId):
result : `lsst.afw.image.Exposure`
The standardized Exposure.
"""
# Convert the raw DecoratedImage to an Exposure, set metadata and wcs.
exp = exposureFromImage(item, logger=self.log)
md = exp.getMetadata()
visitInfo = self.makeRawVisitInfo(md=md)
exp.getInfo().setVisitInfo(visitInfo)

# Standardize an Exposure, including setting the photoCalib object
return self._standardizeExposure(self.exposures['raw'], exp, dataId,
return self._standardizeExposure(self.exposures['raw'], item, dataId,
trimmed=False)

def _createInitialSkyWcs(self, exposure):
# DECam has a coordinate system flipped on X with respect to our
# VisitInfo definition of the field angle orientation.
self._createSkyWcsFromMetadata(exposure)

if exposure.getInfo().getVisitInfo() is None:
msg = "No VisitInfo; cannot access boresight information. Defaulting to metadata-based SkyWcs."
self.log.warn(msg)
return
try:
newSkyWcs = createInitialSkyWcs(exposure.getInfo().getVisitInfo(), exposure.getDetector(),
flipX=True)
exposure.setWcs(newSkyWcs)
except InitialSkyWcsError as e:
msg = "Cannot create SkyWcs using VisitInfo and Detector, using metadata-based SkyWcs: %s"
self.log.warn(msg, e)
mrawls marked this conversation as resolved.
Show resolved Hide resolved
self.log.debug("Exception was: %s", traceback.TracebackException.from_exception(e))
if e.__context__ is not None:
self.log.debug("Root-cause Exception was: %s",
traceback.TracebackException.from_exception(e.__context__))

def std_dark(self, item, dataId):
exp = afwImage.makeExposure(afwImage.makeMaskedImage(item))
rawPath = self.map_raw(dataId).getLocations()[0]
Expand Down