Coverage for python/lsst/obs/fiberspectrograph/_instrument.py: 81%
25 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-04-26 04:24 -0700
« prev ^ index » next coverage.py v7.5.0, created at 2024-04-26 04:24 -0700
1# This file is part of obs_fiberspectrograph
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__ = ("FiberSpectrograph", )
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 FIBER_SPECTROGRAPH_FILTER_DEFINITIONS
31from .translator import FiberSpectrographTranslator
33PACKAGE_DIR = getPackageDir("obs_fiberspectrograph")
36class FiberSpectrograph(LsstCam):
37 """Gen3 instrument for the Rubin fiber spectrographs
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.
46 """
47 filterDefinitions = FIBER_SPECTROGRAPH_FILTER_DEFINITIONS
48 instrument = "FiberSpec"
49 policyName = "fiberSpectrograph"
50 translatorClass = FiberSpectrographTranslator
51 visitSystem = VisitSystem.BY_SEQ_START_END
52 raw_definition = ("rawSpectrum",
53 ("instrument", "exposure", "detector"),
54 "FiberSpectrum")
56 @classmethod
57 def getCamera(cls):
58 # Constructing a YAML camera takes a long time but we rely on
59 # yamlCamera to cache for us.
60 # N.b. can't inherit as PACKAGE_DIR isn't in the class
61 cameraYamlFile = os.path.join(PACKAGE_DIR, "policy", f"{cls.policyName}.yaml")
62 return yamlCamera.makeCamera(cameraYamlFile)
64 def getRawFormatter(self, dataId):
65 # Docstring inherited from Instrument.getRawFormatter
66 # local import to prevent circular dependency
67 from .rawFormatter import FiberSpectrographRawFormatter
68 return FiberSpectrographRawFormatter
70 def extractDetectorRecord(self, camGeomDetector):
71 """Create a Gen3 Detector entry dict from a cameraGeom.Detector.
72 """
73 return dict(
74 instrument=self.getName(),
75 id=camGeomDetector.getId(),
76 full_name=camGeomDetector.getName(),
77 purpose=str(camGeomDetector.getType()).split(".")[-1]
78 )