In [ ]:
# dependencies
from numpy import loadtxt, arange
import matplotlib.pyplot as plt
%matplotlib inline

IN2M = 0.0254

# import data
or_mach, or_cp = loadtxt('./data/C_P-OpenRocket.csv', delimiter=',', unpack=True)

ras_mach = []
ras_cp = []
with open('./data/C_P-RASAero-II.csv', 'r') as fin:
    for line in fin.readlines():
        # ignore documentation line
        if 'Mach' in line: continue

        li = line.split(',')

        # don't care about alpha > 0
        if float(li[1]) > 0: continue

        ras_mach.append(float(li[0]))
        ras_cp.append(float(li[12])*IN2M)

ras_mach_sparse = [m for i, m in enumerate(ras_mach) if i%10 == 0]
ras_cp_sparse = [cp for i, cp in enumerate(ras_cp) if i%10 == 0]

In [ ]:
import barrowman
from barrowman import original

# build a rocket
nose = barrowman.Nose(barrowman.Nose.CONE, 0.1, 0.3)
tube = barrowman.Tube(0.1, 1.0)

body = original.Body([nose, tube])

# TODO: full solution
mach = arange(0,25,0.05)
cp = []
for m in mach:
    cp.append(body.C_P(m))

In [ ]:
fig, ax1 = plt.subplots(figsize=(16,8))
plt.title(r"Center of Pressure ($\mathrm{C}_P$) From Multiple Tools")
plt.ylabel(r"$\mathrm{C}_P$")
plt.xlabel(r"Mach Number")

plt.plot(ras_mach_sparse, ras_cp_sparse, 'x', label="RASAero II")
plt.plot(or_mach, or_cp, '+', label="OpenRocket")
plt.plot(mach, cp, label="barrowman")

plt.ylim([0.75,1.25])
plt.xlim([0,8])
ax1.legend(loc=1, title="Tool:")
plt.show()