Exemple #1
0
    def __init__(self,
                 runway,
                 aircraft,
                 arrivalAirport,
                 descentGlideSlopeDegrees=3.0):
        '''
        arrival Airport provides the field elevation above sea level in meters
        '''
        self.className = self.__class__.__name__
        Graph.__init__(self)

        assert isinstance(descentGlideSlopeDegrees, float)
        self.descentGlideSlopeDegrees = descentGlideSlopeDegrees

        # sanity check
        assert isinstance(arrivalAirport, Airport)
        self.arrivalAirport = arrivalAirport
        ''' sanity check RunWay '''
        assert isinstance(runway, RunWay)
        self.runway = runway

        assert isinstance(aircraft, BadaAircraft)
        self.aircraft = aircraft

        fieldElevationAboveSeaLevelMeters = arrivalAirport.getFieldElevationAboveSeaLevelMeters(
        )
        print(self.className +
              ': airport field Elevation Above Sea Level= {0:.2f} meters'.
              format(fieldElevationAboveSeaLevelMeters))

        strName = arrivalAirport.getName(
        ) + '-' + 'RunWay' + '-' + self.runway.getName()
        self.runWayEndPoint = WayPoint(
            Name=strName,
            LatitudeDegrees=runway.getLatitudeDegrees(),
            LongitudeDegrees=runway.getLongitudeDegrees(),
            AltitudeMeanSeaLevelMeters=fieldElevationAboveSeaLevelMeters)
        ''' touch down is provided from BADA Ground Movement Landing Length '''
        landingDistanceMeters = self.aircraft.groundMovement.getLandingLengthMeters(
        )
        #print self.className + ': {0} aircraft landing length: {1:.2F} meters'.format(self.aircraft.ICAOcode, landingDistanceMeters)
        runWayOrientationDegrees = self.runway.getTrueHeadingDegrees()
        ''' if orientation is 270 degrees from runway end point then ... touch down bearing is 360-270=90 bearing from end point '''
        self.runWayTouchDownPoint = self.runWayEndPoint.getWayPointAtDistanceBearing(
            Name='runway-touch-down',
            DistanceMeters=landingDistanceMeters,
            BearingDegrees=runWayOrientationDegrees)
        ''' elevation of touch down point = field elevation'''
        self.runWayTouchDownPoint.setAltitudeMeanSeaLevelMeters(
            fieldElevationAboveSeaLevelMeters)
        strMsg = "{0} - distance from RunWay - TouchDown to RunWay - End= {1:.2f} meters".format(
            self.className,
            self.runWayTouchDownPoint.getDistanceMetersTo(self.runWayEndPoint))
        print(strMsg)

        self.bearingDegrees = self.runWayTouchDownPoint.getBearingDegreesTo(
            self.runWayEndPoint)
        print(self.className +
              ": bearing from touch-down to runway end= {0:.2f} degrees".
              format(self.bearingDegrees))
    def __init__(self, initialWayPoint, finalWayPoint, aircraft):
        ''' init base class '''
        Graph.__init__(self)
        self.className = self.__class__.__name__
        self.climbRampAngleDegrees = 8.0

        assert (isinstance(initialWayPoint, WayPoint)) and (isinstance(
            finalWayPoint, WayPoint))

        self.initialWayPoint = initialWayPoint
        self.finalWayPoint = finalWayPoint

        assert (isinstance(aircraft, BadaAircraft))
        self.aircraft = aircraft
        ''' sanity checks '''
        ptlon1 = initialWayPoint.getLongitudeDegrees()
        assert (ptlon1 >= -180.) and (ptlon1 <= 180.)
        ''' sanity checks '''
        ptlat1 = initialWayPoint.getLatitudeDegrees()
        assert (ptlat1 >= -90.0) and (ptlat1 <= 90.)
        ''' sanity checks '''
        ptlon2 = finalWayPoint.getLongitudeDegrees()
        assert (ptlon2 >= -180.) and (ptlon2 <= 180.)
        ''' sanity checks '''
        ptlat2 = finalWayPoint.getLatitudeDegrees()
        assert (ptlat2 >= -90.0) and (ptlat2 <= 90.)

        self.ptlon1_radians = math.radians(ptlon1)
        self.ptlat1_radians = math.radians(ptlat1)
        self.ptlon2_radians = math.radians(ptlon2)
        self.ptlat2_radians = math.radians(ptlat2)
    def __init__(self, 
                 runway, 
                 aircraft, 
                 arrivalAirport , 
                 descentGlideSlopeDegrees = 3.0):
        '''
        arrival Airport provides the field elevation above sea level in meters
        '''
        self.className = self.__class__.__name__
        Graph.__init__(self)
        
        assert isinstance(descentGlideSlopeDegrees, float)
        self.descentGlideSlopeDegrees = descentGlideSlopeDegrees
        
        # sanity check 
        assert isinstance(arrivalAirport, Airport)
        self.arrivalAirport = arrivalAirport

        ''' sanity check RunWay '''
        assert isinstance(runway, RunWay)
        self.runway = runway
            
        assert isinstance(aircraft, BadaAircraft)
        self.aircraft = aircraft
        
        fieldElevationAboveSeaLevelMeters = arrivalAirport.getFieldElevationAboveSeaLevelMeters()
        print self.className + ': airport field Elevation Above Sea Level= {0:.2f} meters'.format(fieldElevationAboveSeaLevelMeters)

        strName = arrivalAirport.getName() + '-' + 'RunWay'+'-'+self.runway.getName()
        self.runWayEndPoint = WayPoint (Name=strName, 
                                            LatitudeDegrees=runway.getLatitudeDegrees(),
                                            LongitudeDegrees=runway.getLongitudeDegrees(),
                                            AltitudeMeanSeaLevelMeters=fieldElevationAboveSeaLevelMeters)
 
        ''' touch down is provided from BADA Ground Movement Landing Length '''
        landingDistanceMeters = self.aircraft.groundMovement.getLandingLengthMeters()
        #print self.className + ': {0} aircraft landing length: {1:.2F} meters'.format(self.aircraft.ICAOcode, landingDistanceMeters)
        runWayOrientationDegrees = self.runway.getTrueHeadingDegrees()
        ''' if orientation is 270 degrees from runway end point then ... touch down bearing is 360-270=90 bearing from end point '''
        self.runWayTouchDownPoint = self.runWayEndPoint.getWayPointAtDistanceBearing(Name='runway-touch-down',
                                                                          DistanceMeters=landingDistanceMeters,
                                                                          BearingDegrees=runWayOrientationDegrees )
        
        ''' elevation of touch down point = field elevation'''
        self.runWayTouchDownPoint.setAltitudeMeanSeaLevelMeters(fieldElevationAboveSeaLevelMeters)
        strMsg = self.className + ": distance from RunWay - TouchDown to RunWay - End= "
        strMsg += str(self.runWayTouchDownPoint.getDistanceMetersTo(self.runWayEndPoint)) + " meters"
        print strMsg
        
        self.bearingDegrees = self.runWayTouchDownPoint.getBearingDegreesTo(self.runWayEndPoint)
        print self.className + ": bearing from touch-down to runway end= {0:.2f} degrees".format(self.bearingDegrees)
 def test_graph_two_vertexs(self):
     g1 = Graph()
     v1 = Vertex('Robert')
     v2 = Vertex('Francois')
     g1.addVertex(v1)
     g1.addVertex(v2)
     print('number of vertices: {0}'.format(g1.getNumberOfVertices()))
     self.assertEqual(g1.getNumberOfVertices(), 2)
     print('number of edges: {0}'.format(g1.getNumberOfEdges()))
     self.assertEqual(g1.getNumberOfEdges(), 1)
     print(g1.getLastVertex().getWeight())
