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

49

50

51

52

53

54

55

56

57

58

59

60

import unittest 

from astropy.time import Time, TimeDelta 

import lsst.utils.tests 

 

from lsst.sims.downtimeModel import UnscheduledDowntimeData 

 

 

class UnscheduledDowntimeDataTest(unittest.TestCase): 

 

def setUp(self): 

self.th = Time('2020-01-01', format='isot', scale='tai') 

self.startofnight = -0.34 

self.seed = 1516231120 

self.survey_length = 3650*2 

 

def test_basic_information_after_creation(self): 

downtimeData = UnscheduledDowntimeData(self.th, start_of_night_offset=self.startofnight, 

survey_length=self.survey_length, seed=self.seed) 

self.assertEqual(downtimeData.seed, self.seed) 

self.assertEqual(downtimeData.survey_length, self.survey_length) 

self.assertEqual(self.th + TimeDelta(self.startofnight, format='jd'), downtimeData.night0) 

downtimeData = UnscheduledDowntimeData(self.th, start_of_night_offset=0, 

survey_length=self.survey_length, seed=self.seed) 

self.assertEqual(downtimeData.night0, self.th) 

 

def test_information_after_initialization(self): 

downtimeData = UnscheduledDowntimeData(self.th, start_of_night_offset=self.startofnight, 

survey_length=self.survey_length, seed=self.seed) 

downtimeData.make_data() 

self.assertEqual(len(downtimeData.downtime), 155) 

# Check some of the downtime values. 

dnight = downtimeData.downtime['end'] - downtimeData.downtime['start'] 

self.assertEqual(dnight[0].jd, 1) 

self.assertEqual(downtimeData.downtime['activity'][0], 'minor event') 

self.assertEqual(dnight[2].jd, 7) 

self.assertEqual(downtimeData.downtime['activity'][2], 'major event') 

 

def test_alternate_seed(self): 

downtimeData = UnscheduledDowntimeData(self.th, start_of_night_offset=self.startofnight, 

survey_length=self.survey_length, seed=3) 

downtimeData.make_data() 

self.assertEqual(len(downtimeData.downtime), 145) 

 

def test_call(self): 

downtimeData = UnscheduledDowntimeData(self.th, start_of_night_offset=self.startofnight, 

survey_length=self.survey_length, seed=self.seed) 

downtimeData.make_data() 

downtimes = downtimeData() 

self.assertEqual(downtimes['activity'][2], 'major event') 

 

 

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

pass 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

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

lsst.utils.tests.init() 

unittest.main()