From c3f2f3b3c5a7054c177060e98b9b1425b0d83e71 Mon Sep 17 00:00:00 2001 From: Kylen Solvik Date: Wed, 29 Nov 2023 11:22:22 -0700 Subject: [PATCH] Updated 4dvar notation, working --- dabench/dacycler/_var4d.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dabench/dacycler/_var4d.py b/dabench/dacycler/_var4d.py index 19b7d2e..d045c4e 100644 --- a/dabench/dacycler/_var4d.py +++ b/dabench/dacycler/_var4d.py @@ -130,6 +130,7 @@ def _cycle_obsop(self, xb0, obs_values, obs_loc_indices, obs_values, H, B, Rinv, M, obs_window_indices) + # forecast x = self.step_forecast( n_steps=n_steps, @@ -176,8 +177,7 @@ def _innerloop_4d(self, system_dim, x, xb0, y, H, B, Rinv, M, Args: system_dim (int): The dimension of the system state. x (ndarray): Current best guess for trajectory. Updated each outer - loop. - (time_dim, system_dim) + loop. (time_dim, system_dim) xb0 (ndarray): Initial background estimate for initial conditions. Stays constant throughout analysis cycle. Shape: (system_dim,) y (ndarray): Time array of observation. Shape: (num_obs, obs_dim) @@ -197,7 +197,7 @@ def _innerloop_4d(self, system_dim, x, xb0, y, H, B, Rinv, M, Shape: (system_dim,) """ - x0_last = x[0].ravel() + x0_last = x[0] # Set up Variables SumMtHtRinvD = np.zeros((system_dim, 1)) # b input @@ -215,10 +215,10 @@ def _innerloop_4d(self, system_dim, x, xb0, y, H, B, Rinv, M, SumMtHtRinvD += MtHtRinv @ D[:, None] # Compute initial departure - db0 = x0_last - xb0.ravel() + db0 = x0_last - xb0 # Solve Ax=b for the initial perturbation - dx0 = self._solve(db0, SumMtHtRinvHM, SumMtHtRinvD, B) + dx0 = self._solve(-db0, SumMtHtRinvHM, SumMtHtRinvD, B) # New x0 guess is the last guess plus the analyzed delta x0_new = x0_last + dx0.ravel()