def listTrips(): """ Given latitude data segment the data into trips """ path = Journey.Path.fromJson(request.json) segtrips = Journey.segmentTrips(path) segtrips = filter(lambda t: t.distance() > .1, segtrips) return {"trips":[t.toJson() for t in segtrips]}
def listTrips(): """ Given latitude data segment the data into trips """ path = Journey.Path.fromJson(request.json) segtrips = Journey.segmentTrips(path) segtrips = filter(lambda t: t.distance() > .1, segtrips) return {"trips": [t.toJson() for t in segtrips]}
def parse_mission_file(self, input_file_name): #Step 1: open the file if os.path.isfile(input_file_name): inputfile = open(input_file_name, "r") self.success = 1 else: dlg = wx.MessageDialog(self, "Unable to open" + input_file_name, "EMTG Error", wx.ID_OK) dlg.ShowModal() dlg.Destroy() self.success = 0 return #Step 2: parse the file self.ActiveJourney = -1 self.Journeys = [] linenumber = 0 for line in inputfile: linenumber += 1 #split the line by colons linecell = line.split(':') if linecell[0] == "Mission": self.mission_name = linecell[1].strip('\n') elif linecell[0] == "Decision Vector": DecisionCell = linecell[1].split(' ') DecisionCell.remove('') self.DecisionVector = [] for entry in DecisionCell: self.DecisionVector.append(float(entry)) elif linecell[0] == "Journey": self.ActiveJourney = int(linecell[1]) - 1 self.Journeys.append(Journey.Journey()) if self.ActiveJourney >= 0: if linecell[0] == "Journey name": self.Journeys[ self.ActiveJourney].journey_name = linecell[1].strip() elif linecell[0] == "Central Body": self.Journeys[ self.ActiveJourney].central_body = linecell[1].strip() elif linecell[0] == "Thruster duty cycle": self.Journeys[ self.ActiveJourney].thruster_duty_cycle = eval( linecell[1]) elif linecell[0] == "Radius (km)": self.Journeys[ self.ActiveJourney].central_body_radius = eval( linecell[1]) elif linecell[0] == "mu (km^2/s^3)": self.Journeys[self.ActiveJourney].mu = eval(linecell[1]) elif linecell[0] == "Characteristic length unit (km)": self.Journeys[self.ActiveJourney].LU = eval(linecell[1]) self.Journeys[self.ActiveJourney].TU = math.sqrt( self.Journeys[self.ActiveJourney].LU**3 / self.Journeys[self.ActiveJourney].mu) elif linecell[0] == "Boundary": boundary_elements = linecell[1].split(' ') boundary_state = [ float(boundary_elements[2]), float(boundary_elements[3]), float(boundary_elements[4]), float(boundary_elements[5]), float(boundary_elements[6]), float(boundary_elements[7]) ] self.Journeys[self.ActiveJourney].boundary_states.append( boundary_state) elif linecell[0] == "Flyby": flyby_elements = linecell[1].split(' ') flyby_state = [ float(flyby_elements[3]), float(flyby_elements[4]), float(flyby_elements[5]), float(flyby_elements[6]), float(flyby_elements[7]), float(flyby_elements[8]) ] self.Journeys[ self.ActiveJourney].flyby_periapse_states.append( flyby_state) elif linecell[0] == "End journey\n": self.ActiveJourney = -1 else: #parse event lines inputcell = line.split('|') if inputcell[0].strip(' ').isdigit(): tempEvent = MissionEvent.MissionEvent(inputcell) self.Journeys[self.ActiveJourney].missionevents.append( tempEvent) del tempEvent del inputcell elif linecell[0] == "Total deltaV": self.total_deltaV = float(linecell[1]) elif linecell[0] == "Spacecraft dry mass": self.spacecraft_dry_mass = float(linecell[1]) elif linecell[0] == "Total propellant mass including margin": self.total_propellant_mass_including_margin = float( linecell[1]) elif linecell[0] == "Flight time (y)": self.total_flight_time_years = float(linecell[1]) inputfile.close()