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

1from builtins import range 

2import unittest 

3import numpy as np 

4 

5import lsst.utils.tests 

6from lsst.sims.photUtils import Sed, Bandpass, getImsimFluxNorm 

7 

8 

9def setup_module(module): 

10 lsst.utils.tests.init() 

11 

12 

13class ImSimNormTestCase(unittest.TestCase): 

14 

15 def test_norm(self): 

16 """ 

17 Test that the special test case getImsimFluxNorm 

18 returns the same value as calling calcFluxNorm actually 

19 passing in the imsim Bandpass 

20 """ 

21 

22 bp = Bandpass() 

23 bp.imsimBandpass() 

24 

25 rng = np.random.RandomState(1123) 

26 wavelen = np.arange(300.0, 2000.0, 0.17) 

27 

28 for ix in range(10): 

29 flux = rng.random_sample(len(wavelen))*100.0 

30 sed = Sed() 

31 sed.setSED(wavelen=wavelen, flambda=flux) 

32 magmatch = rng.random_sample()*5.0 + 10.0 

33 

34 control = sed.calcFluxNorm(magmatch, bp) 

35 test = getImsimFluxNorm(sed, magmatch) 

36 

37 # something about how interpolation is done in Sed means 

38 # that the values don't come out exactly equal. They come 

39 # out equal to 8 seignificant digits, though. 

40 self.assertEqual(control, test) 

41 

42 

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

44 pass 

45 

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

47 lsst.utils.tests.init() 

48 unittest.main()