def test_Airport(self):

        print "=========== Airport  =========== " + time.strftime("%c")

        airportICAOcode = 'LFPG'
        CharlesDeGaulle = Airport(Name = 'CharlesDeGaulle',
                                ICAOcode = airportICAOcode,
                                Country = 'France')
        self.assertTrue( not(CharlesDeGaulle is None) )
        
        runWaysDatabase = RunWayDataBase()
        self.assertTrue( runWaysDatabase.read() , 'run ways DB read correctly')
        
        self.assertTrue( CharlesDeGaulle.hasRunWays(runWaysDatabase) )
        print 'airport= {0} has run-ways= {1}'.format(CharlesDeGaulle, CharlesDeGaulle.hasRunWays(runWaysDatabase))
        
        print "=========== Airport run ways ONE =========== " + time.strftime("%c")

        for runway in CharlesDeGaulle.getRunWaysAsDict(runWaysDatabase):
            print runway
            
        print "=========== Airport run ways TWO =========== " + time.strftime("%c")

        for runway in CharlesDeGaulle.getRunWays(runWaysDatabase):
            print runway
    def test_Airport(self):

        print ( "=========== Airport  =========== " + time.strftime("%c") )

        airportICAOcode = 'LFPG'
        CharlesDeGaulle = Airport(Name = 'CharlesDeGaulle',
                                ICAOcode = airportICAOcode,
                                Country = 'France')
        self.assertTrue( not(CharlesDeGaulle is None) )
        
        runWaysDatabase = RunWayDataBase()
        self.assertTrue( runWaysDatabase.read() , 'run ways DB read correctly')
        
        self.assertTrue( CharlesDeGaulle.hasRunWays(runWaysDatabase) )
        print ( 'airport= {0} has run-ways= {1}'.format(CharlesDeGaulle, CharlesDeGaulle.hasRunWays(runWaysDatabase)) )
        
        print ( "=========== Airport run ways ONE =========== " + time.strftime("%c") )

        for runway in CharlesDeGaulle.getRunWaysAsDict(runWaysDatabase):
            print ( runway )
            
        print ( "=========== Airport run ways TWO =========== " + time.strftime("%c") )

        for runway in CharlesDeGaulle.getRunWays(runWaysDatabase):
            print ( runway )
    def test_main_two(self):
        
        print ( '====================run-ways test two ====================' )

        runWaysDatabase = RunWayDataBase()
        self.assertTrue( runWaysDatabase.read() )
            
        airportICAOcode = 'LPPT'
        self.assertTrue ( runWaysDatabase.hasRunWays(airportICAOcode) )
    def test_main_three(self):
        
        print ( '====================run-ways test three ====================' )

        runWaysDatabase = RunWayDataBase()
        self.assertTrue( runWaysDatabase.read() )
        
        airportICAOcode = 'LFPG'
        for runway in runWaysDatabase.getRunWaysAsDict(airportICAOcode) :
            print ( runway )
    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()
Exemplo n.º 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))
Exemplo n.º 7
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")
Exemplo n.º 8
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 =============== '
    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()
                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()
    TAS = cas2tas(
        cas=CAS,
        altitude=arrivalAirport.getFieldElevationAboveSeaLevelMeters(),
        temp='std',
        speed_units='kt',
    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_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_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_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")
    if (acBd.aircraftExists(aircraftIcaoCode)
            and acBd.aircraftPerformanceFileExists(
                acBd.getAircraftPerformanceFile(aircraftIcaoCode))):

        aircraft = BadaAircraft(
            aircraftIcaoCode,
            acBd.getAircraftPerformanceFile(aircraftIcaoCode), atmosphere,
            earth)
        aircraft.dump()
    else:
        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')
#     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 = ''
    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))
