Esempio n. 1
0
    def test_riseSet2centerWidth(self):

        h = Horizon()

        rise = DateTime.DateTimeDelta(0, 12, 0, 0)
        set  = DateTime.DateTimeDelta(0, 18, 0, 0)

        center, width = h.riseSet2centerWidth(rise, set)
        self.assertEqual(15.0, center.hours)
        self.assertEqual(6.0, width.hours)

        # make sure wrap around works
        rise = DateTime.DateTimeDelta(0, 22, 0, 0)
        set  = DateTime.DateTimeDelta(0,  4, 0, 0)

        center, width = h.riseSet2centerWidth(rise, set)
        self.assertEqual(1.0, center.hours)
        self.assertEqual(6.0, width.hours)

        rise = DateTime.DateTimeDelta(0, 18, 0, 0)
        set  = DateTime.DateTimeDelta(0, 12, 0, 0)

        center, width = h.riseSet2centerWidth(rise, set)
        self.assertEqual(18.0, width.hours)
        self.assertEqual(3.0, center.hours)

        # 0 - 24 is a popular range
        rise = DateTime.DateTimeDelta(0, 0, 0, 0)
        set  = DateTime.DateTimeDelta(0, 24, 0, 0)

        center, width = h.riseSet2centerWidth(rise, set)
        self.assertEqual(24.0, width.hours)
        self.assertEqual(12.0, center.hours)
Esempio n. 2
0
    def calcCenterWidthLST(self, minLst = None, maxLst = None):
        """
        Returns the center LST and LST width based off the min &
        max LST's (all in radians).
        """

        if minLst is None:
            minLst = self.min_lst
        if maxLst is None:
            maxLst = self.max_lst
        if minLst is None or maxLst is None:    
            return (None, None)

        # our utility tool - it takes everything in degrees
        if self.elevation_min is not None:
            h = Horizon(rad2deg(self.elevation_min))
        else:
            h = Horizon()

        
        # and the tool returns DateTimeDelta's
        minLst = DateTime.DateTimeDelta(0, rad2hr(minLst), 0, 0)
        maxLst = DateTime.DateTimeDelta(0, rad2hr(maxLst), 0, 0)
        center, width = h.riseSet2centerWidth(minLst, maxLst)

        return (hr2rad(center.hours), hr2rad(width.hours))