Python Flight Test Engineering Applications

Flight Test Python Programming

Scale Altitude Correction

Introduction to Python Flight Test Use

Python is a versatile and popular, high-level, general-purpose programming language ideally suited for flight test engineering. With Python flight test data analysis becomes easy to learn and efficient to implement. In flight test engineering Python is an alternative to MATLAB. Python has the advantage of being free and is therefore affordable and accessible for everyone. Large communities of programmers have contributed lots of open-source modules, which extend the ability of Python in various directions, from flight test data visualization to machine learning in autonomous flight.

If you have only used spreadsheet applications as a test pilot and flight test engineer so far to analyze flight test data, such as Microsoft Excel, we encourage you to try Python flight test data analysis. You can try it out and use for free, and installation is reasonably quick with our Python Flight Test Installation Guide.

All of our flight test engineering software on the Academic Flight website is written in Python, except for some codes intended for embedded systems (such as the Arduino), which are written in C++. In our Python flight test courses we will make it easy and enjoyable for you to learn Python. We present the development of this Python flight test engineering software in modular lessons, which let you select the topics you are interested in. With Python you will be free to perform whatever flight test data analysis and visualization you wish, and you will liberate yourself from the constraints of GUI spreadsheet applications, where you are entirely dependent on whatever functionality was built into the application by its creators.

Note on MATLAB for Students

Despite our use of Python in flight test throughout this website, if you are a university student at a degree-granting institution (including the National Test Pilot School (NTPS)), we strongly suggest that you purchase a MATLAB student license, as long as you are enrolled in classes at your institution. The price of the student license is very affordable (unlike the full license, which costs thousands of dollars) and will grant you perpetual access to MATLAB and Simulink (with software updates only for one year; the license is nominally only intended to complete your coursework and is restricted for installation on one computer, with the number of computer transfers limited per time period). Consider doing this, even if your degree-granting institution gives you access to their campus-wide academic license. MATLAB does things that Python does not, and experience with MATLAB and Simulink will look good on your resume.

Another alternative to MATLAB is GNU Octave, a scientific programming language with syntax largely compatible with MATLAB. Octave is free. You can use it to become familiar with MATLAB syntax without purchasing MATLAB, but it does not do everything MATLAB does.

Overview

Let us return to discussing flight test Python use though. Below you will find:

  • Links to illustrations and descriptions of the capabilities of Python in flight test
  • List of Python modules relevant for flight test
  • Summary and links to Python installation instructions
  • Links to our courses teaching you how to use Python for flight test

Python in Flight Test Engineering — Capabilities and Applications

In the links below, we showcase some of the capabilities of Python, with flight test engineering applications in mind (the links either lead to our own description or to an example Python package, which performs that task). Take a peak and pay attention to how easy and with how few lines of code you can achieve amazing results, while still remaining completely flexible to customize the flight test data analysis in any way you wish.


Python Modules for Flight Test Engineering

