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()
Exemple #2
0
    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_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))
Exemple #4
0
    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)
Exemple #5
0
    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()
Exemple #6
0
    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_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_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 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_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()
Exemple #11
0
    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 =============== '
    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), atmosphere,
            earth)

        print('====================  run-way ==================== ')
        print(runway)

        airportIcaoCode = runway.getAirportICAOcode()
        departureAirport = airportsDB.getAirportFromICAOCode(airportIcaoCode)

        print('====================== departure airport =================')
        print(departureAirport)

        print('====================  ground run ==================== ')
        groundRun = GroundRunLeg(runway=runway,
                                 aircraft=aircraft,
                                 airport=departureAirport)
        groundRun.buildDepartureGroundRun(elapsedTimeSeconds=0.0,
                                          distanceStillToFlyMeters=600000.0)
        groundRun.createKmlOutputFile()
 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, 
                          aircraft=aircraft,
                          airport=CharlesDeGaulle)
 groundRun.buildDepartureGroundRun(deltaTimeSeconds = 0.1,
    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_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")
 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")
Exemple #17
0
    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"))
Exemple #18
0
    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)

        airportIcaoCode = arrivalRunway.getAirportICAOcode()
        airport = airportsDb.getAirportFromICAOCode(airportIcaoCode)
        print('====================  airport ==================== ')

        print(airport)

        climbRamp = ClimbRamp(runway=arrivalRunway,
                              aircraft=acA320,
                              departureAirport=airport)
        climbRamp.buildClimbRamp()
        climbRamp.createXlsxOutputFile()

        descentSlope = DescentGlideSlope(runway=arrivalRunway,
                                         aircraft=acA320,
                                         arrivalAirport=airport)
        descentSlope.buildGlideSlope()
        descentSlope.createXlsxOutputFile()
    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 ==================')
Exemple #20
0
    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_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()
            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)

    aircraft.setArrivalAirportElevationMeters(
        arrivalAirport.getFieldElevationAboveSeaLevelMeters())

    CAS = aircraft.computeLandingStallSpeedCasKnots()
            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('==================== read Airports Database ==================== ' +
          time.strftime("%c"))
    airportsDB = AirportsDatabase()
    airport = airportsDB.getAirportFromICAOCode('LFPG')

    print('==================== fuel flow testing  ==================== ' +
          time.strftime("%c"))

    elapsedTimeSeconds = 0.0

    for index in range(0, 100):
        print('==================== fuel flow testing  ==================== ' +
              time.strftime("%c"))

        deltaTimeSeconds = 1.0
        elapsedTimeSeconds += deltaTimeSeconds

        print('elapsed time= ' + str(elapsedTimeSeconds) +
              ' fuel flow kilograms= ' +
    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 =============== '
    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(
        '=========== add final turn, descent and ground run ==================='
    )
    arrivalGroundRun = GroundRunLeg(runway=arrivalRunway,
                                    aircraft=aircraft,
 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()
Exemple #27
0
 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),
                               atmosphere,
    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()
        departureAirport = airportsDB.getAirportFromICAOCode(airportIcaoCode)
        if departureAirport is None:
            raise ValueError('departure airport not found')

        print('====================  departure airport ==================== ' +
              time.strftime("%c"))
        print(departureAirport)

        print('====================  Climb Ramp ==================== ' +
              time.strftime("%c"))
        climbRamp = ClimbRamp(runway=runway,
                              aircraft=aircraft,
                              departureAirport=departureAirport)
        climbRamp.buildClimbRamp()

        print(
Exemple #29
0
    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.BadaAircraftPerformance.BadaAircraftDatabaseFile import BadaAircraftDatabase
from Home.BadaAircraftPerformance.BadaAircraftFile import BadaAircraft

from Home.Guidance.TurnLegFile import TurnLeg


Meter2Feet = 3.2808 # one meter equals 3.28 feet
Knots2MetersPerSecond = 0.514444444

if __name__ == '__main__':
    
    
    airportsDb = AirportsDatabase()
    assert airportsDb.read()
    departureAirport = airportsDb.getAirportFromICAOCode('LFPO')
    arrivalAirport = airportsDb.getAirportFromICAOCode('LFBO')
    
    atmosphere = Atmosphere()
    earth = Earth()
    
    acBd = BadaAircraftDatabase()
    assert acBd.read()
    aircraftIcaoCode = 'A320'
    if ( acBd.aircraftExists(aircraftIcaoCode) 
        and acBd.aircraftPerformanceFileExists(acBd.getAircraftPerformanceFile(aircraftIcaoCode))):
        
        tasKnots = 480.0
        print ( '--------------- tas= {0:.2f} knots ----------------------'.format(tasKnots) )
        aircraft = BadaAircraft(aircraftIcaoCode, 
                                      acBd.getAircraftPerformanceFile(aircraftIcaoCode),