Search⌘ K
AI Features

Standardizing Airfoil Coordinates

Explore methods to standardize and clean airfoil coordinate data for accurate plotting. Understand how to handle varying data formats, space separators, and invalid values to visualize airfoils beyond basic NACA types.

We'll cover the following...

Now, you can graph some NACA airfoils by name. But, there are many more airfoils in the UIUC database than just NACA ones. Let’s try graphing an MH70 airfoil:

Python 3.8
import requests
import matplotlib.pyplot as plt
def plot_airfoil(x_coordinates: list, y_coordinates: list, plot_title: str) -> None:
"""
Plot the airfoil coordinates given the list of coordinates
:param x_coordinates: list of airfoil's x coordinates
:param y_coordinates: list of airfoil's y coordinates
:param plot_title: str to title as the plot's title
:return: None
"""
plt.plot(x_coordinates, y_coordinates, 'k-')
plt.title('{} airfoil'.format(plot_title))
plt.style.use('default')
plt.xlim(-0.50, 1.25)
plt.ylim(-1, 1)
#plt.show()
plt.savefig("output/chap4_4.png")
def get_airfoil_coords(airfoil: str) -> tuple:
"""
Get airfoil coords from UIUC website
https://m-selig.ae.illinois.edu/ads/coord/__.dat
:param airfoil: str of airfoil types
:return: tuple of ([x coords], [y coords], plot_title)
"""
url = 'https://m-selig.ae.illinois.edu/ads/coord/{}.dat'.format(airfoil.lower())
response_text = requests.get(url).text
all_text = response_text.split('\n')
x_coordinates, y_coordinates = [], []
plot_title = ''
for index, line in enumerate(all_text):
if index == 0:
plot_title = line.strip()
else:
try:
line = line.strip()
x, y = line.split(' ')
x_coordinates.append(float(x.strip()))
y_coordinates.append(float(y.strip()))
except ValueError:
continue
return x_coordinates, y_coordinates, plot_title
air_foil = 'mh70'
x_values, y_values, title = get_airfoil_coords(air_foil)
plot_airfoil(x_values, y_values, title)

It’s blank. Let’s look at the .dat file to see why:

MH 70  11.08% 
  1.00000000  0.00000000
  0.99663874 
...