Skip to content

Commit

Permalink
Add override for SkyWcs to flip DECam camera geometry
Browse files Browse the repository at this point in the history
Until RFC-605 is implemented, we don't have a way to manage the parity of
the camera geometry, so we have to hack around it with this.
  • Loading branch information
parejkoj committed Jun 26, 2019
1 parent 38cde5c commit 77751d9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 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,6 +31,7 @@
from lsst.afw.fits import readMetadata
from lsst.afw.geom import makeSkyWcs
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 @@ -264,6 +266,27 @@ def std_raw(self, item, 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)
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

0 comments on commit 77751d9

Please sign in to comment.