卡尔曼滤波器输入-阵列布置

时间:2019-10-26 09:59:35

标签: python arrays numpy kalman-filter

我在尝试使用软件包时遇到错误。我知道它的数组,但是我不确定如何正确格式化它 我正在使用的软件包是-

https://github.com/oseiskar/simdkalman

代码-

import simdkalman


measurements = np.ma.masked_array(y)


kf = simdkalman.KalmanFilter(A, C, np.linalg.inv(W_neg_sqrt @ W_neg_sqrt), np.linalg.inv(V_neg_sqrt @ V_neg_sqrt))
kf = kf.em(measurements, n_iter=10)

运行错误-

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-b64029d71a54> in <module>
      6 
      7 kf = simdkalman.KalmanFilter(A, C, np.linalg.inv(W_neg_sqrt @ W_neg_sqrt), np.linalg.inv(V_neg_sqrt @ V_neg_sqrt))
----> 8 kf = kf.em(y, n_iter=10)

~/env/lib/python3.7/site-packages/simdkalman/kalmanfilter.py in em(self, data, n_iter, initial_value, initial_covariance, verbose)
    732             gains = True,
    733             log_likelihood = False,
--> 734             verbose = verbose)
    735 
    736         if verbose:

~/env/lib/python3.7/site-packages/simdkalman/kalmanfilter.py in compute(self, data, n_test, initial_value, initial_covariance, smoothed, filtered, states, covariances, observations, likelihoods, gains, log_likelihood, verbose)
    526                 print('filtering %d/%d' % (j+1, n_measurements))
    527 
--> 528             y = data[:,j,...].reshape((n_vars, n_obs, 1))
    529 
    530             tup = self.update(m, P, y, log_likelihood)

ValueError: cannot reshape array of size 119 into shape (119,48,1)

要传递的数据如下-

数据-

measurements

masked_array(
  data=[[1.83    , 1.314   , 0.124   , ..., 2.072   , 0.959   , 0.093   ],
        [1.907   , 1.341   , 0.131   , ..., 2.109   , 0.972   , 0.1     ],
        [1.935   , 1.36    , 0.138   , ..., 2.141   , 1.      , 0.105   ],
        ...,
        [4.864745, 2.99041 , 6.945452, ..., 5.772958, 1.830929, 0.58429 ],
        [4.87512 , 3.002997, 7.048876, ..., 5.792051, 1.817048, 0.578934],
        [4.887871, 3.013825, 7.171646, ..., 5.813568, 1.805832, 0.577737]],
  mask=False,
  fill_value=1e+20)

0 个答案:

没有答案