Coverage for python/lsst/obs/subaru/gen3/hsc/rawFormatter.py : 65%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of obs_subaru.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
22from lsst.afw.image import ImageU, bboxFromMetadata
23from lsst.afw.geom import makeSkyWcs, makeFlippedWcs
24from lsst.afw.math import flipImage
25from lsst.geom import Point2D
26from lsst.obs.base.fitsRawFormatterBase import FitsRawFormatterBase
27from astro_metadata_translator import HscTranslator
29from ....hsc.hscFilters import HSC_FILTER_DEFINITIONS
30from . import HyperSuprimeCam
32__all__ = ("HyperSuprimeCamRawFormatter", "HyperSuprimeCamCornerRawFormatter")
35class HyperSuprimeCamRawFormatter(FitsRawFormatterBase):
36 """Gen3 Butler Formatters for HSC raw data.
37 """
39 FLIP_LR = True
40 FLIP_TB = False
41 translatorClass = HscTranslator
42 filterDefinitions = HSC_FILTER_DEFINITIONS
44 def getDetector(self, id):
45 return HyperSuprimeCam().getCamera()[id]
47 def _createSkyWcsFromMetadata(self):
48 # We need to know which direction the chip is "flipped" in order to
49 # make a sensible WCS from the header metadata.
50 wcs = makeSkyWcs(self.metadata, strip=True)
51 dimensions = bboxFromMetadata(self.metadata).getDimensions()
52 center = Point2D(dimensions/2.0)
53 return makeFlippedWcs(wcs, self.FLIP_LR, self.FLIP_TB, center)
55 def readImage(self):
56 if self.fileDescriptor.parameters:
57 # It looks like the Gen2 std_raw code wouldn't have handled
58 # flipping vs. subimages correctly, so we won't bother to either.
59 # But we'll make sure no one tries to get a subimage, rather than
60 # doing something confusing.
61 raise NotImplementedError("Formatter does not support subimages.")
62 image = ImageU(self.fileDescriptor.location.path)
63 return flipImage(image, self.FLIP_LR, self.FLIP_TB)
66class HyperSuprimeCamCornerRawFormatter(HyperSuprimeCamRawFormatter):
68 FLIP_LR = False
69 FLIP_TB = True