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

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

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

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

# 

# This product includes software developed by the LSST Project 

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

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

# 

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

# license that can be found in the LICENSE file. 

 

"""Metadata translation code for LSST PhoSim FITS headers""" 

 

__all__ = ("PhosimTranslator", ) 

 

import logging 

 

import astropy.units as u 

import astropy.units.cds as cds 

 

from astro_metadata_translator import cache_translation 

from astro_metadata_translator.translators.helpers import tracking_from_degree_headers, \ 

altaz_from_degree_headers 

 

from .lsstsim import LsstSimTranslator 

 

log = logging.getLogger(__name__) 

 

 

class PhosimTranslator(LsstSimTranslator): 

"""Metadata translator for LSST PhoSim data. 

""" 

 

name = "PhoSim" 

"""Name of this translation class""" 

 

_const_map = { 

"instrument": "PhoSim", 

"boresight_rotation_coord": "sky", 

"observation_type": "science", 

"object": "UNKNOWN", 

"relative_humidity": 40.0, 

} 

 

_trivial_map = { 

"detector_group": "RAFTNAME", 

"observation_id": "OBSID", 

"science_program": "RUNNUM", 

"exposure_id": "OBSID", 

"visit_id": "OBSID", 

"physical_filter": "FILTER", 

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

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

"temperature": ("TEMPERA", dict(unit=u.deg_C)), 

"pressure": ("PRESS", dict(unit=cds.mmHg)), 

"boresight_rotation_angle": (["ROTANGZ", "ROTANGLE"], dict(unit=u.deg)), 

"boresight_airmass": "AIRMASS", 

"detector_name": "SENSNAME", 

"detector_serial": "LSST_NUM", 

} 

 

cameraPolicyFile = "policy/phosim.yaml" 

 

@classmethod 

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

"""Indicate whether this translation class can translate the 

supplied header. 

 

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

the ``CREATOR`` header. 

 

Parameters 

---------- 

header : `dict`-like 

Header to convert to standardized form. 

filename : `str`, optional 

Name of file being translated. 

 

Returns 

------- 

can : `bool` 

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

otherwise. 

""" 

return cls.can_translate_with_options(header, {"CREATOR": "PHOSIM", "TESTTYPE": "PHOSIM"}, 

filename=filename) 

 

@cache_translation 

def to_tracking_radec(self): 

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

radecsys = ("RADESYS",) 

radecpairs = (("RATEL", "DECTEL"), ("RA_DEG", "DEC_DEG"), ("BORE-RA", "BORE-DEC")) 

return tracking_from_degree_headers(self, radecsys, radecpairs) 

 

@cache_translation 

def to_altaz_begin(self): 

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

# Fallback to the "derive from ra/dec" if keys are missing 

if self.are_keys_ok(["ZENITH", "AZIMUTH"]): 

return altaz_from_degree_headers(self, (("ZENITH", "AZIMUTH"),), 

self.to_datetime_begin(), is_zd=set(["ZENITH"])) 

else: 

return super().to_altaz_begin()