def __init__(self, y, m, d, h, minutes, seconds): if y < 1980: raise Exception("Year #{y} must >= 1980") in_time = utc.utc_datetime(year=y, month=m, day=d, hour=h, minute=minutes, second=0) gps_t = utc.utc_datetime(year=1980, month=1, day=6, hour=0, minute=0, second=0) self.m_day_of_year = in_time.timetuple().tm_yday gps_sec = (in_time - gps_t).total_seconds() + seconds + self.utc_offset(in_time) gps_days = int(math.floor(gps_sec / GpsTime.SEC_PER_DAY)) gps_weeks = gps_days / 7.0 self.m_week = int(math.floor(gps_weeks)) self.sec_of_week = gps_sec - self.m_week * 7.0 * GpsTime.SEC_PER_DAY
def __init__(self, y, m, d, h, minutes, seconds): if (y < 1980): raise Exception("Year #{y} must >= 1980") in_time = utc.utc_datetime(year=y, month=m, day=d, hour=h, minute=minutes, second=0) gps_t = utc.utc_datetime(year=1980, month=1, day=6, hour=0, minute=0, second=0) self.m_day_of_year = in_time.timetuple().tm_yday gps_sec = ( in_time - gps_t ).total_seconds() + seconds + self.utc_offset(in_time) gps_days = int(math.floor(gps_sec / GpsTime.SEC_PER_DAY)) gps_weeks = gps_days / 7.0 self.m_week = int(math.floor(gps_weeks)) self.sec_of_week = gps_sec - self.m_week*7.0*GpsTime.SEC_PER_DAY
def test_gps(self): import ephem dnd = ephem.Observer() dnd.lon = str(location.Dunedin.lon.to_degrees()) dnd.lat = str(location.Dunedin.lat.to_degrees()) dnd.elevation = location.Dunedin.alt dnd.pressure = 0.0 t = utc.utc_datetime(2013,9,20,0,0,3) dnd.date = t for svnum in range(31,32): l1 = 'GPS BIIRM-2 (PRN 31) ' l2 = '1 29486U 06042A 13264.26023969 -.00000084 00000-0 00000+0 0 2292' l3 = '2 29486 56.1466 336.5502 0081195 316.5190 69.5394 2.00563866 51246' j = ephem.readtle(l1,l2,l3) # http://blog.thetelegraphic.com/2012/gps-sattelite-tracking-in-python-using-pyephem/ #j = ephem.Gps(svnum) j.compute(dnd) ra_e = angle.from_rad(j.ra.real) dec_e= angle.from_rad(j.dec.real) sv = GpsSatellite(svnum, location.Dunedin) ra, dec = sv.radec(t) print angle.wrap_360(ra.to_degrees()) self.assertAlmostEqual(ra.to_degrees(), ra_e.to_degrees(), 0) self.assertAlmostEqual(dec.to_degrees(), dec_e.to_degrees(), 0)
def setUp(self): self.utc_date = utc.utc_datetime(year=2009, month=7, day=22, hour=5, minute=9, second=50.3)
def test_gps(self): import ephem dnd = ephem.Observer() dnd.lon = str(location.Dunedin.lon.to_degrees()) dnd.lat = str(location.Dunedin.lat.to_degrees()) dnd.elevation = location.Dunedin.alt dnd.pressure = 0.0 t = utc.utc_datetime(2013, 9, 20, 0, 0, 3) dnd.date = t for svnum in range(31, 32): l1 = "GPS BIIRM-2 (PRN 31) " l2 = "1 29486U 06042A 13264.26023969 -.00000084 00000-0 00000+0 0 2292" l3 = "2 29486 56.1466 336.5502 0081195 316.5190 69.5394 2.00563866 51246" j = ephem.readtle(l1, l2, l3) # http://blog.thetelegraphic.com/2012/gps-sattelite-tracking-in-python-using-pyephem/ # j = ephem.Gps(svnum) j.compute(dnd) ra_e = angle.from_rad(j.ra.real) dec_e = angle.from_rad(j.dec.real) sv = GpsSatellite(svnum, location.Dunedin) ra, dec = sv.radec(t) print(angle.wrap_360(ra.to_degrees())) self.assertAlmostEqual(ra.to_degrees(), ra_e.to_degrees(), 0) self.assertAlmostEqual(dec.to_degrees(), dec_e.to_degrees(), 0)
def test_basic(self): utcd = utc_datetime(year=2009, month=7, day=22, hour=5, minute=9, second=50.3) apyt = time.Time('2009-07-22 05:09:50.3', format='iso', scale='utc') apyt2 = time.Time(utcd, scale='utc') utcd2 = apyt.to_datetime(UTC()) obstime = apyt2.to_datetime(UTC()) self.assertEqual(utcd2.year, utcd.year) self.assertEqual(utcd2.month, utcd.month) self.assertEqual(utcd2.day, utcd.day) self.assertEqual(utcd2.hour, utcd.hour) self.assertEqual(utcd2.minute, utcd.minute) self.assertEqual(utcd2.second, utcd.second) self.assertEqual((utcd - obstime).total_seconds(), 0.0)
def utc_offset(self, t): if t >= utc.utc_datetime(2017, 1, 1): return 18 if t >= utc.utc_datetime(2015, 7, 1): return 17 if t >= utc.utc_datetime(2012, 7, 1): return 16 if t >= utc.utc_datetime(2009, 1, 1): return 15 if t >= utc.utc_datetime(2006, 1, 1): return 14 if t >= utc.utc_datetime(1999, 1, 1): return 13 if t >= utc.utc_datetime(1997, 7, 1): return 12 if t >= utc.utc_datetime(1996, 1, 1): return 11 if t >= utc.utc_datetime(1994, 7, 1): return 10 if t >= utc.utc_datetime(1993, 7, 1): return 9 if t >= utc.utc_datetime(1992, 7, 1): return 8 if t >= utc.utc_datetime(1991, 1, 1): return 7 if t >= utc.utc_datetime(1990, 1, 1): return 6 if t >= utc.utc_datetime(1988, 1, 1): return 5 if t >= utc.utc_datetime(1985, 7, 1): return 4 if t >= utc.utc_datetime(1983, 7, 1): return 3 if t >= utc.utc_datetime(1982, 7, 1): return 2 if t >= utc.utc_datetime(1981, 7, 1): return 1 if t >= utc.utc_datetime(1980, 1, 1): return 0 return False
def setUp(self): self.ep = EphemeridesProxy.Instance() self.s = self.ep.server self.t = utc.utc_datetime(2002, 10, 31, 0, 2, 2) self.eph_hash = self.s.get_ephemeris(self.t.isoformat(), 1)
def utc_offset(self, t): if (t >= utc.utc_datetime(2012, 7, 1)): return 16 if (t >= utc.utc_datetime(2009, 1, 1)): return 15 if (t >= utc.utc_datetime(2006, 1, 1)): return 14 if (t >= utc.utc_datetime(1999, 1, 1)): return 13 if (t >= utc.utc_datetime(1997, 7, 1)): return 12 if (t >= utc.utc_datetime(1996, 1, 1)): return 11 if (t >= utc.utc_datetime(1994, 7, 1)): return 10 if (t >= utc.utc_datetime(1993, 7, 1)): return 9 if (t >= utc.utc_datetime(1992, 7, 1)): return 8 if (t >= utc.utc_datetime(1991, 1, 1)): return 7 if (t >= utc.utc_datetime(1990, 1, 1)): return 6 if (t >= utc.utc_datetime(1988, 1, 1)): return 5 if (t >= utc.utc_datetime(1985, 7, 1)): return 4 if (t >= utc.utc_datetime(1983, 7, 1)): return 3 if (t >= utc.utc_datetime(1982, 7, 1)): return 2 if (t >= utc.utc_datetime(1981, 7, 1)): return 1 if (t >= utc.utc_datetime(1980, 1, 1)): return 0 return False
def test_radec(self): sv = GpsSatellite(31, location.Dunedin) t = utc.utc_datetime(2013,9,20,0,0,3) ra, dec = sv.radec(t) self.assertLess(ra.to_degrees(), 360.0) self.assertLess(abs(dec.to_degrees()), 90.0)
def setUp(self): self.t = utc.utc_datetime(2002, 10, 31, 0, 2, 2) self.s = Sun()
def test_power(self): sv = GpsSatellite(31, location.Dunedin) t = utc.utc_datetime(2013,9,20,0,0,3) self.assertLess(sv.jansky(t), 5.0e6) self.assertGreater(sv.jansky(t), 3.0e6)
def test_power(self): sv = GpsSatellite(31, location.Dunedin) t = utc.utc_datetime(2013, 9, 20, 0, 0, 3) self.assertLess(sv.jansky(t), 5.0e6) self.assertGreater(sv.jansky(t), 3.0e6)
print(r.url) print(r.text) t = datetime.datetime.utcnow() # utc.utc_datetime(2002, 10, 31, 2, 2, 2) #for i in range(0,100): #t = t - datetime.timedelta(seconds=100.0) #payload = {'date': t, 'sv':1} #r = requests.get('{}/position'.format(server), params=payload) #print r.text #payload = {'date': t.isoformat(), 'sv':1, 'lat':-45.86, 'lon':170.54} #r = requests.get('{}/catalog'.format(server), params=payload) #print r.url #print r.text ep = EphemeridesProxy.Instance() t = utc.utc_datetime(2013, 9, 21, 0, 59, 3) sv = 21 for i in range(0,100): t = t + datetime.timedelta(seconds=1.0) pos = ep.get_sv_position(t, sv) pos_remote = ep.get_remote_position(t, sv) diff = np.array(pos) - np.array(pos_remote) dr = np.sqrt(diff.dot(diff)) print(t, dr)
def setUp(self): self.s = jsonrpclib.Server('http://astro.elec.ac.nz:8876/rpc/gps') self.t = utc.utc_datetime(2002, 10, 31, 0, 2, 2) self.eph_hash = self.s.get_ephemeris(self.t.isoformat(), 1)
def test_radec(self): sv = GpsSatellite(31, location.Dunedin) t = utc.utc_datetime(2013, 9, 20, 0, 0, 3) ra, dec = sv.radec(t) self.assertLess(ra.to_degrees(), 360.0) self.assertLess(abs(dec.to_degrees()), 90.0)