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 part of obs_base. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://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 GNU General Public License 

20# along with this program. If not, see <http://www.gnu.org/licenses/>. 

21 

22import os 

23import unittest 

24 

25import lsst.utils 

26from lsst.daf.butler import Registry, ButlerConfig 

27from lsst.obs.base import Instrument, FilterDefinitionCollection 

28 

29"""Tests of the Instrument class. 

30""" 

31 

32 

33class DummyCam(Instrument): 

34 

35 filterDefinitions = FilterDefinitionCollection() 

36 

37 @classmethod 

38 def getName(cls): 

39 return "DummyCam" 

40 

41 def getCamera(self): 

42 return None 

43 

44 def register(self, registry): 

45 """Insert Instrument, physical_filter, and detector entries into a 

46 `Registry`. 

47 """ 

48 dataId = {"instrument": self.getName()} 

49 registry.insertDimensionData("instrument", dataId) 

50 for f in ("dummy_g", "dummy_u"): 

51 registry.insertDimensionData("physical_filter", 

52 dict(dataId, physical_filter=f, abstract_filter=f[-1])) 

53 for d in (1, 2): 

54 registry.insertDimensionData("detector", 

55 dict(dataId, id=d, full_name=str(d))) 

56 

57 def getRawFormatter(self, dataId): 

58 # Docstring inherited fromt Instrument.getRawFormatter. 

59 return None 

60 

61 def writeCuratedCalibrations(self, butler): 

62 pass 

63 

64 def applyConfigOverrides(self, name, config): 

65 pass 

66 

67 

68class InstrumentTestCase(unittest.TestCase): 

69 """Test for Instrument. 

70 """ 

71 

72 def setUp(self): 

73 self.configDir = lsst.utils.getPackageDir('daf_butler') 

74 self.configFile = os.path.join(self.configDir, "tests/config/basic/butler.yaml") 

75 

76 def testRegister(self): 

77 registry = Registry.fromConfig(ButlerConfig(self.configFile)) 

78 dummyCam = DummyCam() 

79 dummyCam.register(registry) 

80 

81 

82if __name__ == "__main__": 82 ↛ 83line 82 didn't jump to line 83, because the condition on line 82 was never true

83 unittest.main()