Beispiel #1
0
    def test_lstInRange(self):

        # ra to lst: rads to hours
        lst = TimeAgent.rad2hr(self.sesshun.target.horizontal)

        # create the window range
        utcStart = datetime(2009, 6, 1)
        utcEnd   = datetime(2009, 6, 2)
        wr = WindowRange(window = self.w
                       , start_date = utcStart
                       , duration = (utcEnd - utcStart).days)
        wr.save()

        # any target should be in range, w/ out a buffer
        inRange = wr.lstInRange(lst)
        self.assertEquals(True, inRange)

        # but with a big enough buffer, no target can be in range
        buffer = 12.0
        inRange = wr.lstInRange(lst, buffer = buffer)
        self.assertEquals(False, inRange)
        
        # make the buffer reasonable enough, and it passes again
        buffer = 4.5
        inRange = wr.lstInRange(lst, buffer = buffer)
        self.assertEquals(True, inRange)
Beispiel #2
0
    def lstOutOfRange(self):
        """
        Are any of the window ranges just one day, with the
        LST such that the session can't be scheduled?
        """
        lst = TimeAgent.rad2hr(self.session.target.horizontal)

        # how close can the lst be to the edges of the range?
        buffer = (self.session.min_duration + self.session.max_duration) / 2.0

        return [wr for wr in self.windowrange_set.all() \
            if wr.duration == 1 and \
                not wr.lstInRange(lst, buffer = buffer)]
Beispiel #3
0
    def test_lstOutOfRange(self):

        # ra to lst: rads to hours
        lst = TimeAgent.rad2hr(self.sesshun.target.horizontal)

        # this first window should not have a problem, since
        # duration > 1 day
        self.assertEquals(False, self.w.hasLstOutOfRange())
        self.assertEquals(False, self.w.hasNoLstInRange())

        # now create a one day window range
        utcStart = datetime(2009, 6, 1)
        utcEnd   = datetime(2009, 6, 2)
        wr = WindowRange(window = self.w
                       , start_date = utcStart
                       , duration = (utcEnd - utcStart).days)
        wr.save()

        # any target should be in range, w/ out a big buffer
        self.assertEquals(False, self.w.hasLstOutOfRange())
        self.assertEquals(False, self.w.hasNoLstInRange())

        # now, increase the buffer:
        self.sesshun.min_duration = 12.0
        self.sesshunmax_duration  = 12.0
        self.sesshun.save()
        self.assertEquals(True, self.w.hasLstOutOfRange())
        self.assertEquals([wr], self.w.lstOutOfRange())
        self.assertEquals(False, self.w.hasNoLstInRange())

        # now, shrink the original window range so that it 
        # is too small as well
        self.wr1.duration = 1
        self.wr1.save()
        self.assertEquals(True, self.w.hasLstOutOfRange())
        self.assertEquals(True, self.w.hasNoLstInRange())