print('==================== find the run-ways ==================== ') runWaysDB = RunWayDataBase() if runWaysDB.read(): print('runways DB correctly read') else: raise ValueError('runways not read correctly') print('==================== find the run-ways ==================== ') for arrivalRunway in runWaysDB.getRunWays(): print('==================== run-way ==================== ') print(arrivalRunway) airportIcaoCode = arrivalRunway.getAirportICAOcode() airport = airportsDb.getAirportFromICAOCode(airportIcaoCode) print('==================== airport ==================== ') print(airport) climbRamp = ClimbRamp(runway=arrivalRunway, aircraft=acA320, departureAirport=airport) climbRamp.buildClimbRamp() climbRamp.createXlsxOutputFile() descentSlope = DescentGlideSlope(runway=arrivalRunway, aircraft=acA320, arrivalAirport=airport) descentSlope.buildGlideSlope() descentSlope.createXlsxOutputFile()
print('simulation start= {0} seconds'.format(t0)) print('=========== simulation start ==================') endOfSimulation = False currentPosition = departureAirport arrivalGroundRun = GroundRunLeg(runway=arrivalRunway, aircraft=aircraft, airport=arrivalAirport) touchDownWayPoint = arrivalGroundRun.computeTouchDownWayPoint() print(touchDownWayPoint) print( '===================== final 3 degrees descending glide slope ================' ) descentGlideSlope = DescentGlideSlope(runway=arrivalRunway, aircraft=aircraft, arrivalAirport=arrivalAirport, descentGlideSlopeDegrees=3.0) ''' if there is a fix nearer to 5 nautics of the touch-down then limit size of simulated glide slope ''' descentGlideSlopeSizeNautics = 5.0 descentGlideSlope.buildSimulatedGlideSlope(descentGlideSlopeSizeNautics) firstGlideSlopeWayPoint = descentGlideSlope.getVertex(v=0).getWeight() aircraft.setTargetApproachWayPoint(firstGlideSlopeWayPoint) aircraft.setArrivalRunwayTouchDownWayPoint(touchDownWayPoint) distanceStillToFlyMeters = departureAirport.getDistanceMetersTo( arrivalAirport) print('distance still To Fly Meters= {0:.2f} meters'.format( distanceStillToFlyMeters)) index = 0
arrivalAirport.fieldElevationAboveSeaLevelMeters) print( '=========== add final turn, descent and ground run ===================' ) arrivalGroundRun = GroundRunLeg(runway=arrivalRunway, aircraft=aircraft, airport=arrivalAirport) touchDownWayPoint = arrivalGroundRun.computeTouchDownWayPoint() print(touchDownWayPoint) print( '===================== final 3 degrees descending glide slope ================' ) dummyDescentGlideSlope = DescentGlideSlope(runway=arrivalRunway, aircraft=aircraft, arrivalAirport=arrivalAirport, descentGlideSlopeDegrees=3.0) dummyDescentGlideSlope.buildSimulatedGlideSlope() firstGlideSlopeWayPoint = dummyDescentGlideSlope.getVertex(v=0).getWeight() print('=============== init aircraft state vector =================') casKnots = 107.0 casMetersPerSecond = casKnots * Knots2MetersPerSecond tasMetersPerSecond = atmosphere.cas2tas(casMetersPerSecond, 950.0, speed_units='m/s', altitude_units='m') elapsedTimeSeconds = 0.0 aircraft.initStateVector(
def buildSimulatedArrivalPhase(self): print( self.className + '=========== add final turn, descent and ground run ===================' ) arrivalGroundRun = GroundRunLeg(runway=self.arrivalRunway, aircraft=self.aircraft, airport=self.arrivalAirport) self.touchDownWayPoint = arrivalGroundRun.computeTouchDownWayPoint() # add touch down to constraint list self.constraintsList.append( ArrivalRunWayTouchDownConstraint(self.touchDownWayPoint)) print(self.touchDownWayPoint) ''' distance from last fix to touch down ''' distanceToLastFixNautics = self.touchDownWayPoint.getDistanceMetersTo( self.getLastWayPoint()) * Meter2NauticalMiles print( self.className + '===================== final 3 degrees descending glide slope ================' ) descentGlideSlope = DescentGlideSlope( runway=self.arrivalRunway, aircraft=self.aircraft, arrivalAirport=self.arrivalAirport, descentGlideSlopeDegrees=3.0) ''' if there is a fix nearer to 5 nautics of the touch-down then limit size of simulated glide slope ''' descentGlideSlopeSizeNautics = min(distanceToLastFixNautics / 2.0, 5.0) ''' build simulated glide slope ''' descentGlideSlope.buildSimulatedGlideSlope( descentGlideSlopeSizeNautics) self.firstGlideSlopeWayPoint = descentGlideSlope.getVertex( v=0).getWeight() print(self.className + ': top of arrival glide slope= {0}'.format( self.firstGlideSlopeWayPoint)) print( self.className + ' ================= need a turn leg to find the junction point the last way-point in the fix list to the top of the final glide slope' ) ''' initial heading is the orientation of the run-way ''' lastFixListWayPoint = self.wayPointsDict[self.fixList[-1]] initialHeadingDegrees = self.arrivalRunway.getTrueHeadingDegrees() print("=====> arrival runway - true heading degrees = {0}".format( initialHeadingDegrees)) lastTurnLeg = TurnLeg(initialWayPoint=self.firstGlideSlopeWayPoint, finalWayPoint=lastFixListWayPoint, initialHeadingDegrees=initialHeadingDegrees, aircraft=self.aircraft, reverse=True) lastTurnLeg.buildNewSimulatedArrivalTurnLeg( deltaTimeSeconds=self.deltaTimeSeconds, elapsedTimeSeconds=0.0, distanceStillToFlyMeters=0.0, simulatedAltitudeSeaLevelMeters=self.firstGlideSlopeWayPoint. getAltitudeMeanSeaLevelMeters(), flightPathAngleDegrees=3.0, bankAngleDegrees=5.0) descentGlideSlope.addGraph(lastTurnLeg) #print self.className + ': compute arrival phase length= {0:.2f} meters'.format(descentGlideSlope.getLengthMeters()) #descentGlideSlope.createXlsxOutputFile() #descentGlideSlope.createKmlOutputFile() ''' prepare next step ''' beginOfLastTurnLeg = lastTurnLeg.getVertex(v=0).getWeight() print(self.className + ': begin of last turn= {0}'.format(beginOfLastTurnLeg)) ''' add to constraint list ''' self.constraintsList.append( TargetApproachConstraint(beginOfLastTurnLeg)) ''' add the three last way-points in the fix list ''' self.insert(position='end', wayPoint=beginOfLastTurnLeg) ''' update the length of the flight path ''' self.distanceFromApproachToTouchDownMeters = descentGlideSlope.getLengthMeters( ) self.flightLengthMeters = self.computeLengthMeters( ) + descentGlideSlope.getLengthMeters() print(self.className + ': updated flight path length= {0:.2f} nautics'.format( self.flightLengthMeters * Meter2NauticalMiles)) ''' target approach fix is equal to the begin of the SIMULATED last turn leg ''' self.aircraft.setTargetApproachWayPoint(beginOfLastTurnLeg) self.aircraft.setArrivalRunwayTouchDownWayPoint(self.touchDownWayPoint) print(self.className + ': fix list= {0}'.format(self.fixList))
def buildArrivalPhase(self, initialHeadingDegrees): print( self.className + ': initial heading= {0:.2f} degrees'.format(initialHeadingDegrees)) print(self.className + '==================== add last turn ==================== ') if self.isDomestic() or self.isInBound(): endOfLastGreatCircleWayPoint = self.finalRoute.getLastVertex( ).getWeight() finalHeadingDegrees = self.arrivalRunway.getTrueHeadingDegrees() finalHeadingDegrees = math.fmod(finalHeadingDegrees + 180.0, 360.0) print(self.className + ': runway final heading= {0:.2f} degrees'.format( finalHeadingDegrees)) turnLeg = TurnLeg( initialWayPoint=endOfLastGreatCircleWayPoint, #finalWayPoint = self.firstGlideSlopeWayPoint, finalWayPoint=self.touchDownWayPoint, initialHeadingDegrees=initialHeadingDegrees, aircraft=self.aircraft, reverse=False) distanceStillToFlyMeters = self.flightLengthMeters - self.finalRoute.getLengthMeters( ) distanceToLastFixMeters = self.computeDistanceToLastFixMeters( currentPosition=endOfLastGreatCircleWayPoint, fixListIndex=self.flightListIndex) distanceToLastFixMeters = distanceStillToFlyMeters ''' for the last turn => final heading towards the runway orientation ''' deltaTimeSeconds = 0.1 turnLeg.buildTurnLeg( deltaTimeSeconds=deltaTimeSeconds, elapsedTimeSeconds=endOfLastGreatCircleWayPoint. getElapsedTimeSeconds(), distanceStillToFlyMeters=distanceStillToFlyMeters, distanceToLastFixMeters=distanceToLastFixMeters, finalHeadingDegrees=finalHeadingDegrees, lastTurn=True, bankAngleDegrees=5.0, arrivalRunway=self.arrivalRunway) self.finalRoute.addGraph(turnLeg) endOfTurnLegWayPoint = self.finalRoute.getLastVertex().getWeight() ''' ============= use touch-down way-point to compute distance to fly =============''' distanceStillToFlyMeters = endOfTurnLegWayPoint.getDistanceMetersTo( self.touchDownWayPoint) print(self.className + ': distance still to fly= {0:.2f} nautics'.format( distanceStillToFlyMeters * Meter2NauticalMiles)) #print '==================== add descent slope ================= ' descentGlideSlope = DescentGlideSlope( runway=self.arrivalRunway, aircraft=self.aircraft, arrivalAirport=self.arrivalAirport, descentGlideSlopeDegrees=3.0) flownDistanceMeters = self.finalRoute.getLengthMeters() distanceStillToFlyMeters = self.flightLengthMeters - self.finalRoute.getLengthMeters( ) distanceToLastFixMeters = self.computeDistanceToLastFixMeters( currentPosition=endOfTurnLegWayPoint, fixListIndex=self.flightListIndex) distanceToLastFixMeters = distanceStillToFlyMeters descentGlideSlope.buildGlideSlope( deltaTimeSeconds=self.deltaTimeSeconds, elapsedTimeSeconds=endOfTurnLegWayPoint.getElapsedTimeSeconds( ), initialWayPoint=endOfTurnLegWayPoint, flownDistanceMeters=flownDistanceMeters, distanceStillToFlyMeters=distanceStillToFlyMeters, distanceToLastFixMeters=distanceToLastFixMeters) self.finalRoute.addGraph(descentGlideSlope) endOfDescentGlideSlope = self.finalRoute.getLastVertex().getWeight( ) #print '================= add arrival ground run ================' arrivalGroundRun = GroundRunLeg(runway=self.arrivalRunway, aircraft=self.aircraft, airport=self.arrivalAirport) arrivalGroundRun.buildArrivalGroundRun( deltaTimeSeconds=self.deltaTimeSeconds, elapsedTimeSeconds=endOfDescentGlideSlope. getElapsedTimeSeconds(), initialWayPoint=endOfDescentGlideSlope) self.finalRoute.addGraph(arrivalGroundRun)
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) print( "=========== Three Degrees Descent GlideSlope constructor =========== " + time.strftime("%c")) threeDegreesDescentGlideSlope = DescentGlideSlope(arrivalRunway, aircraft, arrivalAirport) threeDegreesDescentGlideSlope.buildGlideSlope() finalVertex = threeDegreesDescentGlideSlope.getVertex( threeDegreesDescentGlideSlope.getNumberOfVertices() - 1) finalArrivalDescentSlopeWayPoint = finalVertex.getWeight() print(finalArrivalDescentSlopeWayPoint) initialVertex = threeDegreesDescentGlideSlope.getVertex(0) initialArrivalDescentSlopeWayPoint = initialVertex.getWeight() print("=========== initial Arrival Descent Slope Way Point =========== " + time.strftime("%c")) print('altitude of initial arrival Descent Slope Way Point= ' + str( initialArrivalDescentSlopeWayPoint.getAltitudeMeanSeaLevelMeters()) + ' meters')
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 buildArrivalPhase(self, initialHeadingDegrees): print self.className + "==================== add last turn ==================== " if self.isDomestic() or self.isInBound(): endOfLastGreatCircleWayPoint = self.finalRoute.getLastVertex().getWeight() finalHeadingDegrees = self.arrivalRunway.getTrueHeadingDegrees() finalHeadingDegrees = math.fmod(finalHeadingDegrees + 180.0, 360.0) print self.className + ": runway final heading= {0:.2f} degrees".format(finalHeadingDegrees) turnLeg = TurnLeg( initialWayPoint=endOfLastGreatCircleWayPoint, # finalWayPoint = self.firstGlideSlopeWayPoint, finalWayPoint=self.touchDownWayPoint, initialHeadingDegrees=initialHeadingDegrees, aircraft=self.aircraft, reverse=False, ) distanceStillToFlyMeters = self.flightLengthMeters - self.finalRoute.getLengthMeters() distanceToLastFixMeters = self.computeDistanceToLastFixMeters( currentPosition=endOfLastGreatCircleWayPoint, fixListIndex=self.flightListIndex ) distanceToLastFixMeters = distanceStillToFlyMeters """ for the last turn => final heading towards the runway orientation """ deltaTimeSeconds = 0.1 turnLeg.buildTurnLeg( deltaTimeSeconds=deltaTimeSeconds, elapsedTimeSeconds=endOfLastGreatCircleWayPoint.getElapsedTimeSeconds(), distanceStillToFlyMeters=distanceStillToFlyMeters, distanceToLastFixMeters=distanceToLastFixMeters, finalHeadingDegrees=finalHeadingDegrees, lastTurn=True, bankAngleDegrees=5.0, ) self.finalRoute.addGraph(turnLeg) endOfTurnLegWayPoint = self.finalRoute.getLastVertex().getWeight() """ ============= use touch-down way-point to compute distance to fly =============""" distanceStillToFlyMeters = endOfTurnLegWayPoint.getDistanceMetersTo(self.touchDownWayPoint) print self.className + ": distance still to fly= {0:.2f} nautics".format( distanceStillToFlyMeters * Meter2NauticalMiles ) # print '==================== add descent slope ================= ' descentGlideSlope = DescentGlideSlope( runway=self.arrivalRunway, aircraft=self.aircraft, arrivalAirport=self.arrivalAirport, descentGlideSlopeDegrees=3.0, ) flownDistanceMeters = self.finalRoute.getLengthMeters() distanceStillToFlyMeters = self.flightLengthMeters - self.finalRoute.getLengthMeters() distanceToLastFixMeters = self.computeDistanceToLastFixMeters( currentPosition=endOfTurnLegWayPoint, fixListIndex=self.flightListIndex ) distanceToLastFixMeters = distanceStillToFlyMeters descentGlideSlope.buildGlideSlope( deltaTimeSeconds=self.deltaTimeSeconds, elapsedTimeSeconds=endOfTurnLegWayPoint.getElapsedTimeSeconds(), initialWayPoint=endOfTurnLegWayPoint, flownDistanceMeters=flownDistanceMeters, distanceStillToFlyMeters=distanceStillToFlyMeters, distanceToLastFixMeters=distanceToLastFixMeters, ) self.finalRoute.addGraph(descentGlideSlope) endOfDescentGlideSlope = self.finalRoute.getLastVertex().getWeight() # print '================= add arrival ground run ================' arrivalGroundRun = GroundRunLeg( runway=self.arrivalRunway, aircraft=self.aircraft, airport=self.arrivalAirport ) arrivalGroundRun.buildArrivalGroundRun( deltaTimeSeconds=self.deltaTimeSeconds, elapsedTimeSeconds=endOfDescentGlideSlope.getElapsedTimeSeconds(), initialWayPoint=endOfDescentGlideSlope, ) self.finalRoute.addGraph(arrivalGroundRun)
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 buildSimulatedArrivalPhase(self): print self.className + "=========== add final turn, descent and ground run ===================" arrivalGroundRun = GroundRunLeg(runway=self.arrivalRunway, aircraft=self.aircraft, airport=self.arrivalAirport) self.touchDownWayPoint = arrivalGroundRun.computeTouchDownWayPoint() print self.touchDownWayPoint """ distance from last fix to touch down """ distanceToLastFixNautics = ( self.touchDownWayPoint.getDistanceMetersTo(self.getLastWayPoint()) * Meter2NauticalMiles ) print self.className + "===================== final 3 degrees descending glide slope ================" descentGlideSlope = DescentGlideSlope( runway=self.arrivalRunway, aircraft=self.aircraft, arrivalAirport=self.arrivalAirport, descentGlideSlopeDegrees=3.0, ) """ if there is a fix nearer to 5 nautics of the touch-down then limit size of simulated glide slope """ descentGlideSlopeSizeNautics = min(distanceToLastFixNautics / 2.0, 5.0) """ build simulated glide slope """ descentGlideSlope.buildSimulatedGlideSlope(descentGlideSlopeSizeNautics) self.firstGlideSlopeWayPoint = descentGlideSlope.getVertex(v=0).getWeight() print self.className + ": top of arrival glide slope= {0}".format(self.firstGlideSlopeWayPoint) print self.className + " ================= need a turn leg to find the junction point the last way-point in the fix list to the top of the final glide slope" """ initial heading is the orientation of the run-way """ lastFixListWayPoint = self.wayPointsDict[self.fixList[-1]] initialHeadingDegrees = self.arrivalRunway.getTrueHeadingDegrees() lastTurnLeg = TurnLeg( initialWayPoint=self.firstGlideSlopeWayPoint, finalWayPoint=lastFixListWayPoint, initialHeadingDegrees=initialHeadingDegrees, aircraft=self.aircraft, reverse=True, ) lastTurnLeg.buildNewSimulatedArrivalTurnLeg( deltaTimeSeconds=self.deltaTimeSeconds, elapsedTimeSeconds=0.0, distanceStillToFlyMeters=0.0, simulatedAltitudeSeaLevelMeters=self.firstGlideSlopeWayPoint.getAltitudeMeanSeaLevelMeters(), flightPathAngleDegrees=3.0, bankAngleDegrees=5.0, ) descentGlideSlope.addGraph(lastTurnLeg) # print self.className + ': compute arrival phase length= {0:.2f} meters'.format(descentGlideSlope.getLengthMeters()) # descentGlideSlope.createXlsxOutputFile() # descentGlideSlope.createKmlOutputFile() """ prepare next step """ beginOfLastTurnLeg = lastTurnLeg.getVertex(v=0).getWeight() print self.className + ": begin of last turn= {0}".format(beginOfLastTurnLeg) """ add the three last way-points in the fix list """ self.insert(position="end", wayPoint=beginOfLastTurnLeg) """ update the length of the flight path """ self.distanceFromApproachToTouchDownMeters = descentGlideSlope.getLengthMeters() self.flightLengthMeters = self.computeLengthMeters() + descentGlideSlope.getLengthMeters() print self.className + ": updated flight path length= {0:.2f} nautics".format( self.flightLengthMeters * Meter2NauticalMiles ) """ target approach fix is equal to the begin of the SIMULATED last turn leg """ self.aircraft.setTargetApproachWayPoint(beginOfLastTurnLeg) self.aircraft.setArrivalRunwayTouchDownWayPoint(self.touchDownWayPoint) print self.className + ": fix list= {0}".format(self.fixList)
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('==================== 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_One(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='LFML', runwayName='') print(runway) print("=========== airports =========== " + 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) 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_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"))