Coverage for python/lsst/obs/rubinGenericCamera/_instrument.py: 77%
45 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-13 04:31 -0700
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-13 04:31 -0700
1# This file is part of obs_rubinGenericCamera
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__all__ = ("RubinGenericCamera", "StarTrackerNarrow", "StarTrackerWide", "StarTrackerFast")
24import os.path
26import lsst.obs.base.yamlCamera as yamlCamera
27from lsst.utils import getPackageDir
28from lsst.obs.base import VisitSystem
29from lsst.obs.lsst import LsstCam
30from .filters import RUBIN_GENERIC_CAMERA_FILTER_DEFINITIONS
31from .translator import StarTrackerNarrowTranslator, StarTrackerWideTranslator, StarTrackerFastTranslator
33PACKAGE_DIR = getPackageDir("obs_rubinGenericCamera")
36class RubinGenericCamera(LsstCam):
37 """Gen3 Butler specialization for the Rubin Generic Cameras
39 Parameters
40 ----------
41 camera : `lsst.cameraGeom.Camera`
42 Camera object from which to extract detector information.
43 filters : `list` of `FilterDefinition`
44 An ordered list of filters to define the set of PhysicalFilters
45 associated with this instrument in the registry.
47 While both the camera geometry and the set of filters associated with a
48 camera are expected to change with time in general, their Butler Registry
49 representations defined by an Instrument do not. Instead:
51 - We only extract names, IDs, and purposes from the detectors in the
52 camera, which should be static information that actually reflects
53 detector "slots" rather than the physical sensors themselves. Because
54 the distinction between physical sensors and slots is unimportant in
55 the vast majority of Butler use cases, we just use "detector" even
56 though the concept really maps better to "detector slot". Ideally in
57 the future this distinction between static and time-dependent
58 information would be encoded in cameraGeom itself (e.g. by making the
59 time-dependent Detector class inherit from a related class that only
60 carries static content).
62 - The Butler Registry is expected to contain physical_filter entries for
63 all filters an instrument has ever had, because we really only care
64 about which filters were used for particular observations, not which
65 filters were *available* at some point in the past. And changes in
66 individual filters over time will be captured as changes in their
67 TransmissionCurve datasets, not changes in the registry content (which
68 is really just a label). While at present Instrument and Registry
69 do not provide a way to add new physical_filters, they will in the
70 future.
71 """
72 filterDefinitions = RUBIN_GENERIC_CAMERA_FILTER_DEFINITIONS
73 instrument = None # you must specialise this class
74 policyName = None # you must specialise this class
75 translatorClass = None # you must specialise this class
76 visitSystem = VisitSystem.BY_SEQ_START_END
78 @classmethod
79 def getCamera(cls):
80 # Constructing a YAML camera takes a long time but we rely on
81 # yamlCamera to cache for us.
82 # N.b. can't inherit as PACKAGE_DIR isn't in the class
83 cameraYamlFile = os.path.join(PACKAGE_DIR, "policy", f"{cls.policyName}.yaml")
84 return yamlCamera.makeCamera(cameraYamlFile)
86 def getRawFormatter(self, dataId):
87 return None
89 def extractDetectorRecord(self, camGeomDetector):
90 """Create a Gen3 Detector entry dict from a cameraGeom.Detector.
91 """
92 purpose = str(camGeomDetector.getType()).split(".")[-1]
94 return dict(
95 instrument=self.getName(),
96 id=camGeomDetector.getId(),
97 full_name=camGeomDetector.getName(),
98 purpose=purpose,
99 )
102class StarTrackerNarrow(RubinGenericCamera):
103 """Specialization of Rubin Generic Camera for the narrow-field StarTracker
105 Parameters
106 ----------
107 camera : `lsst.cameraGeom.Camera`
108 Camera object from which to extract detector information.
109 filters : `list` of `FilterDefinition`
110 An ordered list of filters to define the set of PhysicalFilters
111 associated with this instrument in the registry.
112 """
113 instrument = "StarTrackerNarrow"
114 policyName = "starTrackerNarrow"
115 translatorClass = StarTrackerNarrowTranslator
117 def getRawFormatter(self, dataId):
118 # Docstring inherited from Instrument.getRawFormatter
119 # local import to prevent circular dependency
120 from .rawFormatter import StarTrackerNarrowRawFormatter
121 return StarTrackerNarrowRawFormatter
124class StarTrackerWide(StarTrackerNarrow):
125 """Specialization of Rubin Generic Camera for the wide-field StarTracker
127 Parameters
128 ----------
129 camera : `lsst.cameraGeom.Camera`
130 Camera object from which to extract detector information.
131 filters : `list` of `FilterDefinition`
132 An ordered list of filters to define the set of PhysicalFilters
133 associated with this instrument in the registry.
134 """
135 instrument = "StarTrackerWide"
136 policyName = "starTrackerWide"
137 translatorClass = StarTrackerWideTranslator
139 def getRawFormatter(self, dataId):
140 # Docstring inherited from Instrument.getRawFormatter
141 # local import to prevent circular dependency
142 from .rawFormatter import StarTrackerWideRawFormatter
143 return StarTrackerWideRawFormatter
146class StarTrackerFast(StarTrackerNarrow):
147 """Specialization of Rubin Generic Camera for the high-cadence Star Tracker
149 Parameters
150 ----------
151 camera : `lsst.cameraGeom.Camera`
152 Camera object from which to extract detector information.
153 filters : `list` of `FilterDefinition`
154 An ordered list of filters to define the set of PhysicalFilters
155 associated with this instrument in the registry.
156 """
157 instrument = "StarTrackerFast"
158 policyName = "starTrackerFast"
159 translatorClass = StarTrackerFastTranslator
161 def getRawFormatter(self, dataId):
162 # Docstring inherited from Instrument.getRawFormatter
163 # local import to prevent circular dependency
164 from .rawFormatter import StarTrackerFastRawFormatter
165 return StarTrackerFastRawFormatter