Saver¶
This is a helper class designed to allow you to save the state of the Kalman filter for each epoch. Each instance variable is stored in a list when you call save().
This class is deprecated as of version 1.3.2 and will be deleted soon. Instead, see the class filterpy.common.Saver, which works for any class, not just a KalmanFilter object.
Example
saver = Saver(kf)
for i in range(N):
kf.predict()
kf.update(zs[i])
saver.save()
saver.to_array() # convert all to np.array
# plot the 0th element of kf.x over all epoches
plot(saver.xs[:, 0])
Copyright 2015 Roger R Labbe Jr.
FilterPy library. http://github.com/rlabbe/filterpy
Documentation at: https://filterpy.readthedocs.org
Supporting book at: https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file for more information.
Kalman filter saver
-
class
filterpy.kalman.
Saver
(kf, save_current=True)[source]¶ Deprecated. Use filterpy.common.Saver instead.
Helper class to save the states of the KalmanFilter class. Each time you call save() the current states are appended to lists. Generally you would do this once per epoch - predict/update.
Once you are done filtering you can optionally call to_array() to convert all of the lists to numpy arrays. You cannot safely call save() after calling to_array().
Examples
kf = KalmanFilter(...whatever) # initialize kf here saver = Saver(kf) # save data for kf filter for z in zs: kf.predict() kf.update(z) saver.save() saver.to_array() # plot the 0th element of the state plt.plot(saver.xs[:, 0, 0])