在过去的几天里,我使用 pykalman 通过加速度和速度测量来校正 GPS 坐标,效果很好。现在我想将得到的坐标 (1) 与第二个坐标测量值 (2) 结合起来,该坐标测量值非常精确,但记录率要低得多。我屏蔽了第二次测量中没有值(== 0)的所有元素。
我的问题是,我不知道矩阵的样子。也许卡尔曼滤波器甚至不适合我想做的事情。
非常感谢您提前。
for i in range(len(lat1)):
if i == 0:
measurements = ma.asarray([(lat1[i], long1[i], lat2[i], long2[i])])
else:
measurements = ma.append(measurements, [[lat1[i], long1[i], lat2[i], long2[i]]], axis=0)
for i in range(len(measurements)):
if measurements[i, 2] == 0:
measurements[i, 2] = ma.masked
if measurements[i, 3] == 0:
measurements[i, 3] = ma.masked
initial_state_mean = ma.asarray([measurements[0, 0], measurements[0, 1], measurements[0, 2], measurements[0, 3]])
transition_matrix = [[0, 0, 1, 0],
[0, 0, 0, 1],
[0, 0, 0, 0],
[0, 0, 0, 0]]
observation_matrix = [[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]]
kf1 = KalmanFilter(transition_matrices=transition_matrix,
observation_matrices=observation_matrix,
initial_state_mean=initial_state_mean,
observation_covariance=[[0.1, 0, 0, 0],
[0, 0.1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]],
transition_covariance=[[0, 0, 1, 0],
[0, 0, 0, 1],
[0, 0, 0, 0],
[0, 0, 0, 0]]
)
(smoothed_state_means, smoothed_state_covariances) = kf1.smooth(measurements)
lat_corr = smoothed_state_means[:, 0]
long_corr = smoothed_state_means[:, 1]