Exemple #5
0
    def __init__(self, runway, aircraft, airport):
        ''' base class init '''
        Graph.__init__(self)
        self.className = self.__class__.__name__

        assert (isinstance(runway, RunWay) and not (runway is None))
        self.runway = runway
        print(self.className + ': ground run - run-way true heading= ' +
              str(self.runway.getTrueHeadingDegrees()) + ' degrees')

        assert (isinstance(aircraft, BadaAircraft) and not (aircraft is None))
        self.aircraft = aircraft

        assert (isinstance(airport, Airport) and not (airport is None))
        self.airport = airport
 def test_graph_one_vertex(self):
     g1 = Graph()
     print('empty graph= ', g1)
     self.assertEqual(str(g1), 'Graph: number of vertices= 0')
     v1 = Vertex('Robert')
     g1.addVertex(v1)
     print(g1)
     self.assertEqual(str(g1), 'Graph: number of vertices= 1')
     print('number of vertices: {0}'.format(g1.getNumberOfVertices()))
     self.assertEqual(g1.getNumberOfVertices(), 1)
     print(g1.getLastVertex().getWeight())
     self.assertEqual(str(g1.getLastVertex().getWeight()),
                      'Vertex: vertex= Robert')
     print(g1.getVertex(0).getWeight())
     self.assertEqual(str(g1.getVertex(0).getWeight()),
                      'Vertex: vertex= Robert')
 def __init__(self,
              runway,
              aircraft,
              airport):
         
     ''' base class init '''
     Graph.__init__(self)
     self.className = self.__class__.__name__
     
     assert (isinstance(runway, RunWay) and not(runway is None))
     self.runway = runway
     print self.className + ': ground run - run-way true heading= ' + str(self.runway.getTrueHeadingDegrees()) + ' degrees'
     
     assert (isinstance(aircraft, BadaAircraft) and not(aircraft is None))
     self.aircraft = aircraft
     
     assert (isinstance(airport, Airport)  and not(airport is None))
     self.airport = airport
    def __init__(self, 
                 initialWayPoint,   
                 finalWayPoint, 
                 aircraft):
                
        ''' init base class '''
        Graph.__init__(self)
        self.className = self.__class__.__name__
        self.climbRampAngleDegrees = 8.0
                
        assert (isinstance(initialWayPoint, WayPoint)) and (isinstance(finalWayPoint, WayPoint))
        
        self.initialWayPoint = initialWayPoint
        self.finalWayPoint = finalWayPoint
        
        assert (isinstance(aircraft, BadaAircraft))
        self.aircraft = aircraft
        
        ''' sanity checks '''
        ptlon1 = initialWayPoint.getLongitudeDegrees()
        assert (ptlon1 >= -180.) and (ptlon1 <= 180.)
        
        ''' sanity checks '''
        ptlat1 = initialWayPoint.getLatitudeDegrees()
        assert (ptlat1 >= -90.0) and (ptlat1 <= 90.)
        
        ''' sanity checks '''
        ptlon2 = finalWayPoint.getLongitudeDegrees()
        assert  (ptlon2 >= -180.) and (ptlon2 <= 180.)
        
        ''' sanity checks '''
        ptlat2 = finalWayPoint.getLatitudeDegrees()
        assert (ptlat2 >= -90.0) and (ptlat2 <= 90.)

        self.ptlon1_radians = math.radians(ptlon1)
        self.ptlat1_radians = math.radians(ptlat1)
        self.ptlon2_radians = math.radians(ptlon2)
        self.ptlat2_radians = math.radians(ptlat2)
