Coverage for python/lsst/obs/lsst/translators/lsstCamSim.py: 65%

27 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-10 03:26 -0700

1# This file is currently part of obs_lsst but is written to allow it 

2# to be migrated to the astro_metadata_translator package at a later date. 

3# 

4# This product includes software developed by the LSST Project 

5# (http://www.lsst.org). 

6# See the LICENSE file in this directory for details of code ownership. 

7# 

8# Use of this source code is governed by a 3-clause BSD-style 

9# license that can be found in the LICENSE file. 

10 

11"""Metadata translation code for the Simulated LSST Camera""" 

12 

13__all__ = ("LsstCamSimTranslator",) 

14 

15import logging 

16import astropy 

17 

18from .lsstCam import LsstCamTranslator 

19from .lsst import SIMONYI_TELESCOPE 

20 

21log = logging.getLogger(__name__) 

22 

23 

24class LsstCamSimTranslator(LsstCamTranslator): 

25 """Metadata translation for the simulated LSST Camera.""" 

26 

27 name = "LSSTCamSim" 

28 """Name of this translation class""" 

29 

30 _const_map = { 

31 "instrument": "LSSTCamSim", 

32 } 

33 

34 cameraPolicyFile = "policy/lsstCamSim.yaml" 

35 

36 @classmethod 

37 def can_translate(cls, header, filename=None): 

38 """Indicate whether this translation class can translate the 

39 supplied header. 

40 

41 Parameters 

42 ---------- 

43 header : `dict`-like 

44 Header to convert to standardized form. 

45 filename : `str`, optional 

46 Name of file being translated. 

47 

48 Returns 

49 ------- 

50 can : `bool` 

51 `True` if the header is recognized by this class. `False` 

52 otherwise. 

53 """ 

54 if "INSTRUME" in header and "TELESCOP" in header: 

55 telescope = header["TELESCOP"] 

56 instrument = header["INSTRUME"].lower() 

57 if instrument == "lsstcamsim" and telescope in (SIMONYI_TELESCOPE, "LSST"): 

58 return True 

59 

60 return False 

61 

62 @classmethod 

63 def fix_header(cls, header, instrument, obsid, filename=None): 

64 """Fix Simulated LSSTCamSim headers. 

65 

66 Notes 

67 ----- 

68 Content will be added as needed. 

69 

70 Corrections are reported as debug level log messages. 

71 

72 See `~astro_metadata_translator.fix_header` for details of the general 

73 process. 

74 """ 

75 modified = False 

76 

77 # Currently, no fixes are required. 

78 

79 return modified 

80 

81 @classmethod 

82 def observing_date_to_offset(cls, observing_date: astropy.time.Time) -> astropy.time.TimeDelta | None: 

83 # Always use the 12 hour offset. 

84 return cls._ROLLOVER_TIME