compute analysis
ua = ub + K @ (w-ObsOp(ub))
P = (np.eye(n) - K@Dh) @ B
return ua, P ✝ ✆
```
#### *Example: Lorenz 63 System*

The first-order approximation of the Kalman filter in nonlinear case, known as extended Kalman filter, is applied for the test case of Lorenz 63 system. The computation of model Jacobian **D***M*(·) is presented in Listings 10 and 11 in Section 4. We use the same parameters and initial conditions for the twin experiment framework as before. The sequential implementation of the forecast and analysis steps is shown in Listing 16 and results are illustrated in Figure 4. We adopt the 4th order Runge–Kutta scheme for time integration. For demonstration purposes, we consider zero process

noise (i.e., **Q** = 0). However, we have found that assuming non-zero process noise (e.g., **Q** = 0.01**I**3) yields better performance.

**Listing 16.** Implementation of the EKF for the Lorenz 63 system. ✞ ☎

```
#%% Application: Lorenz 63
########################### Data Assimilation #################################
u0b = np.array([2.0,3.0,4.0])
sig_b= 0.1
B = sig_b**2*np.eye(3)
Q = 0.0*np.eye(3)
#time integration
ub = np.zeros([3,nt+1])
ub[:,0] = u0b
ua = np.zeros([3,nt+1])
ua[:,0] = u0b
km = 0
for k in range(nt):