Coverage for python/lsst/obs/lsst/translators/lsst_ucdcam.py: 73%

24 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-04-24 04:06 -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 LSST UC Davis Test Stand headers""" 

12 

13__all__ = ("LsstUCDCamTranslator", ) 

14 

15import logging 

16import astropy.units as u 

17from astropy.time import TimeDelta 

18 

19from .lsst import LsstBaseTranslator 

20 

21log = logging.getLogger(__name__) 

22 

23 

24LSST_UCDCAM = "LSST-UCDCam" 

25 

26 

27class LsstUCDCamTranslator(LsstBaseTranslator): 

28 """Metadata translator for LSST UC Davis Test Stand.""" 

29 

30 name = LSST_UCDCAM 

31 """Name of this translation class.""" 

32 

33 supported_instrument = LSST_UCDCAM 

34 """Supports the LSST-UCDCam instrument.""" 

35 

36 _const_map = { 

37 "instrument": LSST_UCDCAM, 

38 "telescope": None, 

39 "location": None, 

40 "boresight_rotation_coord": None, 

41 "boresight_rotation_angle": None, 

42 "boresight_airmass": None, 

43 "tracking_radec": None, 

44 "altaz_begin": None, 

45 "object": "UNKNOWN", 

46 "relative_humidity": None, 

47 "temperature": None, 

48 "pressure": None, 

49 } 

50 

51 _trivial_map = { 

52 "detector_group": "RAFTBAY", 

53 "detector_name": "CCDSLOT", 

54 "observation_id": "OBSID", 

55 "detector_serial": "LSST_NUM", 

56 "exposure_time": ("EXPTIME", dict(unit=u.s)), 

57 "science_program": ("RUNNUM", dict(default="unknown")) 

58 } 

59 

60 cameraPolicyFile = "policy/ucd.yaml" 

61 

62 _ROLLOVER_TIME = TimeDelta(0, scale="tai", format="sec") 

63 """This instrument did not offset the observing day.""" 

64 

65 @classmethod 

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

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

68 supplied header. 

69 

70 Parameters 

71 ---------- 

72 header : `dict`-like 

73 Header to convert to standardized form. 

74 filename : `str`, optional 

75 Name of file being translated. 

76 

77 Returns 

78 ------- 

79 can : `bool` 

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

81 otherwise. 

82 """ 

83 if "INSTRUME" in header: 

84 if header["INSTRUME"].lower() in (cls.supported_instrument.lower(), "LSST-UCDCam-ITL".lower()): 

85 return True 

86 return False