Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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 ImSim headers""" 

12 

13__all__ = ("LsstImSimTranslator", ) 

14 

15import logging 

16import astropy.units as u 

17from astropy.coordinates import Angle 

18 

19from astro_metadata_translator import cache_translation 

20from astro_metadata_translator.translators.helpers import tracking_from_degree_headers 

21 

22from .lsstsim import LsstSimTranslator 

23 

24log = logging.getLogger(__name__) 

25 

26 

27class LsstImSimTranslator(LsstSimTranslator): 

28 """Metadata translation class for ImSim headers""" 

29 

30 name = "LSST-ImSim" 

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

32 

33 _const_map = { 

34 "instrument": "LSST-ImSim", 

35 "boresight_rotation_coord": "sky", 

36 "object": "UNKNOWN", 

37 "pressure": None, 

38 "temperature": None, 

39 "relative_humidity": 40.0, 

40 } 

41 

42 _trivial_map = { 

43 "detector_group": "RAFTNAME", 

44 "detector_name": "SENSNAME", 

45 "observation_id": "OBSID", 

46 "science_program": "RUNNUM", 

47 "exposure_id": "OBSID", 

48 "visit_id": "OBSID", 

49 "physical_filter": "FILTER", 

50 "dark_time": ("DARKTIME", dict(unit=u.s)), 

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

52 "detector_serial": "LSST_NUM", 

53 } 

54 

55 cameraPolicyFile = "policy/imsim.yaml" 

56 

57 @classmethod 

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

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

60 supplied header. 

61 

62 There is no ``INSTRUME`` header in ImSim data. Instead we use 

63 the ``TESTTYPE`` header. 

64 

65 Parameters 

66 ---------- 

67 header : `dict`-like 

68 Header to convert to standardized form. 

69 filename : `str`, optional 

70 Name of file being translated. 

71 

72 Returns 

73 ------- 

74 can : `bool` 

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

76 otherwise. 

77 """ 

78 return cls.can_translate_with_options(header, {"TESTTYPE": "IMSIM"}, 

79 filename=filename) 

80 

81 @cache_translation 

82 def to_tracking_radec(self): 

83 # Docstring will be inherited. Property defined in properties.py 

84 radecsys = ("RADESYS",) 

85 radecpairs = (("RATEL", "DECTEL"),) 

86 return tracking_from_degree_headers(self, radecsys, radecpairs) 

87 

88 @cache_translation 

89 def to_boresight_airmass(self): 

90 # Docstring will be inherited. Property defined in properties.py 

91 altaz = self.to_altaz_begin() 

92 if altaz is not None: 

93 return altaz.secz.to_value() 

94 return None 

95 

96 @cache_translation 

97 def to_boresight_rotation_angle(self): 

98 angle = Angle(90.*u.deg) - Angle(self.quantity_from_card("ROTANGLE", u.deg)) 

99 angle = angle.wrap_at("360d") 

100 return angle