예제 #1
0
 def writetrack(self,track,latitude=0,longitude=0,altitude=0,append=True,coordlist=[],log=True):
     """Append a track  or display a coordinate list in Google Earth"""
     #Track is a string key for the self.tracks dictionary (i.e. "balloon")
     track = track.lower()
     #Check to see if the track is currently being plotted (checkboxes on GUI)
     if self.tracks[track]["active"]==True:
         #Determine where the kml files are stored from the dict
         filepath = self.tracks[track]["file"]
         #Default for the function unless the user specifically indicates otherwise
         if append:
             #User must also specify the current long, lat, or altitude, default (0,0,0)
             position = (longitude, latitude, altitude)                
             #Log the new coordinate to file if currently saving logs
             if log==True:
                 logfile = self.tracks[track]["log"]
                 self.writelog([position],logfile)
             #Use writetoKML to append the position into the Google Earth KML
             writetoKML.writeonce(position,filepath)
         #If Append is false, and the user has defined a coordinate list
         else:
             #Log the list to file if currently saving logs
             if log==True:
                 logfile = self.tracks[track]["log"]
                 savetime = datetime.datetime.now().date()
                 #Rename the old log before overwriting
                 if self.renamelog(logfile,savetime):
                     self.writelog(coordlist,logfile)
             #Completely rewrite the coordinate list with the current data
             writetoKML.rewrite(coordlist,filepath)
예제 #2
0
 def writetrack(self,track,latitude=0,longitude=0,altitude=0,append=True,coordlist=None):
     if self.tracks[track]["active"]==True:
         filepath = self.tracks[track]["file"]
         if append:                
             position = (longitude, latitude, altitude)                
             writetoKML.writeonce(position,filepath)
         else:
             writetoKML.rewrite(coordlist,filepath)
예제 #3
0
def main(launchtime=None,
         launchsite=(40.191903, -110.38099, 5826),
         ascentrate=1045,
         descentrate=1763,
         burstaltitude=98000,
         wxstation=None,
         source="GFS",
         messages=False,
         direction="up",
         writefile="Tracks\Prediction.kml",
         timeout=20):
    """Self-running predictor"""
    if launchtime == None:
        #If no launchtime is set, assume an immediate launch
        launchtime = datetime.datetime.now()
    if wxstation == None:
        #If no WxStation is set, find the closest
        wxstation = getClosestStation(launchsite)
        wxstation = wxstation[0]
        if messages: print "WxStation: %s" % wxstation
    if messages: print "Retrieving Data..."
    data = getData(launchtime, wxstation, source, timeout=timeout)
    if messages: print "\t...Done"
    if messages: print "Parsing Data"
    if data == "" or data == None:
        print "No Data, Loading from File...\n*** Warning, this data may be out of date ***"
        data = getDataFromFile()
    else:
        saveDataToFile(data=data)
    atmosphere = parse_wind(data)
    if messages: print "Simulating Balloon Flight"
    track = makeTrack(atmosphere,
                      launchsite,
                      ascentrate,
                      descentrate,
                      burstaltitude,
                      direction=direction)
    if messages: print "\t...Done"
    else: return track
    landing, bearing = findLanding(track, launchsite)
    #for point in track:
    #print "%s\t%s" % (point[0],point[1])
    #print "%s,%s,%s" % (point[1],point[0],point[2]) #Google Earth
    #print "{%s,%s}," % (point[0],point[1]) #Mathematica
    if messages:
        print "Balloon landed at Latitude: %s, Longitude: %s" % (landing[0],
                                                                 landing[1])
    if messages:
        print "\tand %s miles from start at %s degrees East of North" % (
            bearing[0], bearing[1])
    earthtrack = []
    for point in track:
        #Convert the track to google-earth coordinates
        earthtrack.append((point[1], point[0], point[2]))
    if messages:
        import writetoKML
        writetoKML.rewrite(earthtrack, writefile)
    if messages: print "Written to file"
예제 #4
0
 def writetrack(self,
                track,
                latitude=0,
                longitude=0,
                altitude=0,
                append=True,
                coordlist=None):
     if self.tracks[track]["active"] == True:
         filepath = self.tracks[track]["file"]
         if append:
             position = (longitude, latitude, altitude)
             writetoKML.writeonce(position, filepath)
         else:
             writetoKML.rewrite(coordlist, filepath)
