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

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

from builtins import range 

import unittest 

import numpy as np 

 

import lsst.utils.tests 

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

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

class ImSimNormTestCase(unittest.TestCase): 

 

def test_norm(self): 

""" 

Test that the special test case getImsimFluxNorm 

returns the same value as calling calcFluxNorm actually 

passing in the imsim Bandpass 

""" 

 

bp = Bandpass() 

bp.imsimBandpass() 

 

rng = np.random.RandomState(1123) 

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

 

for ix in range(10): 

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

sed = Sed() 

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

magmatch = rng.random_sample()*5.0 + 10.0 

 

control = sed.calcFluxNorm(magmatch, bp) 

test = getImsimFluxNorm(sed, magmatch) 

 

# something about how interpolation is done in Sed means 

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

# out equal to 8 seignificant digits, though. 

self.assertEqual(control, test) 

 

 

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

pass 

 

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

lsst.utils.tests.init() 

unittest.main()