def calcLSTrange(self): """ Returns the minimum and maximum LST from the position and the minimum elevation (in radians). """ if self.ra is None or self.dec 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 rise, set = h.riseSetLSTs(rad2deg(self.ra) , rad2deg(self.dec)) # unless this is a special case! if set is None: # our source never sets - it's always up! return (0.0, hr2rad(24.0)) if rise is None: # our source never rises return (0.0, 0.0) minLst = hr2rad(h.normalizeHours(rise)) maxLst = hr2rad(h.normalizeHours(set)) return (minLst, maxLst)
def test_getRiseSet(self): now = DateTime.DateTime(2006, 5, 31, 18, 6, 4) # default elevation limit h = Horizon() rise, set = h.riseSetLSTs(20.0, 20.0, now) self.assertEqual('18:41:12.03', str(rise)) self.assertEqual('07:58:47.97', str(set)) # raise the el. limit and watch things rise later # and set earlier h = Horizon(20.0) rise, set = h.riseSetLSTs(20.0, 20.0, now) self.assertEqual('20:00:15.72', str(rise)) self.assertEqual('06:39:44.28', str(set)) # a lower dec should mean less time up h = Horizon(20.0) rise, set = h.riseSetLSTs(20.0, 0.0, now) self.assertEqual('21:03:18.21', str(rise)) self.assertEqual('05:36:41.79', str(set)) # demonstrates that we need to normalize results h = Horizon() ra = rad2deg(hr2rad(22.0)) rise, set = h.riseSetLSTs(ra, 10.0, now) self.assertEqual('15:54:14.83', str(rise)) # watch for > 24 hours self.assertEqual('1:04:05:45.17', str(set)) self.assertAlmostEqual(28.0958, set.hours, 2) self.assertAlmostEquals(4.09588185187, h.normalizeHours(set), 3) # source that is always up rise, set = h.riseSetLSTs(ra, 80.0, now) self.assertTrue(set is None) # source that is never up rise, set = h.riseSetLSTs(ra, -80.0, now) self.assertTrue(rise is None) # but a source that is always up may not survive the el limit h = Horizon(30) elLimHr = rad2hr(deg2rad(30)) rise, set = h.riseSetLSTs(ra, 80.0, now) self.assertTrue(set is not None)