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

import matplotlib 

matplotlib.use("Agg") 

import unittest 

import lsst.sims.maf.utils.opsimUtils as opsimUtils 

import lsst.utils.tests 

 

 

class TestOpsimUtils(unittest.TestCase): 

 

def testScaleBenchmarks(self): 

"""Test scaling the design and stretch benchmarks for the length of the run.""" 

# First test that method returns expected dictionaries. 

for i in ('design', 'stretch'): 

benchmark = opsimUtils.scaleBenchmarks(10.0, i) 

self.assertIsInstance(benchmark, dict) 

expectedkeys = ('Area', 'nvisitsTotal', 'nvisits', 'seeing', 'skybrightness', 

'singleVisitDepth') 

expectedfilters = ('u', 'g', 'r', 'i', 'z', 'y') 

for k in expectedkeys: 

self.assertIn(k, benchmark) 

expecteddictkeys = ('nvisits', 'seeing', 'skybrightness', 'singleVisitDepth') 

for k in expecteddictkeys: 

for f in expectedfilters: 

self.assertIn(f, benchmark[k]) 

 

def testCalcCoaddedDepth(self): 

"""Test the expected coadded depth calculation.""" 

benchmark = opsimUtils.scaleBenchmarks(10, 'design') 

coadd = opsimUtils.calcCoaddedDepth(benchmark['nvisits'], benchmark['singleVisitDepth']) 

for f in coadd: 

self.assertLess(coadd[f], 1000) 

singlevisits = {'u': 1, 'g': 1, 'r': 1, 'i': 1, 'z': 1, 'y': 1} 

coadd = opsimUtils.calcCoaddedDepth(singlevisits, benchmark['singleVisitDepth']) 

for f in coadd: 

self.assertAlmostEqual(coadd[f], benchmark['singleVisitDepth'][f]) 

 

 

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

pass 

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

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()