Coverage for python/lsst/obs/decam/instrument.py : 44%

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_decam.
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"""Butler instrument description for the Dark Energy Camera.
23"""
25__all__ = ("DarkEnergyCamera",)
27import os
29from lsst.afw.cameraGeom import makeCameraFromPath, CameraConfig
30from lsst.obs.base import Instrument
31from lsst.obs.base.gen2to3 import AbstractToPhysicalFilterKeyHandler, TranslatorFactory
32from lsst.obs.decam.decamFilters import DECAM_FILTER_DEFINITIONS
34from lsst.daf.butler.core.utils import getFullTypeName
35from lsst.utils import getPackageDir
38class DarkEnergyCamera(Instrument):
39 filterDefinitions = DECAM_FILTER_DEFINITIONS
40 policyName = "decam"
41 obsDataPackage = "obs_decam_data"
43 def __init__(self, **kwargs):
44 super().__init__(**kwargs)
45 packageDir = getPackageDir("obs_decam")
46 self.configPaths = [os.path.join(packageDir, "config")]
48 @classmethod
49 def getName(cls):
50 return "DECam"
52 def getCamera(self):
53 path = os.path.join(getPackageDir("obs_decam"), self.policyName, "camGeom")
54 config = CameraConfig()
55 config.load(os.path.join(path, "camera.py"))
56 return makeCameraFromPath(
57 cameraConfig=config,
58 ampInfoPath=path,
59 shortNameFunc=lambda name: name.replace(" ", "_"),
60 )
62 def register(self, registry):
63 camera = self.getCamera()
64 obsMax = 2**31
65 registry.insertDimensionData(
66 "instrument",
67 {"name": self.getName(), "detector_max": 64, "visit_max": obsMax, "exposure_max": obsMax,
68 "class_name": getFullTypeName(self),
69 }
70 )
72 for detector in camera:
73 registry.insertDimensionData(
74 "detector",
75 {
76 "instrument": self.getName(),
77 "id": detector.getId(),
78 "full_name": detector.getName(),
79 "name_in_raft": detector.getName()[1:],
80 "raft": detector.getName()[0],
81 "purpose": str(detector.getType()).split(".")[-1],
82 }
83 )
85 self._registerFilters(registry)
87 def getRawFormatter(self, dataId):
88 # local import to prevent circular dependency
89 from .rawFormatter import DarkEnergyCameraRawFormatter
90 return DarkEnergyCameraRawFormatter
92 def makeDataIdTranslatorFactory(self) -> TranslatorFactory:
93 # Docstring inherited from lsst.obs.base.Instrument.
94 factory = TranslatorFactory()
95 factory.addGenericInstrumentRules(self.getName(), calibFilterType="abstract_filter",
96 detectorKey="ccdnum")
97 # DECam calibRegistry entries are abstract_filters, but we need physical_filter
98 # in the gen3 registry.
99 factory.addRule(AbstractToPhysicalFilterKeyHandler(self.filterDefinitions),
100 instrument=self.getName(),
101 gen2keys=("filter",),
102 consume=("filter",),
103 datasetTypeName="cpFlat")
104 return factory