Example #1
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))
Example #2
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"))
Example #3
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 =============== ')
Example #4
0
        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)
Example #5
0
        if (acBd.aircraftExists(aircraftICAOcode)
                and acBd.aircraftPerformanceFileExists(
                    acBd.getAircraftPerformanceFile(aircraftICAOcode))):

            print(
                '==================== aircraft found  ==================== ' +
                time.strftime("%c"))
            acA320 = BadaAircraft(
                aircraftICAOcode,
                acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere,
                earth)
            print(acA320)

    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
    acA320.setTrueAirSpeedMetersSecond(elapsedTimeSeconds,
                                       trueAirSpeedMetersSecond)
    acA320.setCurrentAltitudeSeaLevelMeters(elapsedTimeSeconds, 0.0)
Example #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()

        #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))
Example #7
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()
Example #8
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"))