Modules are libraries, which extend the basic functionality of Python. Below is a noninclusive list of selected modules for Python test pilots and flight test engineers will find useful for flight test engineering and immediately related disciplines.

  • NumPy: The fundamental package for scientific computing with Python. You will use this Python module in almost every script/notebook.
  • SciPy: Fundamental algorithms for scientific computing in Python.
  • pandas: Python module for data analysis and manipulation—fast, powerful, flexible, and easy to use.
  • Matplotlib: Comprehensive Python library for creating static, animated, and interactive visualizations in Python. You will be using its pyplot submodule particularly often to create data visualizations.
  • Seaborn: Python data visualization library based on Matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics.
  • Python Control Systems Library (python-control): Python package that implements basic operations for analysis and design of feedback control systems in a MATLAB-like fashion (for a non-MATLAB-like interface, use the signal submodule of SciPy).
  • cyipopt: Python wrapper for Ipopt (Interior Point OPTimizer), a software package for large-scale nonlinear optimization. Can be used, for instance, for Model Predictive Control (MPC) as an advanced alternative to Proportional-Integral-Derivative (PID) control in control systems.
  • do-mpc: A comprehensive open-source toolbox for robust Model Predictive Control (MPC) and Moving Horizon Estimation (MHE).
  • X-Plane Connect (XPC): Open source research tool developed by NASA used to interact with the commercial flight simulator software X-Plane 9, 10, and 11. The XPC library enables the control of aircraft and real-time reception of flight test data from aircraft simulated in X-Plane using code written in Python, MATLAB, C, C++, or Java.
  • Pygame:  A set of Python modules designed for writing games and multimedia programs in Python. Together with X-Plane Connect above, we will use it to write an Automatic Flight Control System (AFCS) for an aircraft simulation, interfacing between the joystick and X-Plane. We will also use Pygame to write our own IADS-like flight test telemetry display software for real-time X-Plane telemetry visualization.
  • Pyserial: Python serial port extension, which allows communications with external devices, such as microcontrollers (e.g. Arduino), via USB.
  • Bleak: Bluetooth Low Energy platform Agnostic Klient, a Bluetooth Low Energy (BLE) library for connecting your computer to BLE devices, such as embedded systems.
  • MetPy: Meteorological Python module useful for reading, visualizing, and performing calculations with weather data. In addition to use in flight test engineering, Academic Flight also uses it for soaring weather forecasts from upper air sounding data of the National Weather Service.
  • OpenCV (OpenCV-Python): The world’s biggest computer vision library. Suggested 3rd-party tutorial. Increasing relevance for flight test engineering is through drones and autonomous flight.
  • scikit-learn: Fundamental versatile machine learning library for Python.
  • TensorFlow: Open-source library for machine learning and artificial intelligence, including deep learning (such as convolutional neural networks). Increasing relevance for flight test engineering is through drones and autonomous flight.
  • PyTorch: Machine learning library based on Torch library; popular for deep learning.
  • JAX: Python library for accelerator-oriented array computation and program transformation, designed for high-performance numerical computing and large-scale machine learning.
  • Keras: Deep learning API for JAX, TensorFlow, and PyTorch.
  • Jupyter Notebook and JupyterLab: Development environment running Python code in interactive code cells, interspersed with text cells for user descriptions, displayed in your web browser. This is the preferred way to use Python for data exploration and data analysis. Works also as a capable text editor for pure Python scripts.

Installation of Python 3 and Python Packages

The above packages greatly extend the capability of Python flight test engineering applications will benefit from, but you need to install them first, after you have installed Python 3 in the first place. In order to keep everything clean and contained in one folder on your computer, we suggest you use a Python package manager such as Anaconda for everything, including Python itself (for Python packages not in the Anaconda distribution, you can use the pip Python package installer later, which itself can also be installed with Anaconda and used within an Anaconda environment). After downloading, you may follow the instructions therein and install the above flight rest engineering relevant Python packages using conda or mamba. Or you can follow the instructions in our Python Flight Test Installation Guide. If you have difficulties, please contact us; the beginnings are often the most confusing, and we will be happy to help you get started. The installation procedure will take you approximately one hour to follow.

Alternatively, for the quickest start possible, you can download Carnets – Jupyter (with scipy) from the Apple App Store, if you have an iOS device (iPad, iPhone). It includes the Jupyter environment and comes with many Python packages preinstalled. It will work straight out of the box, which is ideal for you to try out Python on flight test data. Carnets’ limitations are that you will not be able to install additional packages yourself and that typing lots of code on an iPad or iPhone without an external keyboard is somewhat cumbersome.


Online Courses for Python in Flight Test

The above two Python flight test courses are integral components of our Applied Flight Test Engineering Course Series, which applies them to the creation of an Automatic Flight Control System (AFCS) for an aircraft and the conduct of flight tests performed in the commercial flight simulator software X-Plane.

Python Flight Test Examples

Below we show two Python flight test examples as an illustration how to use Python in flight test and in data presentation.

Python Flight Test
Maneuvering stability flight test data analysis is one of many Python flight test application opportunities.
Flight Test Python
Aircraft performance plot created with Python, using the Matplotlib module.