Exemple #9
0
    def __init__(self,
                 initialWayPoint=None,
                 runway=None,
                 aircraft=None,
                 departureAirport=None):
        ''' base class init '''
        Graph.__init__(self)

        self.className = self.__class__.__name__

        assert isinstance(initialWayPoint, WayPoint)
        self.initialWayPoint = initialWayPoint

        assert isinstance(runway, RunWay) and (not (runway is None))
        self.runway = runway

        assert not (departureAirport is None)
        assert isinstance(departureAirport, Airport)
        self.departureAirport = departureAirport

        assert isinstance(aircraft, BadaAircraft)
        self.aircraft = aircraft
        ''' everything is OKay to start '''
    def __init__(self,
                 initialWayPoint = None,
                 runway = None, 
                 aircraft = None, 
                 departureAirport = None):
        
        ''' base class init '''
        Graph.__init__(self)

        self.className = self.__class__.__name__
        
        assert isinstance(initialWayPoint, WayPoint)
        self.initialWayPoint = initialWayPoint
        
        assert isinstance(runway , RunWay) and (not(runway is None))
        self.runway = runway

        assert not(departureAirport is None)
        assert isinstance(departureAirport, Airport)
        self.departureAirport = departureAirport
        
        assert isinstance(aircraft, BadaAircraft)
        self.aircraft = aircraft
        ''' everything is OKay to start '''
