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 LSST simulations""" 

12 

13__all__ = ("LsstSimTranslator", ) 

14 

15import warnings 

16import logging 

17 

18import astropy.utils.exceptions 

19from astropy.coordinates import AltAz 

20from astro_metadata_translator import cache_translation 

21 

22from .lsst import LsstBaseTranslator, SIMONYI_LOCATION, SIMONYI_TELESCOPE 

23 

24log = logging.getLogger(__name__) 

25 

26 

27class LsstSimTranslator(LsstBaseTranslator): 

28 """Shared routines for LSST Simulated Data. 

29 """ 

30 

31 # No constant or trivial mappings defined 

32 _const_map = {} 

33 _trivial_map = {} 

34 

35 @classmethod 

36 def max_exposure_id(cls): 

37 """The maximum exposure ID expected from this instrument. 

38 

39 Returns 

40 ------- 

41 max_exposure_id : `int` 

42 The maximum value. 

43 """ 

44 return 9_999_999 

45 

46 @cache_translation 

47 def to_telescope(self): 

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

49 telescope = None 

50 if self.is_key_ok("OUTFILE") and self._header["OUTFILE"].startswith("lsst"): 

51 telescope = SIMONYI_TELESCOPE 

52 self._used_these_cards("OUTFILE") 

53 elif "LSST_NUM" in self._header: 

54 telescope = SIMONYI_TELESCOPE 

55 self._used_these_cards("LSST_NUM") 

56 return telescope 

57 

58 @cache_translation 

59 def to_location(self): 

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

61 location = None 

62 # In theory simulated files might not be for LSST 

63 tel = self.to_telescope() 

64 if tel == SIMONYI_TELESCOPE: 

65 location = SIMONYI_LOCATION 

66 else: 

67 # Try standard FITS headers 

68 try: 

69 location = super().to_location() 

70 except Exception: 

71 pass 

72 return location 

73 

74 @cache_translation 

75 def to_altaz_begin(self): 

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

77 if self.to_observation_type() == "science": 

78 # Derive from RADec in absence of any other information 

79 radec = self.to_tracking_radec() 

80 if radec is not None: 

81 # This triggers warnings because of the future dates 

82 with warnings.catch_warnings(): 

83 warnings.simplefilter("ignore", category=astropy.utils.exceptions.AstropyWarning) 

84 altaz = radec.transform_to(AltAz) 

85 return altaz 

86 return None