Extensive copy editing.
This commit is contained in:
@@ -52,7 +52,6 @@ def ball_kf(x, y, omega, v0, dt, r=0.5, q=0.02):
|
||||
|
||||
|
||||
def plot_radar(xs, track, time):
|
||||
|
||||
plt.figure()
|
||||
bp.plot_track(time, track[:, 0])
|
||||
bp.plot_filter(time, xs[:, 0])
|
||||
@@ -76,6 +75,7 @@ def plot_radar(xs, track, time):
|
||||
plt.ylim((900, 1600))
|
||||
plt.show()
|
||||
|
||||
|
||||
def plot_bicycle():
|
||||
plt.clf()
|
||||
plt.axes()
|
||||
@@ -215,11 +215,11 @@ def show_radar_chart():
|
||||
|
||||
|
||||
|
||||
ax.annotate('$\Theta$', xy=(1.2, 1.1), color='b')
|
||||
ax.annotate('$\Theta$', xy=(1.2, 1.05), color='b')
|
||||
ax.annotate('Aircraft', xy=(2.04,2.), color='b')
|
||||
ax.annotate('altitude', xy=(2.04,1.5), color='k')
|
||||
ax.annotate('X', xy=(1.5, .9))
|
||||
ax.annotate('Radar', xy=(.95, 0.9))
|
||||
ax.annotate('altitude (y)', xy=(2.04,1.5), color='k')
|
||||
ax.annotate('x', xy=(1.5, .9))
|
||||
ax.annotate('Radar', xy=(.95, 0.8))
|
||||
ax.annotate('Slant\n (r)', xy=(1.5,1.62), color='r')
|
||||
|
||||
plt.title("Radar Tracking")
|
||||
@@ -229,4 +229,4 @@ def show_radar_chart():
|
||||
ax.yaxis.set_ticks([])
|
||||
|
||||
|
||||
plt.show()
|
||||
plt.show()
|
||||
|
||||
@@ -16,6 +16,7 @@ for more information.
|
||||
from __future__ import (absolute_import, division, print_function,
|
||||
unicode_literals)
|
||||
|
||||
from filterpy.kalman import MerweScaledSigmaPoints, unscented_transform
|
||||
from filterpy.stats import multivariate_gaussian
|
||||
from matplotlib import cm
|
||||
import matplotlib.pyplot as plt
|
||||
@@ -47,10 +48,10 @@ def plot_nonlinear_func(data, f, gaussian, num_bins=300):
|
||||
#plot output
|
||||
h = np.histogram(ys, num_bins, density=False)
|
||||
plt.subplot(2,2,4)
|
||||
plt.plot(h[0], h[1][1:], lw=4, alpha=0.5)
|
||||
plt.plot(h[0], h[1][1:], lw=4, alpha=0.8)
|
||||
plt.ylim(out_lims[1], out_lims[0])
|
||||
plt.gca().xaxis.set_ticklabels([])
|
||||
plt.title('output')
|
||||
plt.title('Output')
|
||||
|
||||
plt.axhline(np.mean(ys), ls='--', lw=2)
|
||||
plt.axhline(f(x0), lw=1)
|
||||
@@ -66,16 +67,16 @@ def plot_nonlinear_func(data, f, gaussian, num_bins=300):
|
||||
print(max(norm.pdf(xs)))'''
|
||||
|
||||
# plot transfer function
|
||||
plt.subplot(2,2,3)
|
||||
plt.subplot(2, 2, 3)
|
||||
x = np.arange(in_lims[0], in_lims[1], 0.1)
|
||||
y = f(x)
|
||||
plt.plot (x,y, 'k')
|
||||
plt.plot (x, y, 'k')
|
||||
isct = f(x0)
|
||||
plt.plot([x0, x0, in_lims[1]], [out_lims[1], isct, isct], color='r', lw=1)
|
||||
plt.xlim(in_lims)
|
||||
plt.ylim(out_lims)
|
||||
#plt.axis('equal')
|
||||
plt.title('function')
|
||||
plt.title('f(x)')
|
||||
|
||||
# plot input
|
||||
h = np.histogram(data, num_bins, density=True)
|
||||
@@ -84,7 +85,7 @@ def plot_nonlinear_func(data, f, gaussian, num_bins=300):
|
||||
plt.plot(h[1][1:], h[0], lw=4)
|
||||
plt.xlim(in_lims)
|
||||
plt.gca().yaxis.set_ticklabels([])
|
||||
plt.title('input')
|
||||
plt.title('Input')
|
||||
|
||||
plt.show()
|
||||
|
||||
@@ -106,11 +107,9 @@ def plot_ekf_vs_mc():
|
||||
d_t = fx(data)
|
||||
|
||||
mean_ekf = fx(mean)
|
||||
|
||||
slope = dfx(mean)
|
||||
std_ekf = abs(slope*std)
|
||||
|
||||
|
||||
norm = scipy.stats.norm(mean_ekf, std_ekf)
|
||||
xs = np.linspace(-3, 5, 200)
|
||||
plt.plot(xs, norm.pdf(xs), lw=2, ls='--', color='b')
|
||||
@@ -126,8 +125,6 @@ def plot_ekf_vs_mc():
|
||||
print('EKF mean={:.2f}, std={:.2f}'.format(mean_ekf, std_ekf))
|
||||
|
||||
|
||||
from filterpy.kalman import MerweScaledSigmaPoints, unscented_transform
|
||||
|
||||
def plot_ukf_vs_mc(alpha=0.001, beta=3., kappa=1.):
|
||||
|
||||
def fx(x):
|
||||
@@ -159,12 +156,12 @@ def plot_ukf_vs_mc(alpha=0.001, beta=3., kappa=1.):
|
||||
|
||||
norm = scipy.stats.norm(ukf_mean, ukf_std)
|
||||
xs = np.linspace(-3, 5, 200)
|
||||
plt.plot(xs, norm.pdf(xs), ls='--', lw=1, color='b')
|
||||
plt.hist(d_t, bins=200, normed=True, histtype='step', lw=1, color='g')
|
||||
plt.plot(xs, norm.pdf(xs), ls='--', lw=2, color='b')
|
||||
plt.hist(d_t, bins=200, normed=True, histtype='step', lw=2, color='g')
|
||||
|
||||
actual_mean = d_t.mean()
|
||||
plt.axvline(actual_mean, lw=1, color='g', label='Monte Carlo')
|
||||
plt.axvline(ukf_mean, lw=1, ls='--', color='b', label='UKF')
|
||||
plt.axvline(actual_mean, lw=2, color='g', label='Monte Carlo')
|
||||
plt.axvline(ukf_mean, lw=2, ls='--', color='b', label='UKF')
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ def plot_random_pd():
|
||||
#plt.setp(plt.gca().get_yticklabels(), visible=False)
|
||||
plt.axes(xticks=[], yticks=[], frameon=False)
|
||||
plt.plot(x, y2)
|
||||
plt.ylim([0, max(y2)+.1])
|
||||
|
||||
|
||||
def plot_monte_carlo_ukf():
|
||||
|
||||
@@ -279,6 +279,17 @@ def plot_radar(xs, t, plot_x=True, plot_vel=True, plot_alt=True):
|
||||
plt.ylabel('altitude')
|
||||
plt.show()
|
||||
|
||||
|
||||
def plot_altitude(xs, t, track):
|
||||
xs = np.asarray(xs)
|
||||
|
||||
plt.plot(t, xs[:,2], label='filter', )
|
||||
plt.plot(t, track, label='Aircraft', lw=2, ls='--', c='k')
|
||||
plt.xlabel('time(sec)')
|
||||
plt.ylabel('altitude')
|
||||
plt.legend(loc=4)
|
||||
|
||||
|
||||
def print_sigmas(n=1, mean=5, cov=3, alpha=.1, beta=2., kappa=2):
|
||||
points = MerweScaledSigmaPoints(n, alpha, beta, kappa)
|
||||
print('sigmas: ', points.sigma_points(mean, cov).T[0])
|
||||
|
||||
Reference in New Issue
Block a user