Exemple #11
0
    def __init__(self,
                 initialWayPoint,
                 finalWayPoint,
                 initialHeadingDegrees,
                 aircraft,
                 reverse=False):
        '''
        initial way point is the end of the previous great circle
        initial Heading is the last heading of the previous great circle
        final way point is the next fix
        '''

        Graph.__init__(self)
        self.className = self.__class__.__name__
        ''' link between time step of one second and 3 degrees per second turn rate '''
        ''' 3 degrees per second * 120 seconds = 360 degrees in 2 minutes '''
        self.BaseStepDegrees = 3.0

        assert (reverse == True) or (reverse == False)
        self.reverse = reverse
        ''' sanity check initialWayPoint ''' '''''' ''
        assert (isinstance(initialWayPoint, WayPoint))
        self.initialWayPoint = initialWayPoint
        ''' sanity check finalWayPoint ''' '''''' ''
        assert (isinstance(finalWayPoint, WayPoint))
        self.finalWayPoint = finalWayPoint
        ''' sanity check initialHeadingDegrees ''' '''''' ''
        assert isinstance(initialHeadingDegrees, float)
        assert (initialHeadingDegrees >= 0.0)
        assert (initialHeadingDegrees <= 360.0)
        self.initialHeadingDegrees = initialHeadingDegrees
        ''' sanity check final Heading Degrees '''
        if reverse == True:
            ''' build a turn backwards from last glide slope point to last fix '''
            ''' initial is first glide slope point and final is the last fix of the route '''
            self.finalHeadingDegrees = self.finalWayPoint.getBearingDegreesTo(
                self.initialWayPoint)
            self.finalHeadingDegrees = math.fmod(
                self.finalHeadingDegrees + 180.0, 360.0)
        else:
            self.finalHeadingDegrees = initialWayPoint.getBearingDegreesTo(
                finalWayPoint)
        ''' sanity checks '''
        assert (self.finalHeadingDegrees >= 0.0)
        assert (self.finalHeadingDegrees <= 360.0)
        ''' sanity check aircraft ''' '''''' ''
        assert (isinstance(aircraft, BadaAircraft))
        self.aircraft = aircraft
        ''' compute angle difference '''
        # print self.className + ': turn from= {0:.2f} degrees to {1:.2f} degrees'.format(self.initialHeadingDegrees, self.finalHeadingDegrees)
        ''' default value - for turn angle steps '''
        self.stepDegrees = self.BaseStepDegrees  # degrees
        ''' turn clock wise or anti clock wise '''
        initialAngleRadians = math.radians(self.initialHeadingDegrees)
        finalAngleRadians = math.radians(self.finalHeadingDegrees)
        angleDifferenceDegrees = math.degrees(
            math.atan2(math.sin(finalAngleRadians - initialAngleRadians),
                       math.cos(finalAngleRadians - initialAngleRadians)))
        if (angleDifferenceDegrees < 0.0):
            self.stepDegrees = -self.BaseStepDegrees
        else:
            self.stepDegrees = +self.BaseStepDegrees

        strMsg = ': turn from= {0:.2f} degrees '.format(
            self.initialHeadingDegrees)
        strMsg += ' to {0:.2f} degrees'.format(self.finalHeadingDegrees)
        strMsg += ' - turn step is= {0:.2f} degrees'.format(self.stepDegrees)

        print(self.className + strMsg)
        self.previousDistanceToArrivalAxisMeters = 0.0
    def __init__(self, 
                 initialWayPoint, 
                 finalWayPoint,
                 initialHeadingDegrees, 
                 aircraft,
                 reverse=False):
        '''
        initial way point is the end of the previous great circle
        initial Heading is the last heading of the previous great circle
        final way point is the next fix
        '''
        
        Graph.__init__(self)
        self.className = self.__class__.__name__
        
        ''' link between time step of one second and 3 degrees per second turn rate '''
        ''' 3 degrees per second * 120 seconds = 360 degrees in 2 minutes '''
        self.BaseStepDegrees = 3.0
        
        assert (reverse == True) or (reverse == False)
        self.reverse = reverse
                
        ''' sanity check initialWayPoint '''''''''''
        assert (isinstance(initialWayPoint, WayPoint))
        self.initialWayPoint = initialWayPoint

        ''' sanity check finalWayPoint '''''''''''
        assert (isinstance(finalWayPoint, WayPoint))
        self.finalWayPoint = finalWayPoint

        ''' sanity check initialHeadingDegrees '''''''''''
        assert isinstance(initialHeadingDegrees, float)
        assert (initialHeadingDegrees >= 0.0)
        assert (initialHeadingDegrees <= 360.0)
        self.initialHeadingDegrees = initialHeadingDegrees
        
        ''' sanity check final Heading Degrees '''
        if reverse == True:
            ''' build a turn backwards from last glide slope point to last fix ''' 
            ''' initial is first glide slope point and final is the last fix of the route '''
            self.finalHeadingDegrees = self.finalWayPoint.getBearingDegreesTo(self.initialWayPoint)
            self.finalHeadingDegrees = math.fmod ( self.finalHeadingDegrees + 180.0 , 360.0 )
        else:
            self.finalHeadingDegrees = initialWayPoint.getBearingDegreesTo(finalWayPoint)
            
        ''' sanity checks '''
        assert (self.finalHeadingDegrees >= 0.0) 
        assert (self.finalHeadingDegrees <= 360.0)
        
        ''' sanity check aircraft '''''''''''
        assert (isinstance(aircraft, BadaAircraft))
        self.aircraft = aircraft
                
        ''' compute angle difference '''
        #print self.className + ': turn from= {0:.2f} degrees to {1:.2f} degrees'.format(self.initialHeadingDegrees, self.finalHeadingDegrees)
        
        ''' default value - for turn angle steps '''
        self.stepDegrees = self.BaseStepDegrees # degrees

        ''' turn clock wise or anti clock wise '''
        initialAngleRadians = math.radians(self.initialHeadingDegrees)
        finalAngleRadians = math.radians(self.finalHeadingDegrees)
        angleDifferenceDegrees = math.degrees(math.atan2(math.sin(finalAngleRadians-initialAngleRadians), math.cos(finalAngleRadians-initialAngleRadians)))
        if (angleDifferenceDegrees < 0.0):
            self.stepDegrees = - self.BaseStepDegrees
        else:
            self.stepDegrees = + self.BaseStepDegrees
        
        strMsg = ': turn from= {0:.2f} degrees '.format(self.initialHeadingDegrees)
        strMsg += ' to {0:.2f} degrees'.format(self.finalHeadingDegrees)
        strMsg += ' - turn step is= {0:.2f} degrees'.format(self.stepDegrees) 
                                                
        print self.className + strMsg
        self.previousDistanceToArrivalAxisMeters = 0.0
    def test_graph_with_airport(self):

        print(" ========== AirportsDatabase testing ======= time start= ")
        airportsDb = AirportsDatabase()
        assert (airportsDb.read())

        airportsDb.dumpCountry(Country="France")
        print("number of airports= ", airportsDb.getNumberOfAirports())

        for ap in [
                'Orly', 'paris', 'toulouse', 'marseille', 'roissy', 'blagnac',
                'provence', 'de gaulle'
        ]:
            print("ICAO Code of= ", ap, " ICAO code= ",
                  airportsDb.getICAOCode(ap))

        t1 = time.clock()
        print(" ========== AirportsDatabase testing ======= time start= ", t1)
        CharlesDeGaulleRoissy = airportsDb.getAirportFromICAOCode('LFPG')
        print(CharlesDeGaulleRoissy)
        MarseilleMarignane = airportsDb.getAirportFromICAOCode('LFML')
        print(MarseilleMarignane)

        g0 = Graph()
        for icao in ['LFPO', 'LFMY', 'LFAT', 'LFGJ']:
            airport = airportsDb.getAirportFromICAOCode(icao)
            g0.addVertex(airport)
        print('================ g0 =================')
        for node in g0.getVertices():
            print(node)
        self.assertEqual(g0.getNumberOfVertices(), 4)

        g1 = Graph()
        for icao in ['LFKC', 'LFBO', 'LFKB']:
            airport = airportsDb.getAirportFromICAOCode(icao)
            g1.addVertex(airport)
        self.assertEqual(g1.getNumberOfVertices(), 3)

        print('================ g1 =================')
        for node in g1.getVertices():
            print(node)

        print(' ============== g0.add_graph(g1) ===============')
        g0.addGraph(g1)
        for node in g0.getVertices():
            print(node)

        self.assertEqual(g0.getNumberOfVertices(), 7)

        print('============== g0.create XLS file ===============')

        g0.createXlsxOutputFile()
        g0.createKmlOutputFile()
    def test_graph_three_vertexs(self):

        g2 = Graph()
        v3 = Vertex('Marie')
        g2.addVertex(v3)

        g1 = Graph()
        v1 = Vertex('Robert')
        v2 = Vertex('Francois')
        g1.addVertex(v1)
        g1.addVertex(v2)

        g1.addGraph(g2)
        print(g1)
        self.assertEqual(g1.getNumberOfVertices(), 3)

        for vertex in g1.getVertices():
            print(vertex)
        print("=================")
        for edge in g1.getEdges():
            print(edge.getTail(), edge.getHead())
    def test_performance_graph_with_airport(self):

        airportsDb = AirportsDatabase()
        assert (airportsDb.read())

        print(' ============== g3 performance ===============')
        t0 = time.process_time()
        g3 = Graph()
        count = 0
        for airport in airportsDb.getAirports():
            print(airport)
            g3.addVertex(airport)
            count += 1
        t1 = time.process_time()
        print('number of airports= {0} - duration= {1} seconds'.format(
            count, t1 - t0))
        self.assertEqual(g3.getNumberOfVertices(), count)

        g3.createXlsxOutputFile()
        g3.createKmlOutputFile()

        print(' ============== g4 performance ===============')
        airport = airportsDb.getAirportFromICAOCode('LFPG')
        t2 = time.process_time()
        g4 = Graph()
        for i in range(0, 10000):
            g4.addVertex(airport)
        t3 = time.process_time()
        print('number of addVertex = {0} - duration= {1:.8f} seconds'.format(
            i, t3 - t2))