def test_main_five(self): airportsDb = AirportsDatabase() assert (airportsDb.read()) print ' ============== g3 performance ===============' t0 = time.clock() g3 = Graph() index = 0 for airport in airportsDb.getAirports(): print airport g3.addVertex(airport) index += 1 t1 = time.clock() print 'number of airports= {0} - duration= {1} seconds'.format( index, t1 - t0) airport = airportsDb.getAirportFromICAOCode('LFPG') t2 = time.clock() g4 = Graph() for i in range(0, 10000): g4.addVertex(airport) t3 = time.clock() print 'number of addVertex = {0} - duration= {1:.8f} seconds'.format( i, t3 - t2)
def test_create_Country_Airports_KML(self): print( '============ create country specific airports KML file =============' ) airportsDb = AirportsDatabase() self.assertTrue(airportsDb.read()) country = 'France' CountryList = [ 'France', 'Japan', 'United Kingdom', 'Germany', 'Spain', 'United States', 'Canada', 'Italy', 'Spain', 'United Kingdom' ] for country in CountryList: fileName = country + '_Airports.kml' kmlOutputFile = KmlOutput(fileName=fileName) for airport in airportsDb.getAirportsFromCountry(Country=country): airportName = str(airport.getName()) kmlOutputFile.write( name=airportName, LongitudeDegrees=airport.getLongitudeDegrees(), LatitudeDegrees=airport.getLatitudeDegrees(), AltitudeAboveSeaLevelMeters=airport. getAltitudeMeanSeaLevelMeters()) kmlOutputFile.close()
def test_class_one(self): print '==================== Main start ==================== ' + time.strftime( "%c") t0 = time.clock() print "time start= {0}".format(t0) atmosphere = Atmosphere() t1 = time.clock() print "simulation time= {0} - simulation duration= {1:3.10f} seconds".format( t1, (t1 - t0)) print '==================== load airports ==================== ' + time.strftime( "%c") airportsDB = AirportsDatabase() assert airportsDB.read() print '==================== air density at airports field elevation ==================== ' + time.strftime( "%c") for airport in airportsDB.getAirports(): print '=======================' + airport.getName( ) + '====================' print 'field elevation= ' + str( airport.getFieldElevationAboveSeaLevelMeters()) + ' meters' altitudeMeters = airport.getFieldElevationAboveSeaLevelMeters() print 'air density= ' + str( atmosphere.getAirDensityKilogramsPerCubicMeters( altitudeMeters)) + ' kg / meters ^^ 3'
def test_performance_graph_with_airport(self): airportsDb = AirportsDatabase() assert (airportsDb.read()) print(' ============== g3 performance ===============') t0 = time.process_time() g3 = Graph() count = 0 for airport in airportsDb.getAirports(): print(airport) g3.addVertex(airport) count += 1 t1 = time.process_time() print('number of airports= {0} - duration= {1} seconds'.format( count, t1 - t0)) self.assertEqual(g3.getNumberOfVertices(), count) g3.createXlsxOutputFile() g3.createKmlOutputFile() print(' ============== g4 performance ===============') airport = airportsDb.getAirportFromICAOCode('LFPG') t2 = time.process_time() g4 = Graph() for i in range(0, 10000): g4.addVertex(airport) t3 = time.process_time() print('number of addVertex = {0} - duration= {1:.8f} seconds'.format( i, t3 - t2))
def test_get_countries(self): print('============ test get countries =============') airportsDb = AirportsDatabase() self.assertTrue(airportsDb.read()) for country in airportsDb.getCountries(): print('test get country= ' + country)
def test_Vstall(self): t0 = time.clock() print("time start= ", t0) atmosphere = Atmosphere() earth = Earth() print( '==================== Stall Speed according to airport field elevation ==================== ' + time.strftime("%c")) acBd = BadaAircraftDatabase() aircraftICAOcode = 'B743' if acBd.read(): if (acBd.aircraftExists(aircraftICAOcode) and acBd.aircraftPerformanceFileExists( acBd.getAircraftPerformanceFile(aircraftICAOcode))): print( '==================== aircraft found ==================== ' + time.strftime("%c")) aircraft = BadaAircraft( ICAOcode=aircraftICAOcode, aircraftFullName=acBd.getAircraftFullName( aircraftICAOcode), badaPerformanceFilePath=acBd.getAircraftPerformanceFile( aircraftICAOcode), atmosphere=atmosphere, earth=earth) aircraft.dump() print('==================== Airport database ==================== ' + time.strftime("%c")) airportsDB = AirportsDatabase() assert airportsDB.read() for airport in airportsDB.getAirports(): print('============' + airport.getName() + ' ============') #print airport aircraft = BadaAircraft( ICAOcode=aircraftICAOcode, aircraftFullName=acBd.getAircraftFullName(aircraftICAOcode), badaPerformanceFilePath=acBd.getAircraftPerformanceFile( aircraftICAOcode), atmosphere=atmosphere, earth=earth) print('airport field elevation= {0:.2f} meters'.format( airport.getFieldElevationAboveSeaLevelMeters())) CAS = aircraft.computeStallSpeedCasKnots() print('V stall Calibrated AirSpeed= {0:.2f} knots'.format(CAS)) TAS = cas2tas( cas=CAS, altitude=airport.getFieldElevationAboveSeaLevelMeters(), temp='std', speed_units='kt', alt_units='m', temp_units=default_temp_units, ) print('V stall True AirSpeed= {0:.2f} knots'.format(TAS))
def test_main_five(self): print ( '==================== run-ways test five ====================' ) airportsDb = AirportsDatabase() self.assertTrue (airportsDb.read()) CharlesDeGaulleRoissy = airportsDb.getAirportFromICAOCode('LFPG') print ( CharlesDeGaulleRoissy ) runWaysDatabase = RunWayDataBase() self.assertTrue( runWaysDatabase.read() ) airportICAOcode = 'LFPG' runwayName = "08L" runway = runWaysDatabase.getFilteredRunWays(airportICAOcode = airportICAOcode, runwayName = runwayName) print ( runway ) fileName = airportICAOcode + "-" + runwayName kmlOutputFile = KmlOutput(fileName=fileName) kmlOutputFile.write(name = fileName, LongitudeDegrees = runway.getLongitudeDegrees(), LatitudeDegrees = runway.getLatitudeDegrees(), AltitudeAboveSeaLevelMeters = CharlesDeGaulleRoissy.getAltitudeMeanSeaLevelMeters()) latitudeDegrees , longitudeDegrees = runway.getGeoPointAtDistanceHeading(runway.getLengthMeters(), runway.getTrueHeadingDegrees()) name = airportICAOcode + "-" + runwayName + "-" + "Runway-End" kmlOutputFile.write(name = name, LongitudeDegrees = longitudeDegrees, LatitudeDegrees = latitudeDegrees, AltitudeAboveSeaLevelMeters = CharlesDeGaulleRoissy.getAltitudeMeanSeaLevelMeters()) ''' GreatCircleRoute: final way-point= turn-pt-189-229.70-degrees - latitude= 48.93 degrees - longitude= 2.75 degrees - altitudeMSL= 500.49 meters ''' routeLatitudeDegrees = 48.93 routeLongitudeDegrees = 2.75 routeGeographicalPoint = GeographicalPoint(routeLatitudeDegrees, routeLongitudeDegrees, CharlesDeGaulleRoissy.getAltitudeMeanSeaLevelMeters()) kmlOutputFile.write(name = "Route-Point", LongitudeDegrees = routeLongitudeDegrees, LatitudeDegrees = routeLatitudeDegrees, AltitudeAboveSeaLevelMeters = CharlesDeGaulleRoissy.getAltitudeMeanSeaLevelMeters()) shortestDistanceMeters = runway.computeShortestDistanceToRunway(routeGeographicalPoint) print ( "Shortest distance = {0} meters".format( shortestDistanceMeters ) ) kmlOutputFile.close()
def buildFixList(self): ''' from the route build a fix list and from the fix list build a way point list ''' self.wayPointsDict = {} wayPointsDb = WayPointsDatabase() assert (wayPointsDb.read()) airportsDb = AirportsDatabase() assert airportsDb.read() runwaysDb = RunWayDataBase() assert runwaysDb.read() self.createFixList() for fix in self.getFix(): wayPoint = wayPointsDb.getWayPoint(fix) if not (wayPoint is None) and isinstance(wayPoint, WayPoint): #print wayPoint self.wayPointsDict[fix] = wayPoint else: self.deleteFix(fix) self.arrivalRunway = runwaysDb.getFilteredRunWays( airportICAOcode=self.arrivalAirportICAOcode, runwayName=self.arrivalRunwayName) assert (not (self.arrivalRunway is None) and isinstance(self.arrivalRunway, RunWay)) self.arrivalAirport = airportsDb.getAirportFromICAOCode( ICAOcode=self.arrivalAirportICAOcode) assert (not (self.arrivalAirport is None) and isinstance(self.arrivalAirport, Airport)) self.departureRunway = runwaysDb.getFilteredRunWays( airportICAOcode=self.departureAirportICAOcode, runwayName=self.departureRunwayName) assert (not (self.departureRunway is None) and isinstance(self.departureRunway, RunWay)) self.departureAirport = airportsDb.getAirportFromICAOCode( ICAOcode=self.departureAirportICAOcode) assert (not (self.departureAirport is None) and isinstance(self.departureAirport, Airport)) #print self.className + ': fix list= ' + str(self.fixList) assert (self.allAnglesLessThan90degrees(minIntervalNautics=10.0))
def test_Vstall(self): t0 = time.clock() print "time start= ", t0 atmosphere = Atmosphere() earth = Earth() print '==================== Stall Speed according to airport field elevation ==================== '+ time.strftime("%c") acBd = BadaAircraftDatabase() aircraftICAOcode = 'B743' if acBd.read(): if ( acBd.aircraftExists(aircraftICAOcode) and acBd.aircraftPerformanceFileExists(acBd.getAircraftPerformanceFile(aircraftICAOcode))): print '==================== aircraft found ==================== '+ time.strftime("%c") aircraft = BadaAircraft(ICAOcode = aircraftICAOcode, aircraftFullName = acBd.getAircraftFullName(aircraftICAOcode), badaPerformanceFilePath = acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere = atmosphere, earth = earth) aircraft.dump() print '==================== Airport database ==================== '+ time.strftime("%c") airportsDB = AirportsDatabase() assert airportsDB.read() for airport in airportsDB.getAirports(): print '============' + airport.getName() + ' ============' #print airport aircraft = BadaAircraft(ICAOcode = aircraftICAOcode, aircraftFullName = acBd.getAircraftFullName(aircraftICAOcode), badaPerformanceFilePath = acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere = atmosphere, earth = earth) print 'airport field elevation= {0:.2f} meters'.format( airport.getFieldElevationAboveSeaLevelMeters()) CAS = aircraft.computeStallSpeedCasKnots() print 'V stall Calibrated AirSpeed= {0:.2f} knots'.format(CAS) TAS = cas2tas(cas = CAS , altitude = airport.getFieldElevationAboveSeaLevelMeters(), temp = 'std', speed_units = 'kt', alt_units = 'm', temp_units=default_temp_units, ) print 'V stall True AirSpeed= {0:.2f} knots'.format(TAS)
def test_main_four(self): print " ========== AirportsDatabase testing ======= time start= " airportsDb = AirportsDatabase() assert (airportsDb.read()) airportsDb.dumpCountry(Country="France") print "number of airports= ", airportsDb.getNumberOfAirports() for ap in ['Orly', 'paris', 'toulouse', 'marseille' , 'roissy', 'blagnac' , 'provence' , 'de gaulle']: print "ICAO Code of= ", ap, " ICAO code= ", airportsDb.getICAOCode(ap) t1 = time.clock() print " ========== AirportsDatabase testing ======= time start= ", t1 CharlesDeGaulleRoissy = airportsDb.getAirportFromICAOCode('LFPG') print CharlesDeGaulleRoissy MarseilleMarignane = airportsDb.getAirportFromICAOCode('LFML') print MarseilleMarignane g0 = Graph() for icao in [ 'LFPO', 'LFMY', 'LFAT', 'LFGJ']: airport = airportsDb.getAirportFromICAOCode(icao) g0.addVertex(airport) print '================ g0 =================' for node in g0.getVertices(): print node g1 = Graph() for icao in [ 'LFKC', 'LFBO' , 'LFKB']: airport = airportsDb.getAirportFromICAOCode(icao) g1.addVertex(airport) print '================ g1 =================' for node in g1.getVertices(): print node print ' ============== g0.add_graph(g1) ===============' g0.addGraph(g1) for node in g0.getVertices(): print node print ' ============== g0.create XLS file ===============' g0.createXlsxOutputFile() g0.createKmlOutputFile()
def test_class_one(self): print '==================== Main start ==================== '+ time.strftime("%c") t0 = time.clock() print "time start= {0}".format( t0) atmosphere = Atmosphere() t1 = time.clock() print "simulation time= {0} - simulation duration= {1:3.10f} seconds".format(t1 , (t1-t0)) print '==================== load airports ==================== '+ time.strftime("%c") airportsDB = AirportsDatabase() assert airportsDB.read() print '==================== air density at airports field elevation ==================== '+ time.strftime("%c") for airport in airportsDB.getAirports(): print '=======================' + airport.getName() + '====================' print 'field elevation= ' + str(airport.getFieldElevationAboveSeaLevelMeters()) + ' meters' altitudeMeters = airport.getFieldElevationAboveSeaLevelMeters() print 'air density= ' + str(atmosphere.getAirDensityKilogramsPerCubicMeters(altitudeMeters)) + ' kg / meters ^^ 3'
def test_main_five(self): airportsDb = AirportsDatabase() assert (airportsDb.read()) print ' ============== g3 performance ===============' t0 = time.clock() g3 = Graph() index = 0 for airport in airportsDb.getAirports(): print airport g3.addVertex(airport) index += 1 t1 = time.clock() print 'number of airports= {0} - duration= {1} seconds'.format(index, t1-t0) airport = airportsDb.getAirportFromICAOCode('LFPG') t2= time.clock() g4 = Graph() for i in range (0,10000): g4.addVertex(airport) t3 = time.clock() print 'number of addVertex = {0} - duration= {1:.8f} seconds'.format(i , t3-t2)
def test_Two(self): t0 = time.clock() print ( " ========== Great Circle ======= time start= ", t0 ) atmosphere = Atmosphere() earth = Earth() print ( '==================== Great Circle ==================== '+ time.strftime("%c") ) acBd = BadaAircraftDatabase() aircraftICAOcode = 'A320' if acBd.read(): if ( acBd.aircraftExists(aircraftICAOcode) and acBd.aircraftPerformanceFileExists(aircraftICAOcode)): print ( '==================== aircraft found ==================== '+ time.strftime("%c") ) aircraft = BadaAircraft(ICAOcode = aircraftICAOcode, aircraftFullName = acBd.getAircraftFullName(aircraftICAOcode), badaPerformanceFilePath = acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere = atmosphere, earth = earth) print ( aircraft ) else: print ( '==================== airport database ==================== '+ time.strftime("%c") ) airportsDB = AirportsDatabase() assert not(airportsDB is None) wayPointsDb = WayPointsDatabase() assert (wayPointsDb.read()) initialWayPoint = wayPointsDb.getWayPoint('TOU') finalWayPoint = wayPointsDb.getWayPoint('ALIVA') print ( initialWayPoint.getBearingDegreesTo(finalWayPoint) ) print ( finalWayPoint.getBearingDegreesTo(initialWayPoint) ) ''' departure ground run => initial speed is null ''' trueAirSpeedMetersSecond = 70.0 elapsedTimeSeconds = 0.0 aircraft.setCurrentAltitudeSeaLevelMeters( elapsedTimeSeconds = 0.0 , altitudeMeanSeaLevelMeters = 0.0, lastAltitudeMeanSeaLevelMeters = 0.0, targetCruiseAltitudeMslMeters = 10000.0) aircraft.initStateVector( elapsedTimeSeconds = 0.0, trueAirSpeedMetersSecond = 70.0, airportFieldElevationAboveSeaLevelMeters = 152.0) aircraft.setTargetCruiseFlightLevel(RequestedFlightLevel = 310, departureAirportAltitudeMSLmeters = 152.0) print ( "=========== simulated descent glide slope =========== " + time.strftime("%c") ) MarseilleMarignane = airportsDB.getAirportFromICAOCode('LFML') print ( '==================== runways database ==================== '+ time.strftime("%c") ) runWaysDatabase = RunWayDataBase() assert runWaysDatabase.read() runway = runWaysDatabase.getFilteredRunWays(airportICAOcode = 'LFML', runwayName = '') arrivalGroundRun = GroundRunLeg( runway = runway, aircraft = aircraft, airport = MarseilleMarignane ) touchDownWayPoint = arrivalGroundRun.computeTouchDownWayPoint() aircraft.setArrivalRunwayTouchDownWayPoint(touchDownWayPoint) threeDegreesGlideSlope = DescentGlideSlope(runway = runway, aircraft = aircraft, arrivalAirport = MarseilleMarignane ) threeDegreesGlideSlope.buildSimulatedGlideSlope(descentGlideSlopeSizeNautics = 5.0) approachWayPoint = threeDegreesGlideSlope.getLastVertex().getWeight() aircraft.setTargetApproachWayPoint(approachWayPoint) ''' ==================================''' greatCircle = GreatCircleRoute(initialWayPoint = initialWayPoint, finalWayPoint = finalWayPoint, aircraft = aircraft) distanceStillToFlyMeters = initialWayPoint.getDistanceMetersTo(approachWayPoint) greatCircle.computeGreatCircle( deltaTimeSeconds = 0.1, elapsedTimeSeconds = 0.0, distanceStillToFlyMeters = distanceStillToFlyMeters, distanceToLastFixMeters = distanceStillToFlyMeters) print ( 'main great circle length= ' + str(greatCircle.computeLengthMeters()) + ' meters' ) greatCircle.createKmlOutputFile() greatCircle.createXlsxOutputFile()
def test_DescentGlideSlope_Two(self): atmosphere = Atmosphere() earth = Earth() print( '==================== three degrees Descent Slope Start ==================== ' + time.strftime("%c")) acBd = BadaAircraftDatabase() aircraftICAOcode = 'A320' aircraft = None if acBd.read(): if (acBd.aircraftExists(aircraftICAOcode) and acBd.aircraftPerformanceFileExists(aircraftICAOcode)): print( '==================== aircraft found ==================== ' + time.strftime("%c")) aircraft = BadaAircraft( ICAOcode=aircraftICAOcode, aircraftFullName=acBd.getAircraftFullName( aircraftICAOcode), badaPerformanceFilePath=acBd.getAircraftPerformanceFile( aircraftICAOcode), atmosphere=atmosphere, earth=earth) aircraft.dump() assert not (aircraft is None) print('==================== runways database ==================== ' + time.strftime("%c")) runWaysDatabase = RunWayDataBase() assert runWaysDatabase.read() runway = runWaysDatabase.getFilteredRunWays(airportICAOcode='LFPG', runwayName='08L') print(runway) print("=========== airports =========== " + time.strftime("%c")) airportsDB = AirportsDatabase() assert (airportsDB.read()) CharlesDeGaulle = airportsDB.getAirportFromICAOCode('LFPG') print(CharlesDeGaulle) print("=========== descent glide slope =========== " + time.strftime("%c")) threeDegreesGlideSlope = DescentGlideSlope( runway=runway, aircraft=aircraft, arrivalAirport=CharlesDeGaulle) threeDegreesGlideSlope.buildSimulatedGlideSlope( descentGlideSlopeSizeNautics=5.0) print("=========== DescentGlideSlope =========== " + time.strftime("%c")) for node in threeDegreesGlideSlope.getVertices(): print(node) print("=========== DescentGlideSlope length =========== " + time.strftime("%c")) print("get number of vertices= {0}".format( threeDegreesGlideSlope.getNumberOfVertices())) print("get number of edges= {0}".format( threeDegreesGlideSlope.getNumberOfEdges())) print('Glide Slope overall length= {0} meters'.format( threeDegreesGlideSlope.computeLengthMeters())) threeDegreesGlideSlope.createKmlOutputFile() threeDegreesGlideSlope.createXlsxOutputFile() print( '==================== three degrees Descent Slope End ==================== ' + time.strftime("%c"))
if (acBd.aircraftExists(aircraftICAOcode) and acBd.aircraftPerformanceFileExists( acBd.getAircraftPerformanceFile(aircraftICAOcode))): print( '==================== aircraft found ==================== ' + time.strftime("%c")) aircraft = BadaAircraft( aircraftICAOcode, acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere, earth) aircraft.dump() print('==================== Get Departure Airport ==================== ' + time.strftime("%c")) airportsDB = AirportsDatabase() assert airportsDB.read() arrivalAirportCode = 'LFPO' arrivalAirport = airportsDB.getAirportFromICAOCode(arrivalAirportCode) print(arrivalAirport) print('==================== find the runway ==================== ' + time.strftime("%c")) runWaysDB = RunWayDataBase() assert runWaysDB.read() arrivalRunway = runWaysDB.getFilteredRunWays( arrivalAirportCode, 'Landing', aircraft.WakeTurbulenceCategory) print(arrivalRunway)
acBd = BadaAircraftDatabase() aircraftICAOcode = 'A320' if acBd.read(): if ( acBd.aircraftExists(aircraftICAOcode) and acBd.aircraftPerformanceFileExists(acBd.getAircraftPerformanceFile(aircraftICAOcode))): print ( '==================== aircraft found ==================== '+ time.strftime("%c") ) aircraft = BadaAircraft(aircraftICAOcode, acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere, earth) aircraft.dump() print ( '==================== read Airports Database ==================== '+ time.strftime("%c") ) airportsDB = AirportsDatabase() airport = airportsDB.getAirportFromICAOCode('LFPG') print ( '==================== find the run-ways ==================== '+ time.strftime("%c") ) runWaysDB = RunWayDataBase() if runWaysDB.read(): print ( 'runways DB correctly read' ) else: raise ValueError ('runways not read correctly') print ( '==================== find the run-ways ==================== '+ time.strftime("%c") ) for runway in runWaysDB.getRunWays(): print ( '==================== aircraft found ==================== '+ time.strftime("%c") ) aircraft = BadaAircraft(aircraftICAOcode, acBd.getAircraftPerformanceFile(aircraftICAOcode),
raise ValueError(': aircraft not found= ' + aircraftIcaoCode) print('==================== find the run-ways ==================== ' + time.strftime("%c")) runWaysDb = RunWayDataBase() assert (runWaysDb.read()) arrivalAirportICAOcode = 'LFPO' arrivalRunway = runWaysDb.getFilteredRunWays( airportICAOcode=arrivalAirportICAOcode, TakeOffLanding='Landing', aircraftWakeTurbulence=aircraft.getWakeTurbulenceCategory()) print('==================== read Airports Database ==================== ' + time.strftime("%c")) airportsDB = AirportsDatabase() assert (airportsDB.read()) print('========== departure is LONDON ================') departureAirport = airportsDB.getAirportFromICAOCode('EGLL') assert not (departureAirport is None) print('========== ' + str(arrivalRunway) + ' =================') airportIcaoCode = arrivalRunway.getAirportICAOcode() arrivalAirport = airportsDB.getAirportFromICAOCode(airportIcaoCode) print('arrival airport= {0}'.format(arrivalAirport)) aircraft.setArrivalAirportElevationMeters( arrivalAirport.fieldElevationAboveSeaLevelMeters) print(
def test_main(self): worldCitiesDatabase = WorldCitiesDatabase() self.assertTrue(worldCitiesDatabase.read()) airportsDb = AirportsDatabase() self.assertTrue(airportsDb.read()) CharlesDeGaulleRoissy = airportsDb.getAirportFromICAOCode('LFPG') print(CharlesDeGaulleRoissy) BerlinTegel = airportsDb.getAirportFromICAOCode('EDDT') print(BerlinTegel) distanceMeters = CharlesDeGaulleRoissy.getDistanceMetersTo(BerlinTegel) print( "distance from CDG to Berlin Tegel = {0:.2f} meters - {1:.2f} nautics" .format(distanceMeters, distanceMeters * Meter2NauticalMiles)) NumberOfPoints = int((distanceMeters * Meter2NauticalMiles) / 10.) print("Number of points = {0}".format(NumberOfPoints)) kmlOutputFile = KmlOutput(fileName="CDG-Berlin-Tegel") kmlOutputFile.write( name=CharlesDeGaulleRoissy.getName(), LongitudeDegrees=CharlesDeGaulleRoissy.getLongitudeDegrees(), LatitudeDegrees=CharlesDeGaulleRoissy.getLatitudeDegrees(), AltitudeAboveSeaLevelMeters=CharlesDeGaulleRoissy. getAltitudeMeanSeaLevelMeters()) kmlOutputFile.write(name=BerlinTegel.getName(), LongitudeDegrees=BerlinTegel.getLongitudeDegrees(), LatitudeDegrees=BerlinTegel.getLatitudeDegrees(), AltitudeAboveSeaLevelMeters=BerlinTegel. getAltitudeMeanSeaLevelMeters()) nearestCities = [] for wayPoint in worldCitiesDatabase.getCities(): distanceMetersToDeparture = CharlesDeGaulleRoissy.getDistanceMetersTo( wayPoint) distanceMetersToArrival = BerlinTegel.getDistanceMetersTo(wayPoint) if (distanceMetersToDeparture + distanceMetersToArrival) < ( distanceMeters + ((10.0 * distanceMeters) / 100.)): nearestCities.append({ "wayPoint": wayPoint, "distanceMeters": distanceMetersToDeparture + distanceMetersToArrival }) ''' re ordering ''' nearestCities.sort(key=lambda x: x["distanceMeters"], reverse=False) count = 0 for city in nearestCities: count = count + 1 if (count < NumberOfPoints): kmlOutputFile.write( name=city["wayPoint"].getName(), LongitudeDegrees=city["wayPoint"].getLongitudeDegrees(), LatitudeDegrees=city["wayPoint"].getLatitudeDegrees(), AltitudeAboveSeaLevelMeters=0.0) kmlOutputFile.close()
print('=========== main start ==================') aircraftIcaoCode = 'A320' atmosphere = Atmosphere() assert (not (atmosphere is None)) earth = Earth() assert (not (earth is None)) acBd = BadaAircraftDatabase() assert acBd.read() print('==================== load airports ==================== ' + time.strftime("%c")) airportsDB = AirportsDatabase() assert airportsDB.read() departureAirport = airportsDB.getAirportFromICAOCode('LFPG') assert not (departureAirport is None) print(departureAirport) arrivalAirportIcaoCode = 'LFML' arrivalAirport = airportsDB.getAirportFromICAOCode(arrivalAirportIcaoCode) assert not (arrivalAirport is None) print(arrivalAirport) runwaysDb = RunWayDataBase() assert runwaysDb.read() arrivalRunway = runwaysDb.getFilteredRunWays(arrivalAirportIcaoCode,
def test_DescentGlideSlope(self): atmosphere = Atmosphere() earth = Earth() print '==================== three degrees Descent Slope Start ==================== ' + time.strftime( "%c") acBd = BadaAircraftDatabase() aircraftICAOcode = 'A320' if acBd.read(): if (acBd.aircraftExists(aircraftICAOcode) and acBd.aircraftPerformanceFileExists(aircraftICAOcode)): print '==================== aircraft found ==================== ' + time.strftime( "%c") aircraft = BadaAircraft( ICAOcode=aircraftICAOcode, aircraftFullName=acBd.getAircraftFullName( aircraftICAOcode), badaPerformanceFilePath=acBd.getAircraftPerformanceFile( aircraftICAOcode), atmosphere=atmosphere, earth=earth) aircraft.dump() assert not (aircraft is None) print '==================== runways database ==================== ' + time.strftime( "%c") runWaysDatabase = RunWayDataBase() assert runWaysDatabase.read() runway = runWaysDatabase.getFilteredRunWays(airportICAOcode='LFML', runwayName='') print runway print "=========== arrival airport =========== " + time.strftime("%c") airportsDB = AirportsDatabase() assert (airportsDB.read()) MarseilleMarignane = airportsDB.getAirportFromICAOCode('LFML') print MarseilleMarignane print "=========== descent glide slope =========== " + time.strftime( "%c") threeDegreesGlideSlope = DescentGlideSlope( runway=runway, aircraft=aircraft, arrivalAirport=MarseilleMarignane) initialWayPoint = WayPoint(Name='startOfDescentGlideSlope', ) print "=========== DescentGlideSlope build the glide slope =========== " + time.strftime( "%c") # threeDegreesGlideSlope.buildGlideSlope(deltaTimeSeconds = 0.1, # elapsedTimeSeconds = 0.0, # initialWayPoint = None, # flownDistanceMeters = 0.0, # distanceStillToFlyMeters = 100000.0, # distanceToLastFixMeters = 100000.0) threeDegreesGlideSlope.buildSimulatedGlideSlope( descentGlideSlopeSizeNautics=5.0) print "=========== DescentGlideSlope =========== " + time.strftime( "%c") for node in threeDegreesGlideSlope.getVertices(): print node print "=========== DescentGlideSlope length =========== " + time.strftime( "%c") print "get number of vertices= {0}".format( threeDegreesGlideSlope.getNumberOfVertices()) print "get number of edges= {0}".format( threeDegreesGlideSlope.getNumberOfEdges()) print 'Glide Slope overall length= {0} meters'.format( threeDegreesGlideSlope.computeLengthMeters()) threeDegreesGlideSlope.createKmlOutputFile() threeDegreesGlideSlope.createXlsxOutputFile() print '==================== three degrees Descent Slope End ==================== ' + time.strftime( "%c")
def test_TurnLeg(self): print '==================== Turn Leg ==================== ' + time.strftime( "%c") atmosphere = Atmosphere() earth = Earth() acBd = BadaAircraftDatabase() aircraftICAOcode = 'A320' assert acBd.read() assert acBd.aircraftExists(aircraftICAOcode) assert acBd.aircraftPerformanceFileExists(aircraftICAOcode) print '==================== aircraft found ==================== ' + time.strftime( "%c") aircraft = BadaAircraft( ICAOcode=aircraftICAOcode, aircraftFullName=acBd.getAircraftFullName(aircraftICAOcode), badaPerformanceFilePath=acBd.getAircraftPerformanceFile( aircraftICAOcode), atmosphere=atmosphere, earth=earth) aircraft.dump() print '==================== Get Airport ==================== ' + time.strftime( "%c") airportsDB = AirportsDatabase() assert airportsDB.read() print '==================== Get Arrival Airport ==================== ' + time.strftime( "%c") Lisbonne = airportsDB.getAirportFromICAOCode('LPPT') print Lisbonne print '==================== find the run-ways ==================== ' + time.strftime( "%c") runWaysDatabase = RunWayDataBase() if runWaysDatabase.read(): print 'runways DB correctly read' print '==================== take off run-way ==================== ' + time.strftime( "%c") arrivalRunway = runWaysDatabase.getFilteredRunWays( airportICAOcode='LPPT', runwayName='') print arrivalRunway print '==================== Ground run ==================== ' + time.strftime( "%c") groundRun = GroundRunLeg(runway=arrivalRunway, aircraft=aircraft, airport=Lisbonne) touchDownWayPoint = groundRun.computeTouchDownWayPoint() print touchDownWayPoint groundRun.buildDepartureGroundRun(deltaTimeSeconds=1.0, elapsedTimeSeconds=0.0, distanceStillToFlyMeters=0.0, distanceToLastFixMeters=0.0) print '==================== Climb Ramp ==================== ' + time.strftime( "%c") initialWayPoint = groundRun.getLastVertex().getWeight() descentGlideSlope = DescentGlideSlope(runway=arrivalRunway, aircraft=aircraft, arrivalAirport=Lisbonne, descentGlideSlopeDegrees=3.0) ''' if there is a fix nearer to 5 nautics of the touch-down then limit size of simulated glide slope ''' descentGlideSlope.buildSimulatedGlideSlope( descentGlideSlopeSizeNautics=5.0) descentGlideSlope.createKmlOutputFile() firstGlideSlopeWayPoint = descentGlideSlope.getVertex(v=0).getWeight() print '==================== Climb Ramp ==================== ' + time.strftime( "%c") initialWayPoint = groundRun.getLastVertex().getWeight() print ' ================== turn leg end =============== ' wayPointsDb = WayPointsDatabase() assert (wayPointsDb.read()) Exona = wayPointsDb.getWayPoint('EXONA') Rosal = wayPointsDb.getWayPoint('ROSAL') print Rosal.getBearingDegreesTo(Exona) initialHeadingDegrees = arrivalRunway.getTrueHeadingDegrees() lastTurnLeg = TurnLeg(initialWayPoint=firstGlideSlopeWayPoint, finalWayPoint=Exona, initialHeadingDegrees=initialHeadingDegrees, aircraft=aircraft, reverse=True) deltaTimeSeconds = 1.0 lastTurnLeg.buildNewSimulatedArrivalTurnLeg( deltaTimeSeconds=deltaTimeSeconds, elapsedTimeSeconds=0.0, distanceStillToFlyMeters=0.0, simulatedAltitudeSeaLevelMeters=firstGlideSlopeWayPoint. getAltitudeMeanSeaLevelMeters(), flightPathAngleDegrees=3.0) lastTurnLeg.createKmlOutputFile() descentGlideSlope.addGraph(lastTurnLeg) #descentGlideSlope.createXlsxOutputFile() descentGlideSlope.createKmlOutputFile() print ' ================== turn leg end =============== '
def test_TurnLeg(self): print '==================== Turn Leg ==================== '+ time.strftime("%c") atmosphere = Atmosphere() earth = Earth() acBd = BadaAircraftDatabase() aircraftICAOcode = 'A320' assert acBd.read() assert acBd.aircraftExists(aircraftICAOcode) assert acBd.aircraftPerformanceFileExists(aircraftICAOcode) print '==================== aircraft found ==================== '+ time.strftime("%c") aircraft = BadaAircraft(ICAOcode = aircraftICAOcode, aircraftFullName = acBd.getAircraftFullName(aircraftICAOcode), badaPerformanceFilePath = acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere = atmosphere, earth = earth) aircraft.dump() print '==================== Get Airport ==================== '+ time.strftime("%c") airportsDB = AirportsDatabase() assert airportsDB.read() print '==================== Get Arrival Airport ==================== '+ time.strftime("%c") Lisbonne = airportsDB.getAirportFromICAOCode('LPPT') print Lisbonne print '==================== find the run-ways ==================== '+ time.strftime("%c") runWaysDatabase = RunWayDataBase() if runWaysDatabase.read(): print 'runways DB correctly read' print '==================== take off run-way ==================== '+ time.strftime("%c") arrivalRunway = runWaysDatabase.getFilteredRunWays( airportICAOcode = 'LPPT', runwayName = '') print arrivalRunway print '==================== Ground run ==================== '+ time.strftime("%c") groundRun = GroundRunLeg(runway = arrivalRunway, aircraft = aircraft, airport = Lisbonne) touchDownWayPoint = groundRun.computeTouchDownWayPoint() print touchDownWayPoint groundRun.buildDepartureGroundRun(deltaTimeSeconds = 1.0, elapsedTimeSeconds = 0.0, distanceStillToFlyMeters = 0.0, distanceToLastFixMeters = 0.0) print '==================== Climb Ramp ==================== '+ time.strftime("%c") initialWayPoint = groundRun.getLastVertex().getWeight() descentGlideSlope = DescentGlideSlope( runway = arrivalRunway, aircraft = aircraft, arrivalAirport = Lisbonne , descentGlideSlopeDegrees = 3.0) ''' if there is a fix nearer to 5 nautics of the touch-down then limit size of simulated glide slope ''' descentGlideSlope.buildSimulatedGlideSlope(descentGlideSlopeSizeNautics = 5.0) descentGlideSlope.createKmlOutputFile() firstGlideSlopeWayPoint = descentGlideSlope.getVertex(v=0).getWeight() print '==================== Climb Ramp ==================== '+ time.strftime("%c") initialWayPoint = groundRun.getLastVertex().getWeight() print ' ================== turn leg end =============== ' wayPointsDb = WayPointsDatabase() assert (wayPointsDb.read()) Exona = wayPointsDb.getWayPoint('EXONA') Rosal = wayPointsDb.getWayPoint('ROSAL') print Rosal.getBearingDegreesTo(Exona) initialHeadingDegrees = arrivalRunway.getTrueHeadingDegrees() lastTurnLeg = TurnLeg( initialWayPoint = firstGlideSlopeWayPoint, finalWayPoint = Exona, initialHeadingDegrees = initialHeadingDegrees, aircraft = aircraft, reverse = True) deltaTimeSeconds = 1.0 lastTurnLeg.buildNewSimulatedArrivalTurnLeg(deltaTimeSeconds = deltaTimeSeconds, elapsedTimeSeconds = 0.0, distanceStillToFlyMeters = 0.0, simulatedAltitudeSeaLevelMeters = firstGlideSlopeWayPoint.getAltitudeMeanSeaLevelMeters(), flightPathAngleDegrees = 3.0) lastTurnLeg.createKmlOutputFile() descentGlideSlope.addGraph(lastTurnLeg) #descentGlideSlope.createXlsxOutputFile() descentGlideSlope.createKmlOutputFile() print ' ================== turn leg end =============== '
def test_One(self): print('=========== main start ==================') aircraftICAOcode = 'A320' atmosphere = Atmosphere() assert (not (atmosphere is None)) earth = Earth() assert (not (earth is None)) acBd = BadaAircraftDatabase() assert acBd.read() if (acBd.aircraftExists(aircraftICAOcode) and acBd.aircraftPerformanceFileExists(aircraftICAOcode)): aircraft = BadaAircraft( ICAOcode=aircraftICAOcode, aircraftFullName=acBd.getAircraftFullName(aircraftICAOcode), badaPerformanceFilePath=acBd.getAircraftPerformanceFile( aircraftICAOcode), atmosphere=atmosphere, earth=earth) aircraft.dump() else: raise ValueError(': aircraft not found= ' + aircraftICAOcode) assert not (aircraft is None) print('================ load airports =================') airportsDB = AirportsDatabase() assert (airportsDB.read()) adepIcaoCode = 'LFML' departureAirport = airportsDB.getAirportFromICAOCode(adepIcaoCode) print(': departure airport= ' + str(departureAirport)) assert not (departureAirport is None) print('================ load runways =================') runWaysDatabase = RunWayDataBase() assert (runWaysDatabase.read()) print('==================== take off run-way ==================== ') departureRunway = runWaysDatabase.getFilteredRunWays(adepIcaoCode) print( '=========== minimum and maximum aircraft mass ==================') minMassKg = aircraft.getMinimumMassKilograms() print('aircraft minimum mass: ' + str(minMassKg) + ' kilograms') maxMassKg = aircraft.getMaximumMassKilograms() print('aircraft maximum mass: ' + str(maxMassKg) + ' kilograms') deltaMass = maxMassKg - minMassKg massKg = 39000.0 while (massKg < maxMassKg): massKg += 1000.0 print( '==================== set aircraft reference mass ==================== ' ) aircraft = BadaAircraft( ICAOcode=aircraftICAOcode, aircraftFullName=acBd.getAircraftFullName(aircraftICAOcode), badaPerformanceFilePath=acBd.getAircraftPerformanceFile( aircraftICAOcode), atmosphere=atmosphere, earth=earth) aircraft.setTargetCruiseFlightLevel( 310, departureAirport.getFieldElevationAboveSeaLevelMeters()) print( '==================== aircraft reference mass ==================== ' ) print('aircraft reference mass= ' + str(massKg) + ' Kilograms') aircraft.setAircraftMassKilograms(massKg) print( '==================== begin of ground run ==================== ' ) groundRunLeg = GroundRunLeg(runway=departureRunway, aircraft=aircraft, airport=departureAirport) groundRunLeg.buildDepartureGroundRun( deltaTimeSeconds=0.1, elapsedTimeSeconds=0.0, distanceStillToFlyMeters=500000.0, distanceToLastFixMeters=500000.0) groundRunLeg.computeLengthMeters() #groundRunLeg.createXlsxOutputFile() print( '==================== end of ground run ==================== ') initialWayPoint = groundRunLeg.getLastVertex().getWeight() print( '==================== dump aircraft speed profile ==================== ' ) aircraft.createStateVectorOutputFile(aircraftICAOcode + "-Mass-" + str(massKg)) print('=========== main end ==================')
def test_route(self): # import sys # temp = sys.stdout #store original stdout object for later # sys.stdout = open('log.txt','w') #redirect all prints to this log file wayPointsDb = WayPointsDatabase() assert wayPointsDb.read() t0 = time.clock() print ' ========== Airports Direct Route testing ======= ' airportsDb = AirportsDatabase() assert airportsDb.read() t1 = time.clock() print ' time to read airports database= {0:.2f} seconds'.format(t1-t0) t2 = time.clock() runwaysDb = RunWayDataBase() assert runwaysDb.read() print ' time to read run-way database= {0:.2f} seconds'.format(t2-t1) print ' ========== Airports Direct Route testing ======= ' departureCountry = 'Japan' departureCountry = 'United Kingdom' departureCountry = 'France' departureCountry = 'United States' arrivalCountry = 'Canada' arrivalCountry = 'France' arrivalCountry = 'United States' for departureAirport in airportsDb.getAirportsFromCountry(Country = departureCountry): departureAirportICAOcode = departureAirport.getICAOcode() departureRunwayName = '' departureRunwayFound = False for runwayName in runwaysDb.findAirportRunWays(airportICAOcode = departureAirportICAOcode, runwayLengthFeet = 11000.0): if not(runwaysDb.getFilteredRunWays( airportICAOcode = departureAirportICAOcode, runwayName = runwayName) is None): departureRunwayName = runwayName departureRunwayFound = True break if departureRunwayFound: for arrivalAirport in airportsDb.getAirportsFromCountry(Country = arrivalCountry): arrivalRunwayName = '' arrivalRunwayFound = False arrivalAirportICAOcode = arrivalAirport.getICAOcode() for runwayName in runwaysDb.findAirportRunWays(airportICAOcode = arrivalAirportICAOcode, runwayLengthFeet = 11000.0): if not(runwaysDb.getFilteredRunWays( airportICAOcode = arrivalAirportICAOcode, runwayName = runwayName) is None): arrivalRunwayName = runwayName arrivalRunwayFound = True break ''' we have a pair of airports ''' if departureRunwayFound and arrivalRunwayFound: distanceMeters = departureAirport.getDistanceMetersTo(arrivalAirport) if distanceMeters > 300000.0: print ' ========== Airports Direct Route testing ======= ' print '{0} - {1} - distance = {2} meters'.format(departureAirport.getName(), arrivalAirport.getName(), distanceMeters) print departureAirport print arrivalAirport routeFinder = RouteFinder() if routeFinder.isConnected(): RFL = 'FL390' if routeFinder.findRoute(departureAirport.getICAOcode(), arrivalAirport.getICAOcode(), RFL): routeList = routeFinder.getRouteAsList() print routeList routeFinder.insertWayPointsInDatabase(wayPointsDb) strRoute = 'ADEP/' + departureAirport.getICAOcode() + '/' + departureRunwayName + '-' for fix in routeList: strRoute += fix['Name'] + '-' strRoute += 'ADES/' + arrivalAirport.getICAOcode() + '/' + arrivalRunwayName print strRoute flightPath = FlightPath(route = strRoute, aircraftICAOcode = 'B744', RequestedFlightLevel = 390, cruiseMach = 0.92, takeOffMassKilograms = 280000.0) print "=========== Flight Plan compute =========== " t0 = time.clock() print 'time zero= ' + str(t0) lengthNauticalMiles = flightPath.computeLengthNauticalMiles() print 'flight path length= {0:.2f} nautics '.format(lengthNauticalMiles) flightPath.computeFlight(deltaTimeSeconds = 1.0) print 'simulation duration= ' + str(time.clock()-t0) + ' seconds' print "=========== Flight Plan create output files =========== " flightPath.createFlightOutputFiles()
'==================== aircraft found ==================== ' + time.strftime("%c")) aircraft = BadaAircraft( aircraftICAOcode, acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere, earth) aircraft.dump() print('==================== Turn Leg ==================== ' + time.strftime("%c")) print('ac max altitude Mean Sea Level Max TakeOff Weight feet= ' + str(aircraft.getMaxAltitudeMslMtowFeet()) + ' feet') print('==================== Read Airport Database ==================== ' + time.strftime("%c")) airportsDB = AirportsDatabase() print('==================== Get Departure Airport ==================== ' + time.strftime("%c")) departureAirportIcaoCode = 'LFBO' departureAirport = airportsDB.getAirportFromICAOCode( departureAirportIcaoCode) print(departureAirport) print('==================== Get Arrival Airport ==================== ' + time.strftime("%c")) arrivalAirportIcaoCode = 'LFPO' arrivalAirport = airportsDB.getAirportFromICAOCode(arrivalAirportIcaoCode) print(arrivalAirport) print('==================== find the run-ways ==================== ' +
acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere, earth) aircraft.dump() print('target altitude= ' + str(aircraft.getMaxAltitudeMslMtowFeet()) + ' feet') print('target speed= ' + str(aircraft.getMaxOpSpeedCasKnots()) + ' knots') else: raise ValueError('aircraft not found') else: raise ValueError('error while reading the aircraft database') print('==================== Read Airports Database ==================== ' + time.strftime("%c")) airportsDB = AirportsDatabase() print('==================== Read the run-ways ==================== ' + time.strftime("%c")) runWaysDB = RunWayDataBase() if runWaysDB.read(): print('runways DB correctly read') else: raise ValueError('run-ways not read correctly') print('==================== find the run-ways ==================== ' + time.strftime("%c")) for runway in runWaysDB.getRunWays(): print('========== ' + str(runway) + ' =================') airportIcaoCode = runway.getAirportICAOcode()
def test_DescentGlideSlope(self): atmosphere = Atmosphere() earth = Earth() print '==================== three degrees Descent Slope Start ==================== '+ time.strftime("%c") acBd = BadaAircraftDatabase() aircraftICAOcode = 'A320' if acBd.read(): if ( acBd.aircraftExists(aircraftICAOcode) and acBd.aircraftPerformanceFileExists(aircraftICAOcode)): print '==================== aircraft found ==================== '+ time.strftime("%c") aircraft = BadaAircraft(ICAOcode = aircraftICAOcode, aircraftFullName = acBd.getAircraftFullName(aircraftICAOcode), badaPerformanceFilePath = acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere = atmosphere, earth = earth) aircraft.dump() assert not (aircraft is None) print '==================== runways database ==================== '+ time.strftime("%c") runWaysDatabase = RunWayDataBase() assert runWaysDatabase.read() runway = runWaysDatabase.getFilteredRunWays(airportICAOcode = 'LFML', runwayName = '') print runway print "=========== arrival airport =========== " + time.strftime("%c") airportsDB = AirportsDatabase() assert (airportsDB.read()) MarseilleMarignane = airportsDB.getAirportFromICAOCode('LFML') print MarseilleMarignane print "=========== descent glide slope =========== " + time.strftime("%c") threeDegreesGlideSlope = DescentGlideSlope(runway = runway, aircraft = aircraft, arrivalAirport = MarseilleMarignane ) initialWayPoint = WayPoint(Name = 'startOfDescentGlideSlope', ) print "=========== DescentGlideSlope build the glide slope =========== " + time.strftime("%c") # threeDegreesGlideSlope.buildGlideSlope(deltaTimeSeconds = 0.1, # elapsedTimeSeconds = 0.0, # initialWayPoint = None, # flownDistanceMeters = 0.0, # distanceStillToFlyMeters = 100000.0, # distanceToLastFixMeters = 100000.0) threeDegreesGlideSlope.buildSimulatedGlideSlope(descentGlideSlopeSizeNautics = 5.0) print "=========== DescentGlideSlope =========== " + time.strftime("%c") for node in threeDegreesGlideSlope.getVertices(): print node print "=========== DescentGlideSlope length =========== " + time.strftime("%c") print "get number of vertices= {0}".format( threeDegreesGlideSlope.getNumberOfVertices() ) print "get number of edges= {0}".format ( threeDegreesGlideSlope.getNumberOfEdges() ) print 'Glide Slope overall length= {0} meters'.format( threeDegreesGlideSlope.computeLengthMeters() ) threeDegreesGlideSlope.createKmlOutputFile() threeDegreesGlideSlope.createXlsxOutputFile() print '==================== three degrees Descent Slope End ==================== '+ time.strftime("%c")
print '==================== Ground run ==================== '+ time.strftime("%c") acBd = BadaAircraftDatabase() aircraftICAOcode = 'A320' if acBd.read(): if ( acBd.aircraftExists(aircraftICAOcode) and acBd.aircraftPerformanceFileExists(acBd.getAircraftPerformanceFile(aircraftICAOcode))): print '==================== aircraft found ==================== '+ time.strftime("%c") aircraft = BadaAircraft(aircraftICAOcode, acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere, earth) aircraft.dump() print '==================== Ground run ==================== '+ time.strftime("%c") airportsDB = AirportsDatabase() assert airportsDB.read() CharlesDeGaulle = airportsDB.getAirportFromICAOCode('LFPG') print CharlesDeGaulle print '==================== Ground run - read runway database ==================== '+ time.strftime("%c") runWaysDatabase = RunWayDataBase() assert runWaysDatabase.read() print '==================== Ground run ==================== '+ time.strftime("%c") runway = runWaysDatabase.getFilteredRunWays('LFPG', aircraft.WakeTurbulenceCategory) print runway print '==================== departure Ground run ==================== '+ time.strftime("%c") groundRun = GroundRunLeg(runway=runway,
def test_graph_with_airport(self): print(" ========== AirportsDatabase testing ======= time start= ") airportsDb = AirportsDatabase() assert (airportsDb.read()) airportsDb.dumpCountry(Country="France") print("number of airports= ", airportsDb.getNumberOfAirports()) for ap in [ 'Orly', 'paris', 'toulouse', 'marseille', 'roissy', 'blagnac', 'provence', 'de gaulle' ]: print("ICAO Code of= ", ap, " ICAO code= ", airportsDb.getICAOCode(ap)) t1 = time.clock() print(" ========== AirportsDatabase testing ======= time start= ", t1) CharlesDeGaulleRoissy = airportsDb.getAirportFromICAOCode('LFPG') print(CharlesDeGaulleRoissy) MarseilleMarignane = airportsDb.getAirportFromICAOCode('LFML') print(MarseilleMarignane) g0 = Graph() for icao in ['LFPO', 'LFMY', 'LFAT', 'LFGJ']: airport = airportsDb.getAirportFromICAOCode(icao) g0.addVertex(airport) print('================ g0 =================') for node in g0.getVertices(): print(node) self.assertEqual(g0.getNumberOfVertices(), 4) g1 = Graph() for icao in ['LFKC', 'LFBO', 'LFKB']: airport = airportsDb.getAirportFromICAOCode(icao) g1.addVertex(airport) self.assertEqual(g1.getNumberOfVertices(), 3) print('================ g1 =================') for node in g1.getVertices(): print(node) print(' ============== g0.add_graph(g1) ===============') g0.addGraph(g1) for node in g0.getVertices(): print(node) self.assertEqual(g0.getNumberOfVertices(), 7) print('============== g0.create XLS file ===============') g0.createXlsxOutputFile() g0.createKmlOutputFile()
def test_main(self): t0 = time.process_time() print(' ========== AirportsDatabase testing ======= ') airportsDb = AirportsDatabase() ret = airportsDb.read() self.assertTrue(ret) t1 = time.process_time() print(t1 - t0) print(' ========== AirportsDatabase testing ======= ') airportsDb.dumpCountry(Country="France") print("number of airports= ", airportsDb.getNumberOfAirports()) print(' ========== AirportsDatabase testing ======= ') for ap in [ 'Orly', 'paris', 'toulouse', 'marseille', 'roissy', 'blagnac', 'provence', 'de gaulle' ]: print("ICAO Code of= ", ap, " ICAO code= ", airportsDb.getICAOCode(ap)) t2 = time.process_time() print(t2 - t1) print('========== AirportsDatabase testing ======= ') CharlesDeGaulleRoissy = airportsDb.getAirportFromICAOCode('LFPG') print(CharlesDeGaulleRoissy) print(' ========== AirportsDatabase testing ======= ') MarseilleMarignane = airportsDb.getAirportFromICAOCode('LFML') print(MarseilleMarignane) print(' ========== AirportsDatabase testing ======= ') Lisbonne = airportsDb.getAirportFromICAOCode('LPPT') print(Lisbonne) print(' ========== AirportsDatabase testing ======= ') JohnFKennedy = airportsDb.getAirportFromICAOCode('KJFK') self.assertTrue(isinstance(JohnFKennedy, Airport)) print(JohnFKennedy) print('========== AirportsDatabase testing =======') LosAngeles = airportsDb.getAirportFromICAOCode('KLAX') print(LosAngeles) self.assertTrue(True)
def test_ClimbRamp(self): atmosphere = Atmosphere() earth = Earth() print '==================== Three Degrees climb slope ==================== '+ time.strftime("%c") acBd = BadaAircraftDatabase() aircraftICAOcode = 'A320' if acBd.read(): if ( acBd.aircraftExists(aircraftICAOcode) and acBd.aircraftPerformanceFileExists(aircraftICAOcode)): print '==================== aircraft found ==================== '+ time.strftime("%c") aircraft = BadaAircraft( ICAOcode = aircraftICAOcode, aircraftFullName = acBd.getAircraftFullName(aircraftICAOcode), badaPerformanceFilePath = acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere = atmosphere, earth = earth) aircraft.dump() assert not(aircraft is None) print '==================== get Charles Gaulle airport ==================== '+ time.strftime("%c") airportsDB = AirportsDatabase() assert(airportsDB.read()) CharlesDeGaulle = airportsDB.getAirportFromICAOCode('LFPG') print CharlesDeGaulle assert not(aircraft is None) aircraft.setTargetCruiseFlightLevel(RequestedFlightLevel = 390, departureAirportAltitudeMSLmeters = CharlesDeGaulle.getAltitudeMeanSeaLevelMeters()) print '==================== Three Degrees climb slope==================== '+ time.strftime("%c") runWaysDatabase = RunWayDataBase() if runWaysDatabase.read(): print 'runways DB correctly read' runway = runWaysDatabase.getFilteredRunWays('LFPG') print runway print '==================== Ground Run ==================== '+ time.strftime("%c") groundRun = GroundRunLeg(runway=runway, aircraft=aircraft, airport=CharlesDeGaulle) groundRun.buildDepartureGroundRun(deltaTimeSeconds = 0.1, elapsedTimeSeconds = 0.0, distanceStillToFlyMeters = 100000.0, distanceToLastFixMeters = 100000.0) print '==================== Three Degrees climb slope==================== '+ time.strftime("%c") initialVertex = groundRun.getVertex(groundRun.getNumberOfVertices()-1) initialWayPoint = initialVertex.getWeight() climbRamp = ClimbRamp(initialWayPoint = initialWayPoint, runway=runway, aircraft=aircraft, departureAirport=CharlesDeGaulle) climbRamp.buildClimbRamp(deltaTimeSeconds = 0.1, elapsedTimeSeconds = 0.0, distanceStillToFlyMeters = 100000.0, distanceToLastFixMeters = 100000.0, climbRampLengthNautics = 5.0 ) groundRun.addGraph(climbRamp) groundRun.createKmlOutputFile() print "=========== ThreeDegreesGlideSlope end =========== " + time.strftime("%c")
acBd = BadaAircraftDatabase() aircraftICAOcode = 'A320' assert acBd.read() assert acBd.aircraftExists(aircraftICAOcode) if acBd.aircraftPerformanceFileExists( acBd.getAircraftPerformanceFile(aircraftICAOcode)): print('==================== aircraft found ==================== ') acA320 = BadaAircraft( aircraftICAOcode, acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere, earth) acA320.dump() print('==================== read Airports Database ==================== ') airportsDb = AirportsDatabase() assert (airportsDb.read()) print('==================== find the run-ways ==================== ') runWaysDB = RunWayDataBase() if runWaysDB.read(): print('runways DB correctly read') else: raise ValueError('runways not read correctly') print('==================== find the run-ways ==================== ') for arrivalRunway in runWaysDB.getRunWays(): print('==================== run-way ==================== ') print(arrivalRunway)
def test_main_four(self): print " ========== AirportsDatabase testing ======= time start= " airportsDb = AirportsDatabase() assert (airportsDb.read()) airportsDb.dumpCountry(Country="France") print "number of airports= ", airportsDb.getNumberOfAirports() for ap in [ 'Orly', 'paris', 'toulouse', 'marseille', 'roissy', 'blagnac', 'provence', 'de gaulle' ]: print "ICAO Code of= ", ap, " ICAO code= ", airportsDb.getICAOCode( ap) t1 = time.clock() print " ========== AirportsDatabase testing ======= time start= ", t1 CharlesDeGaulleRoissy = airportsDb.getAirportFromICAOCode('LFPG') print CharlesDeGaulleRoissy MarseilleMarignane = airportsDb.getAirportFromICAOCode('LFML') print MarseilleMarignane g0 = Graph() for icao in ['LFPO', 'LFMY', 'LFAT', 'LFGJ']: airport = airportsDb.getAirportFromICAOCode(icao) g0.addVertex(airport) print '================ g0 =================' for node in g0.getVertices(): print node g1 = Graph() for icao in ['LFKC', 'LFBO', 'LFKB']: airport = airportsDb.getAirportFromICAOCode(icao) g1.addVertex(airport) print '================ g1 =================' for node in g1.getVertices(): print node print ' ============== g0.add_graph(g1) ===============' g0.addGraph(g1) for node in g0.getVertices(): print node print ' ============== g0.create XLS file ===============' g0.createXlsxOutputFile() g0.createKmlOutputFile()
def buildFixList(self): ''' from the route build a fix list and from the fix list build a way point list ''' self.wayPointsDict = {} wayPointsDb = WayPointsDatabase() assert (wayPointsDb.read()) airportsDb = AirportsDatabase() assert airportsDb.read() runwaysDb = RunWayDataBase() assert runwaysDb.read() #print self.className + ': ================ get Fix List =================' self.fixList = [] index = 0 for fix in self.strRoute.split('-'): fix = str(fix).strip() ''' first item is the Departure Airport ''' if str(fix).startswith('ADEP'): ''' fix is the departure airport ''' if index == 0: ''' ADEP is the first fix of the route ''' if len(str(fix).split('/')) >= 2: self.departureAirportIcaoCode = str(fix).split('/')[1] self.departureAirport = airportsDb.getAirportFromICAOCode(ICAOcode = self.departureAirportIcaoCode) print self.className + ': departure airport= {0}'.format( self.departureAirport) self.departureRunwayName = '' if len(str(fix).split('/')) >= 3: self.departureRunwayName = str(fix).split('/')[2] if not(self.departureAirport is None): self.departureRunway = runwaysDb.getFilteredRunWays(airportICAOcode = self.departureAirportIcaoCode, runwayName = self.departureRunwayName) print self.className + ': departure runway= {0}'.format(self.departureRunway) else: raise ValueError (self.className + ': ADEP must be the first fix in the route!!!') elif str(fix).startswith('ADES'): if index == (len(self.strRoute.split('-'))-1): ''' ADES is the last fix of the route ''' if len(str(fix).split('/')) >= 2: self.arrivalAirportIcaoCode = str(fix).split('/')[1] self.arrivalAirport = airportsDb.getAirportFromICAOCode(ICAOcode = self.arrivalAirportIcaoCode) print self.className + ': arrival airport= {0}'.format( self.arrivalAirport) self.arrivalRunwayName = '' if len(str(fix).split('/')) >= 3: self.arrivalRunwayName = str(fix).split('/')[2] if not(self.arrivalAirport is None): self.arrivalRunway = runwaysDb.getFilteredRunWays(airportICAOcode = self.arrivalAirportIcaoCode, runwayName = self.arrivalRunwayName) print self.className + ': arrival runway= {0}'.format(self.arrivalRunway) else: raise ValueError (self.classeName + ': ADES must be the last fix of the route!!!' ) else: ''' do not take the 1st one (ADEP) and the last one (ADES) ''' constraintFound, levelConstraint, speedConstraint = analyseConstraint(index, fix) #print self.className + ': constraint found= {0}'.format(constraintFound) if constraintFound == True: constraint = {} constraint['fixIndex'] = index constraint['level'] = levelConstraint constraint['speed'] = speedConstraint self.constraintsList.append(constraint) else: self.fixList.append(fix) wayPoint = wayPointsDb.getWayPoint(fix) if not(wayPoint is None): #print wayPoint self.wayPointsDict[fix] = wayPoint else: ''' do not insert way point names when there is no known latitude - longitude ''' self.fixList.pop() index += 1 #print self.className + ': fix list= ' + str(self.fixList) assert (self.allAnglesLessThan90degrees(minIntervalNautics = 10.0))
def test_One(self): print('==================== departure airport ==================== ' + time.strftime("%c")) airportsDB = AirportsDatabase() assert (airportsDB.read()) CharlesDeGaulle = airportsDB.getAirportFromICAOCode('LFPG') print(CharlesDeGaulle) print('==================== arrival airport ==================== ' + time.strftime("%c")) MarseilleMarignane = airportsDB.getAirportFromICAOCode('LFML') print(MarseilleMarignane) print('==================== Great Circle ==================== ' + time.strftime("%c")) self.aircraft.setCurrentAltitudeSeaLevelMeters( elapsedTimeSeconds=0.0, altitudeMeanSeaLevelMeters=0.0, lastAltitudeMeanSeaLevelMeters=0.0, targetCruiseAltitudeMslMeters=10000.0) self.aircraft.initStateVector( elapsedTimeSeconds=0.0, trueAirSpeedMetersSecond=70.0, airportFieldElevationAboveSeaLevelMeters=152.0) self.aircraft.setTargetCruiseFlightLevel( RequestedFlightLevel=310, departureAirportAltitudeMSLmeters=152.0) print('==================== runways database ==================== ' + time.strftime("%c")) runWaysDatabase = RunWayDataBase() assert runWaysDatabase.read() arrivalRunway = runWaysDatabase.getFilteredRunWays( airportICAOcode='LFML', runwayName='') print('==================== Compute touch down ==================== ' + time.strftime("%c")) arrivalGroundRun = GroundRunLeg(runway=arrivalRunway, aircraft=self.aircraft, airport=MarseilleMarignane) touchDownWayPoint = arrivalGroundRun.computeTouchDownWayPoint() self.aircraft.setArrivalRunwayTouchDownWayPoint(touchDownWayPoint) print("=========== simulated descent glide slope =========== " + time.strftime("%c")) threeDegreesGlideSlope = DescentGlideSlope( runway=arrivalRunway, aircraft=self.aircraft, arrivalAirport=MarseilleMarignane) threeDegreesGlideSlope.buildSimulatedGlideSlope( descentGlideSlopeSizeNautics=5.0) approachWayPoint = threeDegreesGlideSlope.getLastVertex().getWeight() self.aircraft.setTargetApproachWayPoint(approachWayPoint) print('==================== Great Circle ==================== ' + time.strftime("%c")) greatCircle = GreatCircleRoute(initialWayPoint=CharlesDeGaulle, finalWayPoint=approachWayPoint, aircraft=self.aircraft) distanceStillToFlyMeters = CharlesDeGaulle.getDistanceMetersTo( approachWayPoint) greatCircle.computeGreatCircle( deltaTimeSeconds=1.0, elapsedTimeSeconds=0.0, distanceStillToFlyMeters=distanceStillToFlyMeters, distanceToLastFixMeters=distanceStillToFlyMeters) print('main great circle length= ' + str(greatCircle.computeLengthMeters()) + ' meters') greatCircle.createKmlOutputFile() greatCircle.createXlsxOutputFile()
def test_ClimbRamp(self): atmosphere = Atmosphere() earth = Earth() print '==================== Three Degrees climb slope ==================== ' + time.strftime( "%c") acBd = BadaAircraftDatabase() aircraftICAOcode = 'A320' if acBd.read(): if (acBd.aircraftExists(aircraftICAOcode) and acBd.aircraftPerformanceFileExists(aircraftICAOcode)): print '==================== aircraft found ==================== ' + time.strftime( "%c") aircraft = BadaAircraft( ICAOcode=aircraftICAOcode, aircraftFullName=acBd.getAircraftFullName( aircraftICAOcode), badaPerformanceFilePath=acBd.getAircraftPerformanceFile( aircraftICAOcode), atmosphere=atmosphere, earth=earth) aircraft.dump() assert not (aircraft is None) print '==================== get Charles Gaulle airport ==================== ' + time.strftime( "%c") airportsDB = AirportsDatabase() assert (airportsDB.read()) CharlesDeGaulle = airportsDB.getAirportFromICAOCode('LFPG') print CharlesDeGaulle assert not (aircraft is None) aircraft.setTargetCruiseFlightLevel( RequestedFlightLevel=390, departureAirportAltitudeMSLmeters=CharlesDeGaulle. getAltitudeMeanSeaLevelMeters()) print '==================== Three Degrees climb slope==================== ' + time.strftime( "%c") runWaysDatabase = RunWayDataBase() if runWaysDatabase.read(): print 'runways DB correctly read' runway = runWaysDatabase.getFilteredRunWays('LFPG') print runway print '==================== Ground Run ==================== ' + time.strftime( "%c") groundRun = GroundRunLeg(runway=runway, aircraft=aircraft, airport=CharlesDeGaulle) groundRun.buildDepartureGroundRun(deltaTimeSeconds=0.1, elapsedTimeSeconds=0.0, distanceStillToFlyMeters=100000.0, distanceToLastFixMeters=100000.0) print '==================== Three Degrees climb slope==================== ' + time.strftime( "%c") initialVertex = groundRun.getVertex(groundRun.getNumberOfVertices() - 1) initialWayPoint = initialVertex.getWeight() climbRamp = ClimbRamp(initialWayPoint=initialWayPoint, runway=runway, aircraft=aircraft, departureAirport=CharlesDeGaulle) climbRamp.buildClimbRamp(deltaTimeSeconds=0.1, elapsedTimeSeconds=0.0, distanceStillToFlyMeters=100000.0, distanceToLastFixMeters=100000.0, climbRampLengthNautics=5.0) groundRun.addGraph(climbRamp) groundRun.createKmlOutputFile() print "=========== ThreeDegreesGlideSlope end =========== " + time.strftime( "%c")
from Home.Guidance.FlightPathFile import FlightPath if __name__ == '__main__': # import sys # temp = sys.stdout #store original stdout object for later # sys.stdout = open('log.txt','w') #redirect all prints to this log file wayPointsDb = WayPointsDatabase() assert wayPointsDb.read() t0 = time.clock() print ( ' ========== Airports Direct Route testing ======= ' ) airportsDb = AirportsDatabase() assert airportsDb.read() t1 = time.clock() print ( ' time to read airports database= {0:.2f} seconds'.format(t1-t0) ) t2 = time.clock() runwaysDb = RunWayDataBase() assert runwaysDb.read() print ( ' time to read run-way database= {0:.2f} seconds'.format(t2-t1)) print ( ' ========== Airports Direct Route testing ======= ' ) departureCountry = 'Japan' departureCountry = 'United Kingdom' departureCountry = 'France' departureCountry = 'United States' arrivalCountry = 'Canada'