def getAircraft(self, aircraftICAOcode):

        print(self.className +
              ': ================ get aircraft =================')
        atmosphere = Atmosphere()
        earth = Earth()
        acBd = BadaAircraftDatabase()
        assert acBd.read()

        if (acBd.aircraftExists(aircraftICAOcode)
                and acBd.aircraftPerformanceFileExists(aircraftICAOcode)):

            print(self.className + ': performance file= {0}'.format(
                acBd.getAircraftPerformanceFile(aircraftICAOcode)))
            self.aircraft = BadaAircraft(
                ICAOcode=aircraftICAOcode,
                aircraftFullName=acBd.getAircraftFullName(aircraftICAOcode),
                badaPerformanceFilePath=acBd.getAircraftPerformanceFile(
                    aircraftICAOcode),
                atmosphere=atmosphere,
                earth=earth,
                windSpeedMetersPerSecond=None,
                windDirectionDegrees=None)
            self.aircraft.dump()
        else:
            raise ValueError(self.className + ': aircraft not found= ' +
                             self.aircraftICAOcode)
예제 #2
0
    def test_Class_One(self):
            
        print('================ test one ====================')
        acBd = BadaAircraftDatabase()
        assert acBd.read()
        
        atmosphere = Atmosphere()
        earth = Earth()
        
        aircraftICAOcode = 'A320'
        if ( acBd.aircraftExists(aircraftICAOcode) and
             acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
            
            print(acBd.getAircraftFullName(aircraftICAOcode))
            
            aircraftPerformance = AircraftPerformance(acBd.getAircraftPerformanceFile(aircraftICAOcode))
            aeroDynamics = AeroDynamics(aircraftPerformance, atmosphere, earth)
            
            print(aeroDynamics)
            for phase in ['CR', 'IC', 'TO', 'AP', 'LD']:
                print('phase= {0} - Vstall CAS= {1} knots'.format(phase, aeroDynamics.getVstallKcas(phase)))
                
            for phase in ['CR', 'IC', 'TO', 'AP', 'LD']:
                print('phase= {0} - Drag Coeff= {1}'.format(phase, aeroDynamics.getDragCoeff(phase)))

            print('Wing Area Surface={0} Square-meters'.format(aeroDynamics.getWingAreaSurfaceSquareMeters()))
 def test_Class_Two(self):
         
     print '================ test Two ===================='
     acBd = BadaAircraftDatabase()
     assert acBd.read()
     
     atmosphere = Atmosphere()
     earth = Earth()
     
     aircraftICAOcode = 'A320'
     if ( acBd.aircraftExists(aircraftICAOcode) and
          acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
         
         print acBd.getAircraftFullName(aircraftICAOcode)
         
         aircraftPerformance = AircraftPerformance(acBd.getAircraftPerformanceFile(aircraftICAOcode))
         aeroDynamics = AeroDynamics(aircraftPerformance, atmosphere, earth)
         
         print aeroDynamics
         phase = 'XX'
         try:
             print aeroDynamics.getDragCoeff(phase)
         except Exception as e: 
             print 'test two = {0}'.format(e)
             self.assertTrue(isinstance(e, AssertionError))
예제 #4
0
    def getAircraft(self):

        print(self.className +
              ': ================ get aircraft =================')
        atmosphere = Atmosphere()
        earth = Earth()
        acBd = BadaAircraftDatabase()
        assert acBd.read()

        if (acBd.aircraftExists(self.aircraftICAOcode)
                and acBd.aircraftPerformanceFileExists(self.aircraftICAOcode)):

            print(self.className + ': performance file= {0}'.format(
                acBd.getAircraftPerformanceFile(self.aircraftICAOcode)))
            self.aircraft = BadaAircraft(
                ICAOcode=self.aircraftICAOcode,
                aircraftFullName=acBd.getAircraftFullName(
                    self.aircraftICAOcode),
                badaPerformanceFilePath=acBd.getAircraftPerformanceFile(
                    self.aircraftICAOcode),
                atmosphere=atmosphere,
                earth=earth)
            self.aircraft.dump()
        else:
            raise ValueError(self.className + ': aircraft not found= ' +
                             self.aircraftICAOcode)
예제 #5
0
 def test_Class_Two(self):
         
     print('================ test Two ====================')
     acBd = BadaAircraftDatabase()
     assert acBd.read()
     
     atmosphere = Atmosphere()
     earth = Earth()
     
     aircraftICAOcode = 'A320'
     if ( acBd.aircraftExists(aircraftICAOcode) and
          acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
         
         print(acBd.getAircraftFullName(aircraftICAOcode))
         
         aircraftPerformance = AircraftPerformance(acBd.getAircraftPerformanceFile(aircraftICAOcode))
         aeroDynamics = AeroDynamics(aircraftPerformance, atmosphere, earth)
         
         print(aeroDynamics)
         phase = 'XX'
         try:
             print(aeroDynamics.getDragCoeff(phase))
         except Exception as e: 
             print('test two = {0}'.format(e))
             self.assertTrue(isinstance(e, AssertionError))
    def setUp(self) -> None:

        self.deltaTimeSeconds = 1.0
        atmosphere = Atmosphere()
        earth = Earth()

        print('==================== Aircraft ==================== ' +
              time.strftime("%c"))
        acBd = BadaAircraftDatabase()
        aircraftICAOcode = 'A320'
        if acBd.read():
            if (acBd.aircraftExists(aircraftICAOcode)
                    and acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
                print(
                    '==================== aircraft found  ==================== '
                    + time.strftime("%c"))
                self.aircraft = BadaAircraft(
                    ICAOcode=aircraftICAOcode,
                    aircraftFullName=acBd.getAircraftFullName(
                        aircraftICAOcode),
                    badaPerformanceFilePath=acBd.getAircraftPerformanceFile(
                        aircraftICAOcode),
                    atmosphere=atmosphere,
                    earth=earth,
                    windSpeedMetersPerSecond=None,
                    windDirectionDegrees=None)
                print(self.aircraft)
                assert not (self.aircraft is None)
    def test_Class_One(self):
            
        print '================ test one ===================='
        acBd = BadaAircraftDatabase()
        assert acBd.read()
        
        atmosphere = Atmosphere()
        earth = Earth()
        
        aircraftICAOcode = 'A320'
        if ( acBd.aircraftExists(aircraftICAOcode) and
             acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
            
            print acBd.getAircraftFullName(aircraftICAOcode)
            
            aircraftPerformance = AircraftPerformance(acBd.getAircraftPerformanceFile(aircraftICAOcode))
            aeroDynamics = AeroDynamics(aircraftPerformance, atmosphere, earth)
            
            print aeroDynamics
            for phase in ['CR', 'IC', 'TO', 'AP', 'LD']:
                print 'phase= {0} - Vstall CAS= {1} knots'.format(phase, aeroDynamics.getVstallKcas(phase))
                
            for phase in ['CR', 'IC', 'TO', 'AP', 'LD']:
                print 'phase= {0} - Drag Coeff= {1}'.format(phase, aeroDynamics.getDragCoeff(phase))

            print 'Wing Area Surface={0} Square-meters'.format(aeroDynamics.getWingAreaSurfaceSquareMeters())
    def test_Vstall(self):

        t0 = time.clock()
        print("time start= ", t0)

        atmosphere = Atmosphere()
        earth = Earth()
        print(
            '==================== Stall Speed according to airport field elevation ==================== '
            + time.strftime("%c"))
        acBd = BadaAircraftDatabase()
        aircraftICAOcode = 'B743'
        if acBd.read():
            if (acBd.aircraftExists(aircraftICAOcode)
                    and acBd.aircraftPerformanceFileExists(
                        acBd.getAircraftPerformanceFile(aircraftICAOcode))):

                print(
                    '==================== aircraft found  ==================== '
                    + time.strftime("%c"))
                aircraft = BadaAircraft(
                    ICAOcode=aircraftICAOcode,
                    aircraftFullName=acBd.getAircraftFullName(
                        aircraftICAOcode),
                    badaPerformanceFilePath=acBd.getAircraftPerformanceFile(
                        aircraftICAOcode),
                    atmosphere=atmosphere,
                    earth=earth)
                aircraft.dump()

        print('==================== Airport database ==================== ' +
              time.strftime("%c"))
        airportsDB = AirportsDatabase()
        assert airportsDB.read()
        for airport in airportsDB.getAirports():
            print('============' + airport.getName() + ' ============')
            #print airport
            aircraft = BadaAircraft(
                ICAOcode=aircraftICAOcode,
                aircraftFullName=acBd.getAircraftFullName(aircraftICAOcode),
                badaPerformanceFilePath=acBd.getAircraftPerformanceFile(
                    aircraftICAOcode),
                atmosphere=atmosphere,
                earth=earth)
            print('airport field elevation= {0:.2f} meters'.format(
                airport.getFieldElevationAboveSeaLevelMeters()))
            CAS = aircraft.computeStallSpeedCasKnots()
            print('V stall Calibrated AirSpeed= {0:.2f} knots'.format(CAS))
            TAS = cas2tas(
                cas=CAS,
                altitude=airport.getFieldElevationAboveSeaLevelMeters(),
                temp='std',
                speed_units='kt',
                alt_units='m',
                temp_units=default_temp_units,
            )
            print('V stall True AirSpeed= {0:.2f} knots'.format(TAS))
 def test_Class_One(self):
         
     print '================ test one ===================='
     acBd = BadaAircraftDatabase()
     assert acBd.read()
     
     
     aircraftICAOcode = 'A320'
     if ( acBd.aircraftExists(aircraftICAOcode) and
          acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
         
         print acBd.getAircraftFullName(aircraftICAOcode)
         
         aircraftPerformance = AircraftPerformance(acBd.getAircraftPerformanceFile(aircraftICAOcode))
         aircraftMass = AircraftMass(aircraftPerformance)
    def test_Class_One(self):

        print('================ test one ====================')
        acBd = BadaAircraftDatabase()
        assert acBd.read()

        aircraftICAOcode = 'A320'
        if (acBd.aircraftExists(aircraftICAOcode)
                and acBd.aircraftPerformanceFileExists(aircraftICAOcode)):

            print(acBd.getAircraftFullName(aircraftICAOcode))

            aircraftPerformance = AircraftPerformance(
                acBd.getAircraftPerformanceFile(aircraftICAOcode))
            aircraftMass = AircraftMass(aircraftPerformance)
    def test_Class_Two(self):
        
        print('================ test Two ====================')

        acBd = BadaAircraftDatabase()
        assert acBd.read()
        
        aircraftICAOcode = 'A320'
        if ( acBd.aircraftExists(aircraftICAOcode) and
             acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
            
            print(acBd.getAircraftFullName(aircraftICAOcode))
            
            aircraftPerformance = AircraftPerformance(acBd.getAircraftPerformanceFile(aircraftICAOcode))
            engine = Engine(aircraftPerformance)
            
            print('engine fuel consumption coeff= {0}'.format(engine.getFuelConsumptionCoeff()))
    def test_Class_Two(self):
        
        print '================ test Two ===================='

        acBd = BadaAircraftDatabase()
        assert acBd.read()
        
        aircraftICAOcode = 'A320'
        if ( acBd.aircraftExists(aircraftICAOcode) and
             acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
            
            print acBd.getAircraftFullName(aircraftICAOcode)
            
            aircraftPerformance = AircraftPerformance(acBd.getAircraftPerformanceFile(aircraftICAOcode))
            engine = Engine(aircraftPerformance)
            
            print 'engine fuel consumption coeff= {0}'.format(engine.getFuelConsumptionCoeff())
 def test_Vstall(self):
     
     
     t0 = time.clock()
     print "time start= ", t0
     
     atmosphere = Atmosphere()
     earth = Earth()
     print '==================== Stall Speed according to airport field elevation ==================== '+ time.strftime("%c")
     acBd = BadaAircraftDatabase()
     aircraftICAOcode = 'B743'
     if acBd.read():
         if ( acBd.aircraftExists(aircraftICAOcode) 
              and acBd.aircraftPerformanceFileExists(acBd.getAircraftPerformanceFile(aircraftICAOcode))):
             
             print '==================== aircraft found  ==================== '+ time.strftime("%c")
             aircraft = BadaAircraft(ICAOcode = aircraftICAOcode, 
                                     aircraftFullName = acBd.getAircraftFullName(aircraftICAOcode),
                                     badaPerformanceFilePath = acBd.getAircraftPerformanceFile(aircraftICAOcode),
                                     atmosphere = atmosphere,
                                     earth = earth)
             aircraft.dump()
             
     print '==================== Airport database ==================== '+ time.strftime("%c")
     airportsDB = AirportsDatabase()
     assert airportsDB.read()
     for airport in airportsDB.getAirports():
         print '============' + airport.getName() + ' ============'
         #print airport
         aircraft = BadaAircraft(ICAOcode =  aircraftICAOcode, 
                                     aircraftFullName = acBd.getAircraftFullName(aircraftICAOcode),
                                     badaPerformanceFilePath = acBd.getAircraftPerformanceFile(aircraftICAOcode),
                                     atmosphere = atmosphere,
                                     earth = earth)
         print 'airport field elevation= {0:.2f} meters'.format( airport.getFieldElevationAboveSeaLevelMeters())
         CAS = aircraft.computeStallSpeedCasKnots()
         print 'V stall Calibrated AirSpeed= {0:.2f} knots'.format(CAS) 
         TAS = cas2tas(cas = CAS , 
               altitude = airport.getFieldElevationAboveSeaLevelMeters(),
               temp = 'std',
               speed_units = 'kt',
               alt_units = 'm',
               temp_units=default_temp_units,
               )
         print 'V stall True AirSpeed= {0:.2f} knots'.format(TAS) 
 def test_Class_One(self):
         
     print('================ test one ====================')
     acBd = BadaAircraftDatabase()
     assert acBd.read()
     
     aircraftICAOcode = 'A320'
     if ( acBd.aircraftExists(aircraftICAOcode) and
          acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
         
         print(acBd.getAircraftFullName(aircraftICAOcode))
         
         aircraftPerformance = AircraftPerformance(acBd.getAircraftPerformanceFile(aircraftICAOcode))
         engine = Engine(aircraftPerformance)
         
         print('engine is Jet= {0}'.format(engine.isJet()))
         print('engine is Turbo Prop= {0}'.format(engine.isTurboProp()))
         print( 'engine is Piston= {0}'.format(engine.isPiston()))
         self.assertTrue(engine.isJet(), 'A320 is a jet aircraft')
    def test_Class_Four(self):

        print('================ test Four ====================')

        acBd = BadaAircraftDatabase()
        assert acBd.read()
        
        aircraftICAOcode = 'A320'
        if ( acBd.aircraftExists(aircraftICAOcode) and
             acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
            
            print(acBd.getAircraftFullName(aircraftICAOcode))
            
            aircraftPerformance = AircraftPerformance(acBd.getAircraftPerformanceFile(aircraftICAOcode))
            engine = Engine(aircraftPerformance)
            
            for index in range(0,5):
                print(index)
                print('engine Descent Thrust Coeff= {0}'.format(engine.getDescentThrustCoeff(index)))
    def test_Class_Four(self):

        print '================ test Four ===================='

        acBd = BadaAircraftDatabase()
        assert acBd.read()
        
        aircraftICAOcode = 'A320'
        if ( acBd.aircraftExists(aircraftICAOcode) and
             acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
            
            print acBd.getAircraftFullName(aircraftICAOcode)
            
            aircraftPerformance = AircraftPerformance(acBd.getAircraftPerformanceFile(aircraftICAOcode))
            engine = Engine(aircraftPerformance)
            
            for index in range(0,5):
                print index
                print 'engine Descent Thrust Coeff= {0}'.format(engine.getDescentThrustCoeff(index))
 def test_Class_One(self):
         
     print '================ test one ===================='
     acBd = BadaAircraftDatabase()
     assert acBd.read()
     
     aircraftICAOcode = 'A320'
     if ( acBd.aircraftExists(aircraftICAOcode) and
          acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
         
         print acBd.getAircraftFullName(aircraftICAOcode)
         
         aircraftPerformance = AircraftPerformance(acBd.getAircraftPerformanceFile(aircraftICAOcode))
         engine = Engine(aircraftPerformance)
         
         print 'engine is Jet= {0}'.format(engine.isJet())
         print 'engine is Turbo Prop= {0}'.format(engine.isTurboProp())
         print 'engine is Piston= {0}'.format(engine.isPiston())
         self.assertTrue(engine.isJet(), 'A320 is a jet aircraft')
예제 #18
0
    def test_Class_Three(self):

        print '================ test Three ===================='

        acBd = BadaAircraftDatabase()
        assert acBd.read()

        aircraftICAOcode = 'A320'
        if (acBd.aircraftExists(aircraftICAOcode)
                and acBd.aircraftPerformanceFileExists(aircraftICAOcode)):

            print acBd.getAircraftFullName(aircraftICAOcode)

            aircraftPerformance = AircraftPerformance(
                acBd.getAircraftPerformanceFile(aircraftICAOcode))
            engine = Engine(aircraftPerformance)

            for index in range(0, 5):
                print index
                print 'engine Max Climb Thrust coeff= {0}'.format(
                    engine.getMaxClimbThrustCoeff(index))
 def test_Class_One(self):
     
     print '================ test one ===================='
     acBd = BadaAircraftDatabase()
     assert acBd.read()
     
     atmosphere = Atmosphere()
     earth = Earth()
     
     aircraftICAOcode = 'A320'
     if ( acBd.aircraftExists(aircraftICAOcode) and
          acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
         
         print acBd.getAircraftFullName(aircraftICAOcode)
         
         aircraftPerformance = AircraftPerformance(acBd.getAircraftPerformanceFile(aircraftICAOcode))
         flightEnvelope = FlightEnvelope(aircraftPerformance = aircraftPerformance,
                                         ICAOcode = aircraftICAOcode,
                                         atmosphere = atmosphere,
                                         earth = earth)
         print flightEnvelope
    def getAircraft(self):

        print self.className + ": ================ get aircraft ================="
        atmosphere = Atmosphere()
        earth = Earth()
        acBd = BadaAircraftDatabase()
        assert acBd.read()

        if acBd.aircraftExists(self.aircraftICAOcode) and acBd.aircraftPerformanceFileExists(self.aircraftICAOcode):

            print self.className + ": performance file= {0}".format(
                acBd.getAircraftPerformanceFile(self.aircraftICAOcode)
            )
            self.aircraft = BadaAircraft(
                ICAOcode=self.aircraftICAOcode,
                aircraftFullName=acBd.getAircraftFullName(self.aircraftICAOcode),
                badaPerformanceFilePath=acBd.getAircraftPerformanceFile(self.aircraftICAOcode),
                atmosphere=atmosphere,
                earth=earth,
            )
            self.aircraft.dump()
        else:
            raise ValueError(self.className + ": aircraft not found= " + self.aircraftICAOcode)
    def test_Class_One(self):

        print('================ test one ====================')
        acBd = BadaAircraftDatabase()
        assert acBd.read()

        atmosphere = Atmosphere()
        earth = Earth()

        aircraftICAOcode = 'A320'
        if (acBd.aircraftExists(aircraftICAOcode)
                and acBd.aircraftPerformanceFileExists(aircraftICAOcode)):

            print(acBd.getAircraftFullName(aircraftICAOcode))

            aircraftPerformance = AircraftPerformance(
                acBd.getAircraftPerformanceFile(aircraftICAOcode))
            flightEnvelope = FlightEnvelope(
                aircraftPerformance=aircraftPerformance,
                ICAOcode=aircraftICAOcode,
                atmosphere=atmosphere,
                earth=earth)
            print(flightEnvelope)
예제 #22
0
from Home.BadaAircraftPerformance.BadaAircraftDatabaseFile import BadaAircraftDatabase
from Home.BadaAircraftPerformance.BadaAircraftFile import BadaAircraft

if __name__ == '__main__':

    t0 = time.clock()
    print ( "time start= ", t0 )
    atmosphere = Atmosphere()
    earth = Earth()
    
    print ( '==================== Run-Ways Testing ==================== '+ time.strftime("%c") )
    
    acBd = BadaAircraftDatabase()
    aircraftICAOcode = 'A320'
    if acBd.read():
        if ( acBd.aircraftExists(aircraftICAOcode) 
             and acBd.aircraftPerformanceFileExists(acBd.getAircraftPerformanceFile(aircraftICAOcode))):
            
            print ( '==================== aircraft found  ==================== '+ time.strftime("%c") )
            aircraft = BadaAircraft(aircraftICAOcode, 
                                  acBd.getAircraftPerformanceFile(aircraftICAOcode),
                                  atmosphere,
                                  earth)
            aircraft.dump()
            
    print ( '==================== read Airports Database ==================== '+ time.strftime("%c") )
    airportsDB = AirportsDatabase()
    airport = airportsDB.getAirportFromICAOCode('LFPG')
    
    print ( '====================  find the run-ways ==================== '+ time.strftime("%c") )
class TestTurnLegGreatCircleRoute(unittest.TestCase):
    def setUp(self) -> None:
        self.atmosphere = Atmosphere()
        self.earth = Earth()
        self.acBd = BadaAircraftDatabase()
        self.aircraftICAOcode = 'A320'
        self.deltaTimeSeconds = 1.0

        assert self.acBd.read()
        assert self.acBd.aircraftExists(self.aircraftICAOcode)
        assert self.acBd.aircraftPerformanceFileExists(self.aircraftICAOcode)

        self.aircraft = BadaAircraft(
            ICAOcode=self.aircraftICAOcode,
            aircraftFullName=self.acBd.getAircraftFullName(
                self.aircraftICAOcode),
            badaPerformanceFilePath=self.acBd.getAircraftPerformanceFile(
                self.aircraftICAOcode),
            atmosphere=self.atmosphere,
            earth=self.earth,
            windSpeedMetersPerSecond=None,
            windDirectionDegrees=None)

    def test_turn_leg_fly_by_waypoint(self):
        wayPointsDb = WayPointsDatabase()
        assert (wayPointsDb.read())
        # Exona = wayPointsDb.getWayPoint('EXONA')
        # Rosal = wayPointsDb.getWayPoint('ROSAL')
        # Santa = wayPointsDb.getWayPoint('SANTA')

        p1 = wayPointsDb.getWayPoint('LAMSO')
        p2 = wayPointsDb.getWayPoint('EVELI')
        # p2 = wayPointsDb.getWayPoint('BASNO')
        # p3 = wayPointsDb.getWayPoint('PAMPUS')
        # ret = wayPointsDb.insertWayPoint('ENKOS', "N31°40'58.50" + '"', "N31°40'58.50" + '"')
        # ret = wayPointsDb.insertWayPoint('ENKOS', "N52°40'41.26" + '"', "E5°14'35.75" + '"')
        # if wayPointsDb.hasWayPoint('ENKOS'):
        #     self.assertFalse(ret, 'insertion not done')
        #     exit(1)
        # else:
        #     self.assertTrue(ret, 'insertion correct')
        p3 = wayPointsDb.getWayPoint('ENKOS')

        print(p1)
        print(p2)
        print(p3)
        # print(p4)

        self.aircraft.aircraftCurrentConfiguration = 'cruise'

        self.aircraft.initStateVector(
            elapsedTimeSeconds=0.0,
            trueAirSpeedMetersSecond=70.0,
            airportFieldElevationAboveSeaLevelMeters=10000.0)

        self.aircraft.setTargetCruiseFlightLevel(
            RequestedFlightLevel=310, departureAirportAltitudeMSLmeters=0.0)

        greatCircle = GreatCircleRoute(initialWayPoint=p1,
                                       finalWayPoint=p2,
                                       aircraft=self.aircraft)

        distanceStillToFlyMeters = p1.getDistanceMetersTo(p2)
        greatCircle.computeGreatCircle(
            deltaTimeSeconds=self.deltaTimeSeconds,
            elapsedTimeSeconds=p1.getElapsedTimeSeconds(),
            distanceStillToFlyMeters=distanceStillToFlyMeters,
            distanceToLastFixMeters=distanceStillToFlyMeters)
        finalRoute = greatCircle

        initialHeadingDegrees = p1.getBearingDegreesTo(p2)
        turn_leg = TurnLeg(initialWayPoint=p2,
                           finalWayPoint=p3,
                           initialHeadingDegrees=initialHeadingDegrees,
                           aircraft=self.aircraft,
                           reverse=False)

        last_gc_vertex = finalRoute.getLastVertex().getWeight()
        distance_to_fly = last_gc_vertex.getDistanceMetersTo(p3)
        turn_leg.buildTurnLeg(
            deltaTimeSeconds=self.deltaTimeSeconds,
            elapsedTimeSeconds=last_gc_vertex.getElapsedTimeSeconds(),
            distanceStillToFlyMeters=distance_to_fly,
            distanceToLastFixMeters=distance_to_fly)
        finalRoute.addGraph(turn_leg)

        last_turn_leg_vertex = turn_leg.getLastVertex().getWeight()
        # last_turn_leg_vertex = p2
        greatCircle2 = GreatCircleRoute(initialWayPoint=last_turn_leg_vertex,
                                        finalWayPoint=p3,
                                        aircraft=self.aircraft)
        distanceStillToFlyMeters = last_turn_leg_vertex.getDistanceMetersTo(p3)
        greatCircle2.computeGreatCircle(
            deltaTimeSeconds=self.deltaTimeSeconds,
            elapsedTimeSeconds=last_turn_leg_vertex.getElapsedTimeSeconds(),
            distanceStillToFlyMeters=distanceStillToFlyMeters,
            distanceToLastFixMeters=distanceStillToFlyMeters)
        finalRoute.addGraph(greatCircle2)

        finalRoute.createKmlOutputFile()
        finalRoute.createXlsxOutputFile()
        self.aircraft.createStateVectorOutputFile(
            filePrefix='turn-leg-great-circle')
예제 #24
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")
예제 #25
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 =============== '
    except Exception as e:
        print 'Exception raised= {0}'.format(e)
    greatCircle.createKmlOutputFile()
    greatCircle.createXlsxOutputFile()

if __name__ == '__main__':
    
    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(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()
    def test_TurnLeg(self):

        print '==================== Turn Leg ==================== '+ time.strftime("%c")
        atmosphere = Atmosphere()
        earth = Earth()
        
        acBd = BadaAircraftDatabase()
        aircraftICAOcode = 'A320'
        assert acBd.read()
        assert acBd.aircraftExists(aircraftICAOcode) 
        assert acBd.aircraftPerformanceFileExists(aircraftICAOcode)
                
        print '==================== aircraft found  ==================== '+ time.strftime("%c")
        aircraft = BadaAircraft(ICAOcode = aircraftICAOcode, 
                                aircraftFullName = acBd.getAircraftFullName(aircraftICAOcode),
                                badaPerformanceFilePath = acBd.getAircraftPerformanceFile(aircraftICAOcode),
                                atmosphere = atmosphere,
                                earth = earth)
        aircraft.dump()
                
        print '==================== Get Airport ==================== '+ time.strftime("%c")
        airportsDB = AirportsDatabase()
        assert airportsDB.read()
        
        print '==================== Get Arrival Airport ==================== '+ time.strftime("%c")
        Lisbonne = airportsDB.getAirportFromICAOCode('LPPT')
        print Lisbonne
        
        print '====================  find the run-ways ==================== '+ time.strftime("%c")
        runWaysDatabase = RunWayDataBase()
        if runWaysDatabase.read():
            print 'runways DB correctly read'
            
        print '====================  take off run-way ==================== '+ time.strftime("%c")
        arrivalRunway = runWaysDatabase.getFilteredRunWays(
                                                           airportICAOcode = 'LPPT', 
                                                           runwayName = '')
        print arrivalRunway
        
        print '==================== Ground run ==================== '+ time.strftime("%c")
        groundRun = GroundRunLeg(runway = arrivalRunway, 
                                 aircraft = aircraft,
                                 airport = Lisbonne)
        
        touchDownWayPoint = groundRun.computeTouchDownWayPoint()
        print touchDownWayPoint
        groundRun.buildDepartureGroundRun(deltaTimeSeconds = 1.0,
                                          elapsedTimeSeconds = 0.0,
                                          distanceStillToFlyMeters = 0.0,
                                          distanceToLastFixMeters = 0.0)
        print '==================== Climb Ramp ==================== '+ time.strftime("%c")
        
        initialWayPoint = groundRun.getLastVertex().getWeight()
    
        descentGlideSlope = DescentGlideSlope( runway   = arrivalRunway,
                                                aircraft = aircraft,
                                                arrivalAirport = Lisbonne ,
                                                descentGlideSlopeDegrees = 3.0)
        ''' if there is a fix nearer to 5 nautics of the touch-down then limit size of simulated glide slope '''
    
        descentGlideSlope.buildSimulatedGlideSlope(descentGlideSlopeSizeNautics = 5.0)
        descentGlideSlope.createKmlOutputFile()
        
        firstGlideSlopeWayPoint = descentGlideSlope.getVertex(v=0).getWeight()
    
        print '==================== Climb Ramp ==================== '+ time.strftime("%c")
        initialWayPoint = groundRun.getLastVertex().getWeight()
    
        print ' ================== turn leg end =============== '
        wayPointsDb = WayPointsDatabase()
        assert (wayPointsDb.read())
        Exona = wayPointsDb.getWayPoint('EXONA')
        Rosal = wayPointsDb.getWayPoint('ROSAL')
    
        print Rosal.getBearingDegreesTo(Exona) 
        initialHeadingDegrees = arrivalRunway.getTrueHeadingDegrees()
        
        lastTurnLeg = TurnLeg( initialWayPoint = firstGlideSlopeWayPoint, 
                               finalWayPoint = Exona,
                               initialHeadingDegrees = initialHeadingDegrees, 
                               aircraft = aircraft,
                               reverse = True)
        deltaTimeSeconds = 1.0
        lastTurnLeg.buildNewSimulatedArrivalTurnLeg(deltaTimeSeconds = deltaTimeSeconds,
                                                     elapsedTimeSeconds = 0.0,
                                                     distanceStillToFlyMeters = 0.0,
                                                     simulatedAltitudeSeaLevelMeters = firstGlideSlopeWayPoint.getAltitudeMeanSeaLevelMeters(),
                                                     flightPathAngleDegrees = 3.0)
        lastTurnLeg.createKmlOutputFile()
        descentGlideSlope.addGraph(lastTurnLeg)
        #descentGlideSlope.createXlsxOutputFile()
        descentGlideSlope.createKmlOutputFile()
        
        print ' ================== turn leg end =============== '
    def test_One(self):

        print('=========== main start ==================')
        aircraftICAOcode = 'A320'

        atmosphere = Atmosphere()
        assert (not (atmosphere is None))

        earth = Earth()
        assert (not (earth is None))

        acBd = BadaAircraftDatabase()
        assert acBd.read()

        if (acBd.aircraftExists(aircraftICAOcode)
                and acBd.aircraftPerformanceFileExists(aircraftICAOcode)):

            aircraft = BadaAircraft(
                ICAOcode=aircraftICAOcode,
                aircraftFullName=acBd.getAircraftFullName(aircraftICAOcode),
                badaPerformanceFilePath=acBd.getAircraftPerformanceFile(
                    aircraftICAOcode),
                atmosphere=atmosphere,
                earth=earth)
            aircraft.dump()
        else:
            raise ValueError(': aircraft not found= ' + aircraftICAOcode)

        assert not (aircraft is None)

        print('================ load airports =================')
        airportsDB = AirportsDatabase()
        assert (airportsDB.read())

        adepIcaoCode = 'LFML'

        departureAirport = airportsDB.getAirportFromICAOCode(adepIcaoCode)
        print(': departure airport= ' + str(departureAirport))
        assert not (departureAirport is None)

        print('================ load runways =================')

        runWaysDatabase = RunWayDataBase()
        assert (runWaysDatabase.read())

        print('====================  take off run-way ==================== ')
        departureRunway = runWaysDatabase.getFilteredRunWays(adepIcaoCode)
        print(
            '=========== minimum and maximum aircraft mass ==================')

        minMassKg = aircraft.getMinimumMassKilograms()
        print('aircraft minimum mass: ' + str(minMassKg) + ' kilograms')

        maxMassKg = aircraft.getMaximumMassKilograms()
        print('aircraft maximum mass: ' + str(maxMassKg) + ' kilograms')

        deltaMass = maxMassKg - minMassKg
        massKg = 39000.0
        while (massKg < maxMassKg):

            massKg += 1000.0
            print(
                '==================== set aircraft reference mass ==================== '
            )
            aircraft = BadaAircraft(
                ICAOcode=aircraftICAOcode,
                aircraftFullName=acBd.getAircraftFullName(aircraftICAOcode),
                badaPerformanceFilePath=acBd.getAircraftPerformanceFile(
                    aircraftICAOcode),
                atmosphere=atmosphere,
                earth=earth)

            aircraft.setTargetCruiseFlightLevel(
                310, departureAirport.getFieldElevationAboveSeaLevelMeters())

            print(
                '==================== aircraft reference mass ==================== '
            )
            print('aircraft reference mass= ' + str(massKg) + ' Kilograms')

            aircraft.setAircraftMassKilograms(massKg)
            print(
                '==================== begin of ground run ==================== '
            )
            groundRunLeg = GroundRunLeg(runway=departureRunway,
                                        aircraft=aircraft,
                                        airport=departureAirport)

            groundRunLeg.buildDepartureGroundRun(
                deltaTimeSeconds=0.1,
                elapsedTimeSeconds=0.0,
                distanceStillToFlyMeters=500000.0,
                distanceToLastFixMeters=500000.0)

            groundRunLeg.computeLengthMeters()
            #groundRunLeg.createXlsxOutputFile()

            print(
                '==================== end of ground run ==================== ')
            initialWayPoint = groundRunLeg.getLastVertex().getWeight()

            print(
                '==================== dump aircraft speed profile ==================== '
            )
            aircraft.createStateVectorOutputFile(aircraftICAOcode + "-Mass-" +
                                                 str(massKg))
            print('=========== main end ==================')
예제 #29
0
from Home.OutputFiles.XlsxOutputFile import XlsxOutput

Meter2Feet = 3.2808
Knots2MetersPerSecond = 0.514444444

#============================================
if __name__ == '__main__':

    FileName = "FlightEnvelope.xlsx"
    print("=================== Flight Envelope start======================")

    aircraftIcaoCode = 'A320'

    atmosphere = Atmosphere()
    assert not (atmosphere is None)

    earth = Earth()
    assert not (earth is None)

    acBd = BadaAircraftDatabase()
    assert acBd.read()

    assert acBd.aircraftExists(aircraftIcaoCode)
    assert acBd.aircraftPerformanceFileExists(aircraftIcaoCode)

    aircraft = BadaAircraft(aircraftIcaoCode,
                            acBd.getAircraftFullName(aircraftIcaoCode),
                            acBd.getAircraftPerformanceFile(aircraftIcaoCode),
                            atmosphere, earth)
    aircraft.dump()
 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()
예제 #31
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"))
 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_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")
예제 #34
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.Guidance.FlightPlanFile import FlightPlan
from Home.Guidance.GroundRunLegFile import GroundRunLeg
from Home.Guidance.ClimbRampFile import ClimbRamp
from Home.Guidance.TurnLegFile import TurnLeg
from Home.Guidance.GreatCircleRouteFile import GreatCircleRoute
from Home.Guidance.DescentGlideSlopeFile import DescentGlideSlope

Meter2Feet = 3.2808  # one meter equals 3.28 feet
Meter2NauticalMiles = 0.000539956803  # One Meter = 0.0005 nautical miles
NauticalMiles2Meters = 1852.0
Kilogram2Pounds = 2.20462262  # 1 kilogram = 2.204 lbs

atmosphere = Atmosphere()
earth = Earth()
aircraftDb = BadaAircraftDatabase()
assert aircraftDb.read()


def pairwise(iterable):
    it = iter(iterable)
    a = next(it, None)

    for b in it:
        yield a, b
        a = b


def scan(f, state, it):
    for x in it:
        state = f(state, x)
        yield state