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

2This unit test essentially copies the unit test of the same name that 

3exists in sims_utils. However, in this iteration, the test to verify 

4that a mapped filename exists is never skipped. The idea being that we need 

5to make sure that we have loaded the correct version of sims_sed_library. 

6 

7In the future, we will replace this test with a version requirement on 

8sims_sed_library in sims_catUtils' ups table. Right now, we are keeping 

9this test as an extra-paranoid verification that the correct version of 

10sims_sed_library was loaded. 

11""" 

12 

13import os 

14import unittest 

15import lsst.utils.tests 

16 

17from lsst.utils import getPackageDir 

18from lsst.sims.utils import defaultSpecMap 

19 

20 

21def setup_module(module): 

22 lsst.utils.tests.init() 

23 

24 

25class FileMapTest(unittest.TestCase): 

26 

27 def setUp(self): 

28 self.root_dir = getPackageDir('sims_sed_library') 

29 

30 def verifyFile(self, file_name, dir_name): 

31 """ 

32 Verify that specMape[file_name] results in a file in dir dir_name 

33 """ 

34 test_name = defaultSpecMap[file_name] 

35 control_name = os.path.join(dir_name, file_name+'.gz') 

36 msg = '%s should map to %s; it actually maps to %s' % (file_name, control_name, test_name) 

37 self.assertEqual(test_name, control_name, msg=msg) 

38 

39 add_space = file_name+' ' 

40 self.assertNotEqual(add_space, file_name) 

41 test_name = defaultSpecMap[add_space] 

42 msg = '%s should map to %s; it actually maps to %s' % (add_space, control_name, test_name) 

43 self.assertEqual(test_name, control_name, msg=msg) 

44 

45 add_space = ' '+file_name 

46 self.assertNotEqual(add_space, file_name) 

47 test_name = defaultSpecMap[add_space] 

48 msg = '%s should map to %s; it actually maps to %s' % (add_space, control_name, test_name) 

49 self.assertEqual(test_name, control_name, msg=msg) 

50 

51 add_gz = file_name+'.gz' 

52 self.assertNotEqual(add_gz, file_name) 

53 test_name = defaultSpecMap[add_gz] 

54 msg = '%s should map to %s; it actually maps to %s' % (add_gz, control_name, test_name) 

55 self.assertEqual(test_name, control_name, msg=msg) 

56 

57 full_path = os.path.join(self.root_dir, test_name) 

58 msg = '%s does not exist; it should' % full_path 

59 self.assertTrue(os.path.exists(full_path), msg=msg) 

60 

61 def testMLT(self): 

62 """ 

63 Test that defaultSpecMap correctly locates MLT dwarf spectra 

64 """ 

65 self.verifyFile('lte004-3.5-0.0a+0.0.BT-Settl.spec', 'starSED/mlt') 

66 

67 def test_m_spec(self): 

68 """ 

69 Test that defaultSpecMap correctly finds old MLT dwarf spectra 

70 that begin with 'm' 

71 """ 

72 self.verifyFile('m5.1Full.dat', 'starSED/old_mlt') 

73 

74 def test_l4_spec(self): 

75 """ 

76 Test that defaultSpecMap correctly finds l4Full.dat 

77 """ 

78 self.verifyFile('l4Full.dat', 'starSED/old_mlt') 

79 

80 def test_L_spec(self): 

81 """ 

82 Test that defaultSpecMap correctly find the L#_# spectra 

83 """ 

84 self.verifyFile('L2_0Full.dat', 'starSED/old_mlt') 

85 

86 def test_burrows_spec(self): 

87 """ 

88 Test that defaultSpecMap correctly find the burrows spectra 

89 """ 

90 self.verifyFile('burrows+2006c91.21_T1400_g5.5_cf_0.3X', 'starSED/old_mlt') 

91 

92 def testBergeron(self): 

93 """ 

94 Test that defaultSpecMap correctly locates the bergeron spectra 

95 """ 

96 self.verifyFile('bergeron_4750_85.dat_4900', 'starSED/wDs') 

97 

98 def testKurucz(self): 

99 """ 

100 Test that defaultSpecMap correctly locates the kurucz spectra 

101 """ 

102 self.verifyFile('km30_5000.fits_g10_5040', 'starSED/kurucz') 

103 self.verifyFile('kp10_9000.fits_g40_9100', 'starSED/kurucz') 

104 

105 def testGalaxy(self): 

106 """ 

107 Test that defaultSpecMap correctly locates the galaxy SEDs 

108 """ 

109 self.verifyFile('Const.79E06.002Z.spec', 'galaxySED') 

110 self.verifyFile('Inst.79E06.02Z.spec', 'galaxySED') 

111 self.verifyFile('Exp.40E08.02Z.spec', 'galaxySED') 

112 self.verifyFile('Burst.40E08.002Z.spec', 'galaxySED') 

113 

114 

115class MemoryTestClass(lsst.utils.tests.MemoryTestCase): 

116 pass 

117 

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

119 lsst.utils.tests.init() 

120 unittest.main()