Skip to content

Instantly share code, notes, and snippets.

@SuborbitalPigeon
Last active October 6, 2016 19:11
Show Gist options
  • Save SuborbitalPigeon/e39270ae28ef2d77200248af65c43492 to your computer and use it in GitHub Desktop.
Save SuborbitalPigeon/e39270ae28ef2d77200248af65c43492 to your computer and use it in GitHub Desktop.
from math import pi
from matplotlib import pyplot as plt
import pandas as pd
import seaborn as sns
A = pi/4 * 0.8**2 # Diameter: 800 mm
speeds = list(range(60, 270, 10))
altitudes = list(range(0, 45000, 1000))
rho_0 = 1.225
rho_fact = [1.0000, 0.9711, 0.9428, 0.9151, 0.8881,
0.8671, 0.8359, 0.8106, 0.7860, 0.7620,
0.7385, 0.7155, 0.6932, 0.6713, 0.6500,
0.6292, 0.6090, 0.5892, 0.5699, 0.5511,
0.5328, 0.5150, 0.4976, 0.4806, 0.4642,
0.4481, 0.4325, 0.4173, 0.4025, 0.3881,
0.3741, 0.3605, 0.3473, 0.3345, 0.3220,
0.3099, 0.2981, 0.2843, 0.2710, 0.2583,
0.2462, 0.2346, 0.2236, 0.2131, 0.2031]
density = [rho_0 * d for d in rho_fact]
density = pd.Series(density, index=altitudes)
power = pd.DataFrame(index=altitudes)
power.index.name = 'altitude (ft)'
power.columns.name = 'speed (m/s)'
for s in speeds:
series = (0.5 * density * A * s**3) / 1e3 # kW
power[s] = series
# Plotting
plt.figure(figsize=(12,6))
sns.set_context('paper')
ax = sns.heatmap(power, cmap='viridis', annot=True, fmt='.0f')
plt.yticks(rotation='horizontal')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment