Coverage for python/lsst/obs/fiberspectrograph/_instrument.py: 100%

24 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-16 09:26 +0000

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/>. 

21 

22__all__ = ("FiberSpectrograph", ) 

23 

24import lsst.obs.base.yamlCamera as yamlCamera 

25from lsst.obs.base import VisitSystem 

26from lsst.obs.lsst import LsstCam 

27from lsst.resources import ResourcePath 

28from .filters import FIBER_SPECTROGRAPH_FILTER_DEFINITIONS 

29from .translator import FiberSpectrographTranslator 

30 

31 

32class FiberSpectrograph(LsstCam): 

33 """Gen3 instrument for the Rubin fiber spectrographs 

34 

35 Parameters 

36 ---------- 

37 camera : `lsst.cameraGeom.Camera` 

38 Camera object from which to extract detector information. 

39 filters : `list` of `FilterDefinition` 

40 An ordered list of filters to define the set of PhysicalFilters 

41 associated with this instrument in the registry. 

42 """ 

43 filterDefinitions = FIBER_SPECTROGRAPH_FILTER_DEFINITIONS 

44 instrument = "FiberSpec" 

45 policyName = "fiberSpectrograph" 

46 translatorClass = FiberSpectrographTranslator 

47 visitSystem = VisitSystem.BY_SEQ_START_END 

48 raw_definition = ("rawSpectrum", 

49 ("instrument", "exposure", "detector"), 

50 "FiberSpectrum") 

51 

52 @classmethod 

53 def getCamera(cls): 

54 # Constructing a YAML camera takes a long time but we rely on 

55 # yamlCamera to cache for us. 

56 cameraYamlFile = ResourcePath( 

57 f"resource://lsst.obs.fiberspectrograph/resources/policy/{cls.policyName}.yaml" 

58 ) 

59 with cameraYamlFile.as_local() as local_file: 

60 return yamlCamera.makeCamera(local_file.ospath) 

61 

62 def getRawFormatter(self, dataId): 

63 # Docstring inherited from Instrument.getRawFormatter 

64 # local import to prevent circular dependency 

65 from .rawFormatter import FiberSpectrographRawFormatter 

66 return FiberSpectrographRawFormatter 

67 

68 def extractDetectorRecord(self, camGeomDetector): 

69 """Create a Gen3 Detector entry dict from a cameraGeom.Detector. 

70 """ 

71 return dict( 

72 instrument=self.getName(), 

73 id=camGeomDetector.getId(), 

74 full_name=camGeomDetector.getName(), 

75 purpose=str(camGeomDetector.getType()).split(".")[-1] 

76 )