5  ㊙️ Flight phase identification

OpenAP includes a module to identify flight phases based on flight data, such as ADS-B data. It uses the fuzzy logic, which is defined in my paper: Sun et al. (2017)

Note that the paper was published a while ago; some improvements have been made in the logic since then. I also added a new phase to indicate level segments in the flight during the climb and descent.

5.1 Phase labeling

We can use FlightPhase.phaselabel(ts, alt, spd, roc) function to identify the labels of a given set of flight states. The following flight phases are supported:

GND: on-ground  
CL:  climb
DE:  descend
LVL: level flight
CR:  cruise
NA:  unlabeled

Note that the unit for all required parameters is:

ts:  timestamp      second
alt: altitude       ft
spd: speed          kts
roc: vertical rate  ft/min

Following is an example labeling process based on a real flight:

import pandas as pd
from openap.phase import FlightPhase

df = pd.read_csv("assets/data/flight_a319_opensky.csv", parse_dates=["timestamp"])

ts = (df.timestamp - df.timestamp.iloc[0]).dt.total_seconds()  # second
alt = df.altitude.values  # ft
spd = df.groundspeed.values  # kts
roc = df.vertical_rate.values  # ft/min

fp = FlightPhase()

fp.set_trajectory(ts, alt, spd, roc)

labels = fp.phaselabel()
print(labels)
['CL', 'CL', 'CL', 'CL', 'CL', 'CL', 'CL', 'CL', 'CL', 'CL', 'CL', 'CL', 'CL', 'CL', 'CL', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CL', 'CL', 'CR', 'CR', 'CL', 'CR', 'CL', 'CL', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'CR', 'DE', 'DE', 'DE', 'DE', 'DE', 'DE', 'DE', 'DE', 'DE', 'DE', 'DE', 'DE', 'DE', 'DE', 'DE', 'NA']

We can visualize the identified flight phases:

import matplotlib.pyplot as plt

phasecolors = {
    "GND": "black",
    "CL": "green",
    "DE": "blue",
    "LVL": "cyan",
    "CR": "purple",
    "NA": "red",
}

colors = [phasecolors[lbl] for lbl in labels]

plt.subplot(311)
plt.scatter(ts, alt, marker=".", c=colors, lw=0)
plt.ylabel("altitude (ft)")

plt.subplot(312)
plt.scatter(ts, spd, marker=".", c=colors, lw=0)
plt.ylabel("speed (kt)")

plt.subplot(313)
plt.scatter(ts, roc, marker=".", c=colors, lw=0)
plt.ylabel("roc (fpm)")

plt.show()