-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtestSedUtils.py
48 lines (34 loc) · 1.29 KB
/
testSedUtils.py
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
if __name__ == "__main__":
lsst.utils.tests.init()
unittest.main()