/openap-top-rye

Open flight trajectory optimizer built with non-linear optimal control method

Primary LanguagePythonGNU Lesser General Public License v3.0LGPL-3.0

OpenAP Trajectory Optimizer

This repository contains the flight trajectory optimizer module of OpenAP.

A more detailed user guide can be found on: https://openap.dev/top.

Install

OpenAP.top uses cfgrib for integrating wind data, cartopy for plotting, and a few other libraries.

Note

This fork of OpenAP.top is configured so that it can be easily installed in one go

pip install git+https://github.com/lucianosrp/openap-top-rye

Or using Rye

rye add openap-top --git https://github.com/lucianosrp/openap-top-rye

Quick start

Example code to generate a fuel optimal flight between two airports:

from openap import top

optimizer = top.CompleteFlight("A320", "EHAM", "LGAV", m0=0.85)

flight = optimizer.trajectory(objective="fuel")

You can specify different objective functions as:

flight = optimizer.trajectory(objective="ci:30")
flight = optimizer.trajectory(objective="gwp100")
flight = optimizer.trajectory(objective="gtp100")

The final flight object is a pandas DataFrame. The following is an example:

example_optimal_flight

Use wind data

To enable wind in your optimizer, you must first download meteorological data in grib format from ECMWF, for example, the ERA5 data at https://doi.org/10.24381/cds.bd0915c6.

Then enable the wind for the defined optimizer.

Example code:

from openap import top
from openap.top import wind

optimizer = top.CompleteFlight("A320", "EHAM", "LGAV", m0=0.85)

fgrib = "path_to_the_wind_data.grib"
windfield = wind.read_grib(fgrib)
optimizer.enable_wind(windfield)

flight = optimizer.trajectory(objective="fuel")

If your grib file includes multiple timestamps, make sure to filter the correct time in the previous windfield object (pandas DataFrame).

Example of an optimal flight:

example_optimal_flight