예제 #5
0
def main(launchtime=None, launchsite=(40.191903, -110.38099, 5826), ascentrate=1045, descentrate=1763,
         burstaltitude=98000,
         wxstation=None, source="GFS", messages=False, direction="up", writefile="Tracks\Prediction.kml", timeout=20):
    """Self-running predictor"""
    if launchtime == None:
        # If no launchtime is set, assume an immediate launch
        launchtime = datetime.datetime.now()
    if wxstation == None:
        # If no WxStation is set, find the closest
        wxstation = getClosestStation(launchsite)
        wxstation = wxstation[0]
        if messages: print "WxStation: %s" % wxstation
    if messages: print "Retrieving Data..."
    data = getData(launchtime, wxstation, source, timeout=timeout)
    if messages: print "\t...Done"
    if messages: print "Parsing Data"
    if data == "" or data == None:
        print "No Data, Loading from File...\n*** Warning, this data may be out of date ***"
        data = getDataFromFile()
    else:
        saveDataToFile(data=data)
    atmosphere = parse_wind(data)
    if messages: print "Simulating Balloon Flight"
    track = makeTrack(atmosphere, launchsite, ascentrate, descentrate, burstaltitude, direction=direction)
    if messages:
        print "\t...Done"
    else:
        return track
    landing, bearing = findLanding(track, launchsite)
    # for point in track:
    # print "%s\t%s" % (point[0],point[1])
    # print "%s,%s,%s" % (point[1],point[0],point[2]) #Google Earth
    # print "{%s,%s}," % (point[0],point[1]) #Mathematica
    if messages: print "Balloon landed at Latitude: %s, Longitude: %s" % (landing[0], landing[1])
    if messages: print "\tand %s miles from start at %s degrees East of North" % (bearing[0], bearing[1])
    earthtrack = []
    for point in track:
        # Convert the track to google-earth coordinates
        earthtrack.append((point[1], point[0], point[2]))
    if messages:
        import writetoKML
        writetoKML.rewrite(earthtrack, writefile)
    if messages: print "Written to file"
예제 #6
0
 def writetrack(self,
                track,
                latitude=0,
                longitude=0,
                altitude=0,
                append=True,
                coordlist=[],
                log=True):
     """Append a track  or display a coordinate list in Google Earth"""
     #Track is a string key for the self.tracks dictionary (i.e. "balloon")
     track = track.lower()
     #Check to see if the track is currently being plotted (checkboxes on GUI)
     if self.tracks[track]["active"] == True:
         #Determine where the kml files are stored from the dict
         filepath = self.tracks[track]["file"]
         #Default for the function unless the user specifically indicates otherwise
         if append:
             #User must also specify the current long, lat, or altitude, default (0,0,0)
             position = (longitude, latitude, altitude)
             #Log the new coordinate to file if currently saving logs
             if log == True:
                 logfile = self.tracks[track]["log"]
                 self.writelog([position], logfile)
             #Use writetoKML to append the position into the Google Earth KML
             writetoKML.writeonce(position, filepath)
         #If Append is false, and the user has defined a coordinate list
         else:
             #Log the list to file if currently saving logs
             if log == True:
                 logfile = self.tracks[track]["log"]
                 savetime = datetime.datetime.now().date()
                 #Rename the old log before overwriting
                 if self.renamelog(logfile, savetime):
                     self.writelog(coordlist, logfile)
             #Completely rewrite the coordinate list with the current data
             writetoKML.rewrite(coordlist, filepath)
예제 #7
0
from __future__ import division
import writetoKML


NW = (40.187158,-109.681162)
SE = (39.821682,-109.280980)
NE = (NW[0],SE[1])
SW = (SE[0],NW[1])

difference = (NW[0]-SE[0],NW[1]-SE[1])

stops = 100

writetoKML.rewrite([],"SavePath.kml")

coords = []
for x in range(stops):
    for y in range(stops):
        if x%2==0:
            newpoint = (SE[1]+((y/stops)*difference[1]),SE[0]+((x/stops)*difference[0]),0)
        else:
            newpoint = (SW[1]-((y/stops)*difference[1]),SE[0]+((x/stops)*difference[0]),0)
        #writetoKML.writeonce(newpoint,"SavePath.kml")
        coords.append(newpoint)
    print "Saved Row %s" % x
print "Writing to file"
writetoKML.rewrite(coords,"SavePath.kml")
print "Done"
예제 #8
0
from __future__ import division
import writetoKML

NW = (40.187158, -109.681162)
SE = (39.821682, -109.280980)
NE = (NW[0], SE[1])
SW = (SE[0], NW[1])

difference = (NW[0] - SE[0], NW[1] - SE[1])

stops = 100

writetoKML.rewrite([], "SavePath.kml")

coords = []
for x in range(stops):
    for y in range(stops):
        if x % 2 == 0:
            newpoint = (SE[1] + ((y / stops) * difference[1]),
                        SE[0] + ((x / stops) * difference[0]), 0)
        else:
            newpoint = (SW[1] - ((y / stops) * difference[1]),
                        SE[0] + ((x / stops) * difference[0]), 0)
        #writetoKML.writeonce(newpoint,"SavePath.kml")
        coords.append(newpoint)
    print "Saved Row %s" % x
print "Writing to file"
writetoKML.rewrite(coords, "SavePath.kml")
print "Done"