Exemplo n.º 18
0
    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 ==================== ' +
          time.strftime("%c"))
    runWaysDatabase = RunWayDataBase()
    if runWaysDatabase.read():
        print('runways DB correctly read')

    print('====================  take off run-way ==================== ' +
          time.strftime("%c"))
    departureRunway = runWaysDatabase.getFilteredRunWays(
        departureAirportIcaoCode, 'TakeOff', aircraft.WakeTurbulenceCategory)
    print(departureRunway)

    print('====================  arrival run-way ==================== ' +
          time.strftime("%c"))
    arrivalRunway = runWaysDatabase.getFilteredRunWays(
        arrivalAirportIcaoCode, 'Landing', aircraft.WakeTurbulenceCategory)
    print(arrivalRunway)
    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 ==================')
Exemplo n.º 20
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"))
Exemplo n.º 21
0
    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,
                                                 'Landing')

    if (acBd.aircraftExists(aircraftIcaoCode)
            and acBd.aircraftPerformanceFileExists(
                acBd.getAircraftPerformanceFile(aircraftIcaoCode))):
        aircraft = BadaAircraft(
            aircraftIcaoCode,
            acBd.getAircraftPerformanceFile(aircraftIcaoCode), atmosphere,
            earth)
        aircraft.dump()
    assert not (aircraft is None)
    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 =============== '
Exemplo n.º 23
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 ( '==================== 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,
                               earth)
     
     print ( '==========================' )
 def test_main_one(self):
 
     print ( '====================run-ways====================' )
     t0 = time.clock()
 
     runWaysDatabase = RunWayDataBase()
     if runWaysDatabase.read():
         print ( 'runways DB correctly read' )
     
     t1 = time.clock()
     print ( 'time spent= {0:.2f} seconds'.format(t1-t0) )
     
     print ( '====================run-ways====================' )
 
     print ( runWaysDatabase.findAirportRunWays('LFPG') )
     t2 = time.clock()
     print ('time spent= {0:.2f} seconds'.format(t2-t1) )
     
 
     print ( '====================run-ways get filtered run ways====================' )
     print ( runWaysDatabase.getFilteredRunWays('LFML') )
     
     print ( '====================run-ways get filtered run ways====================' )
     print ( runWaysDatabase.getFilteredRunWays('LFBO') )
     
     print ( '====================run-ways get filtered run ways====================' )
     print ( runWaysDatabase.findAirportRunWays('LFBO') )
     
     
     print ( '====================run-ways get filtered run ways====================' )
     runway = runWaysDatabase.getFilteredRunWays('EGLL') 
     print ( runway )
     
     print ( '====================run-ways get filtered run ways====================' )
     #print 'number of runways: ' + str(len(runWaysDatabase.getRunWays('LFPG')))
     runway = runWaysDatabase.getFilteredRunWays(airportICAOcode = 'LFPG', runwayName  = '27L')
     print ( runway )
     
     print ( '====================run-ways get filtered run ways====================' )
     runway = runWaysDatabase.getFilteredRunWays(airportICAOcode = 'KJFK', runwayName  = '31L')
     print ( runway )
     
     print ( '====================run-ways get filtered run ways====================' )
 
     runway = runWaysDatabase.getFilteredRunWays(airportICAOcode = 'KLAX', runwayName  = '06L')
     print ( runway )
     
     for ICAOcode in ['LFPG', 'LFPO', 'LFBO', 'LFML', 'LFST', 'KJFK', 'SBGL', 'LFBD']:
         
         print ( '====================run-ways get filtered run ways====================' )
 
         tStart = time.clock()
         print ( runWaysDatabase.findAirportRunWays(ICAOcode) )
         tEnd = time.clock()
         print ( 'icao= {0} - duration= {1:.2f} seconds'.format(ICAOcode, (tEnd-tStart)) )
 #     print '====================run-ways===================='
 #     for runway in runWaysDatabase.getRunWays():
 #         print runway.getAirportICAOcode() + '-' + runway.getName()
         
     print ( '====================run-ways====================' )
 #     for runway in runWaysDatabase.getRunWays():
 #         print runway
 
     print ( '====================run-ways get filtered run ways====================' )
 
     print ( runWaysDatabase.findAirportRunWays('LPPT') )
Exemplo n.º 25
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")
         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,
                             elapsedTimeSeconds = 0.0,
                             distanceStillToFlyMeters = 100000.0)
 groundRun.createKmlOutputFile()
 groundRun.createXlsxOutputFile()