Coverage for python/lsst/obs/subaru/gen3/hsc/gen2to3.py : 89%

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/>.
22"""Gen2->Gen3 Data repo conversion specializations for Hyper Suprime-Cam
23"""
25from lsst.obs.base.gen2to3 import Translator, KeyHandler, ConstantKeyHandler, CopyKeyHandler
27from ....hsc.hscFilters import HSC_FILTER_DEFINITIONS
30__all__ = ()
33class HscAbstractFilterKeyHandler(KeyHandler):
34 """KeyHandler for HSC filter keys that should be mapped to AbstractFilters.
35 """
37 __slots__ = ("_map",)
39 def __init__(self):
40 super().__init__("abstract_filter")
41 self._map = {d.physical_filter: d.abstract_filter for d in HSC_FILTER_DEFINITIONS
42 if d.physical_filter is not None}
44 def extract(self, gen2id, skyMap, skyMapName, datasetTypeName):
45 physical = gen2id["filter"]
46 return self._map.get(physical, physical)
49# Translate Gen2 `filter` to AbstractFilter if it hasn't been consumed yet and gen2keys includes tract.
50Translator.addRule(HscAbstractFilterKeyHandler(), instrument="HSC", gen2keys=("filter", "tract"),
51 consume=("filter",))
53# Add instrument for HSC transmission curve datasets (transmission_sensor is
54# already handled by the above translators).
55Translator.addRule(ConstantKeyHandler("instrument", "HSC"),
56 instrument="HSC", datasetTypeName="transmission_optics")
57Translator.addRule(ConstantKeyHandler("instrument", "HSC"),
58 instrument="HSC", datasetTypeName="transmission_atmosphere")
59Translator.addRule(ConstantKeyHandler("instrument", "HSC"),
60 instrument="HSC", datasetTypeName="transmission_filter")
61Translator.addRule(CopyKeyHandler("physical_filter", "filter"),
62 instrument="HSC", datasetTypeName="transmission_filter")