Coverage for python / lsst / obs / subaru / rawFormatter.py: 0%
29 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-15 00:14 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-15 00:14 +0000
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 import FitsRawFormatterBase
27from astro_metadata_translator import HscTranslator
29from ..hsc.hscFilters import HSC_FILTER_DEFINITIONS
30from . import HyperSuprimeCam
32__all__ = ("HyperSuprimeCamRawFormatter", "HyperSuprimeCamCornerRawFormatter",
33 )
36class HyperSuprimeCamRawFormatter(FitsRawFormatterBase):
37 """Gen3 Butler Formatters for HSC raw data.
38 """
40 FLIP_LR = True
41 FLIP_TB = False
42 translatorClass = HscTranslator
43 filterDefinitions = HSC_FILTER_DEFINITIONS
45 def getDetector(self, id):
46 return HyperSuprimeCam().getCamera()[id]
48 def _createSkyWcsFromMetadata(self):
49 # We need to know which direction the chip is "flipped" in order to
50 # make a sensible WCS from the header metadata.
51 wcs = makeSkyWcs(self.metadata, strip=True)
52 dimensions = bboxFromMetadata(self.metadata).getDimensions()
53 center = Point2D(dimensions/2.0)
54 return makeFlippedWcs(wcs, self.FLIP_LR, self.FLIP_TB, center)
56 def readImage(self):
57 if self.file_descriptor.parameters:
58 # It looks like the Gen2 std_raw code wouldn't have handled
59 # flipping vs. subimages correctly, so we won't bother to either.
60 # But we'll make sure no one tries to get a subimage, rather than
61 # doing something confusing.
62 raise NotImplementedError("Formatter does not support subimages.")
63 image = ImageU(self._reader_path)
64 return flipImage(image, self.FLIP_LR, self.FLIP_TB)
67class HyperSuprimeCamCornerRawFormatter(HyperSuprimeCamRawFormatter):
69 FLIP_LR = False
70 FLIP_TB = True