summaryrefslogtreecommitdiff
path: root/tools/mmd/MmdSatellite.py
diff options
context:
space:
mode:
authorJogi Hofmüller <jogi@mur.at>2011-08-11 12:31:16 +0000
committerJogi Hofmüller <jogi@mur.at>2011-08-11 12:31:16 +0000
commitabcb8f300a44b67e2c75330627b690944ed769cf (patch)
treedb80179ea87e63072e7e62f5ed2c45ff59d95aa3 /tools/mmd/MmdSatellite.py
parent- fixed Bug in call to getTrajectoryAsJavaArray in osmWidget () (diff)
- fixed Bug in call to getTrajectoryAsJavaArray in osmWidget ()
- included real satellite data in dataWidget () - added comment to map git-svn-id: https://svn.spreadspace.org/mur.sat@123 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'tools/mmd/MmdSatellite.py')
-rw-r--r--tools/mmd/MmdSatellite.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tools/mmd/MmdSatellite.py b/tools/mmd/MmdSatellite.py
index 67a9052..a148f30 100644
--- a/tools/mmd/MmdSatellite.py
+++ b/tools/mmd/MmdSatellite.py
@@ -4,6 +4,7 @@ import ephem
import time
import os
from MmdDb import Db
+from MmdLocation import Location
def createJavaArray (point_list, name):
astring = '''var {0} = new Array (\n'''.format (name)
@@ -41,10 +42,11 @@ def dms2degdec (lonlat):
class Satellite:
- def __init__ (self):
+ def __init__ (self, location = False):
self.name = 'RADIOSCAF-B/ARISSAT-1'
self.tle_filename = '/usr/local/mmd/tles/current'
self.db = Db ()
+ self.initSatellite (location)
def getCurrentSSP (self):
ssp = self._loadCurrentSSP ()
@@ -77,6 +79,22 @@ class Satellite:
def _loadCurrentSSP (self):
return self.db.satelliteLoadCurrentSSP (time.strftime ('%s'))
+ def initSatellite (self, location = False):
+ if not self._loadTLE ():
+ return False
+ if location:
+ loc = location
+ else:
+ loc = Location ()
+
+ sat = ephem.readtle (self._tle[0], self._tle[1], self._tle[2])
+ obs = ephem.Observer ()
+ obs.long, obs.lat, obs.elevation = loc.longitude, loc.latitude, loc.altitude
+ sat.compute (obs)
+ self.longitude = dms2degdec (sat.sublong.__str__ ())
+ self.latitude = dms2degdec (sat.sublat.__str__ ())
+ self.altitude = round (float (sat.elevation.__str__ ()), 1)
+
def computeTrajectory (self):
'''
computes 5 hours of future trajectory data, starting at the
@@ -129,6 +147,7 @@ if __name__ == "__main__":
t, lon, lat = satellite.getCurrentSSP ()
assert t, 'loading current SSP failed'
print lon, lat, time.strftime ('%c', time.gmtime (t))
+ print satellite.longitude, satellite.latitude, satellite.altitude
except AssertionError as e:
print 'Error: {0}'.format (e)