rlabbe / filterpy

Python Kalman filtering and optimal estimation library. Implements Kalman filter, particle filter, Extended Kalman filter, Unscented Kalman filter, g-h (alpha-beta), least squares, H Infinity, smoothers, and more. Has companion book 'Kalman and Bayesian Filters in Python'.
MIT License
3.23k stars 614 forks source link

Use masked array for zs? #236

Open rlabbe opened 3 years ago

rlabbe commented 3 years ago

Using None to denote z is not available is fine in methods such as update(), but it really falls apart when using batch_filter. Typically I would have zs as an np.array, not a list. Having to convert to a list and then assigning None just isn't very NumPyish.

I would just single functions like update should use the test:

 if z is None or z is ma.masked:

and then you can pass what you want into methods like batch_filter.

antoinecollet5 commented 2 years ago

Hi ! First of all thanks for your great work :)

Indeed, the support of masked array would be great and it works fine with the batch-filter method.

I just did a pull request.

You can find a working example here: https://github.com/antoinecollet5/kalman-filtering/blob/develop/linear_case_filterpy.ipynb

Cheers