Coverage for python/lsst/obs/lsst/phosim.py: 76%

Shortcuts 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

27 statements  

1# This file is part of obs_lsst. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

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

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the LSST License Statement and 

20# the GNU General Public License along with this program. If not, 

21# see <http://www.lsstcorp.org/LegalNotices/>. 

22# 

23__all__ = ["PhosimMapper", "PhosimParseTask", "PhosimEimgParseTask"] 

24 

25from . import LsstCamMapper, LsstCamMakeRawVisitInfo 

26from .ingest import LsstCamParseTask 

27from .translators import LsstCamPhoSimTranslator 

28from ._instrument import LsstCamPhoSim 

29 

30 

31class PhosimRawVisitInfo(LsstCamMakeRawVisitInfo): 

32 """Make a VisitInfo from the FITS header of a raw image.""" 

33 metadataTranslator = LsstCamPhoSimTranslator 

34 

35 

36class PhosimMapper(LsstCamMapper): 

37 """The Mapper for the phosim simulations of the LsstCam.""" 

38 translatorClass = LsstCamPhoSimTranslator 

39 MakeRawVisitInfoClass = PhosimRawVisitInfo 

40 _gen3instrument = LsstCamPhoSim 

41 

42 _cameraName = "phosim" 

43 yamlFileList = ["imsim/imsimMapper.yaml"] + list(LsstCamMapper.yamlFileList) 

44 

45 def bypass_ccdExposureId_bits(self, datasetType, pythonType, location, dataId): 

46 """How many bits are required for the maximum exposure ID""" 

47 return 34 # To match the value computed in gen3 

48 

49 

50class PhosimParseTask(LsstCamParseTask): 

51 """Parser suitable for phosim data. 

52 """ 

53 

54 _mapperClass = PhosimMapper 

55 _translatorClass = LsstCamPhoSimTranslator 

56 

57 def translate_controller(self, md): 

58 """Always return Simulation as controller for imsim data.""" 

59 return "S" 

60 

61 

62class PhosimEimgParseTask(PhosimParseTask): 

63 """Parser suitable for phosim eimage data. 

64 """ 

65 

66 def getDestination(self, butler, info, filename): 

67 """Get destination for the file. 

68 

69 Parameters 

70 ---------- 

71 butler : `lsst.daf.persistence.Butler` 

72 Data butler 

73 info : data ID 

74 File properties, used as dataId for the butler. 

75 filename : `str` 

76 Input filename. 

77 

78 Returns 

79 ------- 

80 `str` 

81 Destination filename. 

82 """ 

83 

84 eimage = butler.get("eimage_filename", info)[0] 

85 # Ensure filename is devoid of cfitsio directions about HDUs 

86 c = eimage.find("[") 

87 if c > 0: 

88 eimage = eimage[:c] 

89 return eimage