Data assimilation didactic examples. User s guide - David Cugnet, 2011 Introduction The present didactic software is using two models: the first one is a simple damped mechanical oscillator, and the second is the Lorenz oscillator. We will focus hereafter on the second one. For more details about the theoretical background, please refer to reference [1]. The Lorenz model In a 1963 article [1], the meteorologist Edward N. Lorenz has for the first time described an example of chaotic non- periodic oscillator obtained by deriving the governing equations of a simplified convective fluid dynamic system. Following Salzman [2], he constructed a truncated Fourier expansion of the physical system, which leads to a set of three differential equations: =. =. +. =.. (1) The key idea is to choose a set of, and parameters such that the oscillator becomes critical and exhibits a so- called chaotic behaviour. This oscillator is now widely known as the Lorenz Oscillator. The most usual set of parameters is the following: = 10 = 8 3 = 28 (2) There are at most three equilibrium points. The first one, the origin, exists whatever the values of the three parameters. The other two, symmetric with respect to the origin, exist for > 1, and are located at:. 1,. 1, 1 and. 1,. 1, 1 (3) The trajectories are rolling around those two last attraction points and switch from one attractor to the other without any apparent intuitive predictability, and the sensitivity to the starting point is very high. This model is rather demanding to test assimilations techniques, but belongs at the same time simple enough to allow testing most of the adjustable parameters, so that one can test the assimilations methods and their parameterization rather than the model itself, and learn useful lessons about the way to deal with more complex and realistic models, in particular meteorological models.
Some assimilation algorithms 1. Optimal interpolation Estimation is updated each time a new measurement is available via the relation: (4) = +.., where =.... + The matrix is constant, equal to its initial value (default: climatological matrix). 2. 4D- Var Each measurement within the assimilation window is contributing to a cost function J that has to be minimized to find the optimal starting point. J includes also a term for the initial guess (background), which can be considered as another measurement (in the model space) following another statistic (the background error covariance matrix B). J has the following expression: 1 1 =.. +.... (5) 2 2 Its minimization requires the gradient. For a small model space like ours, it can be done using a simple finite differences approach. For larger systems, it is mandatory to find an alternative method, because the numerical cost becomes prohibitive. The most popular and efficient method is based on the adjoint model usage. Here, although the model space is quite small (3 parameters for Lorenz oscillator, 2 for damped oscillator), we chose also the adjoint method for its precision and robustness. 3. Incremental 4D- Var This alternative method is widely used for large systems. It allows to solve the problem on a subset of the model space by reduction of the resolution of the increments. It is usually divided into two loops, an internal and an external, helping for massive numerical cost reduction, and uses a simplified low resolution model. Although it could be also implemented for small models, the benefit is very marginal and the present version of the software does not include this method yet (and this is unlikely to change). 4. Extended Kalman Filter The Kalman filter method is very similar to optimal interpolation, but the background covariance error matrix is also updated, so the gain matrix is changing each time a measurement is taken into account. It consists in five stages: State forecast: =. (6.1) Error covariance forecast: =.. + (6.2) Kalman gain computation: =.... + (6.3) State analysis: = +.. (6.4) Error covariance analysis: =.. (6.5) The regular Kalman filters works under the hypothesis that both model M and observation operator are linear, which is not the case for Lorenz model, at least for M. Hence, we use an extended approach: the tangent linear version of M is used instead. Note that equation 6.2 contains, which is the model error covariance matrix. 5. 4D- PSAS (dual formulation of 4D- Var) The basic idea is to rewrite 4D- Var equations in physical space instead of model space. For more details, see [3]. This method isn t included in the present software yet.
The software 1. Prerequisite The user must have access to a machine with MATLAB software installed, and of course the Didactic.tgz archive available. 2. Expanding the archive Chose a place to store the archive Didactic.tgz and expand it : with MacOS or a Windows system, using your favourite tool. with a Linux system, using the following command: tar xvzf Didactic.tgz 3. Launching MATLAB with MacOS or a Windows system, just click on the corresponding icon. with a Linux system, use the following terminal command: matlab desktop & Note that if you re connecting to a remote machine, X windows agent has to be activated. To do so, use the X option: ssh X user@machine 4. Selecting the folder containing the code Under the top left menu of the main MATLAB window, click on one of the following: the blue folder if you d like to type the folder path directly the << sign to select one basic place the arrow in the bottom direction to select an already visited place When selection is done, the MATLAB source files names should appear just under the path name. 5. Main GUI window creation 5.1. Launch the software by typing in the matlab main window the following command : Didactic 5.2. Select the model you want to work on by clicking on the adequate knob : We suppose from now the Lorenz model has been selected. Few parameters accessible in the command window are differing from Lorenz to damped oscillators (manly the number of independent variables: 2 instead of three for the damped oscillator). This illustrates the assimilation part is almost independent of the choice of the model.
5.3. Selection of the number of experiences to be run together (by default: 2): The following window is appearing : The number can be modified using the keyboard after clicking on the box : All the experiences run together are using the same random numbers, i.e. the same background noise (for starting point, using ) and measurement noise (using ). Numerically, we can add a noise with covariance matrix to vector this way: = +.. (7) has been diagonalized using SVD (Singular Values Decomposition): =.. is a gaussian noise vector with unit variance and zero mean is positive defined, so its eigenvalues are positive real and their square roots also. 5.4. Estimation of the background error covariance matrix The following window appears the time required to compute an approximation of the variance matrix of the system by integrating a trajectory during a long time and calculating variances and co- variances numerically. The matrix obtained using a very long sample (i.e. hundreds of time units, with a time step equal to 0.02 unit) is singular, so we are restricting the integration time to 20 units. This is not fully satisfactory, but enough for our purpose. 5.5. Main GUI command window
6. Main parameters 6.1. Assimilation algorithm Roll menu: Available choices: Optimal Interpolation 4D- Var Incremental 4D- Var Extended Kalman Filter Note that the incremental 4D- Var is not implemented yet, so avoid using this option. 6.2. Assimilation window size Roll menu: Available choices: The assimilation window is the time interval observations are available and the integration period for variational algorithms. Time unit corresponds roughly to a full revolution around one of the attractors of Lorenz model. 6.3. Observations spacing and measurement noise variance: Roll menu: Available choices: Fenêtre d édition (bruit) : Spacing is given in model integration time step unit. The default value (0,02 time unit) can be changed via the advanced parameters (see below). 6.4. Background error statistics (starting point of the trajectory) Exact start: With error: The starting point is exact if the box is checked. Otherwise, a noise (cf. eq. (7)) characterized with climatological scaled with an editable coefficient (in %) is added. 7. Advanced parameters Hidden menus can be revealed by pushing the knob More options on the right: 7.1. Integration time step Can be edited via the window: Keyboard- edited value is rounded ; observations spacing menu is modified accordingly (time steps number between two observations must divide the number in the assimilation). 7.2. Controlled variables: They can be chosen using this menu: These are the degrees of freedom visible through the observations.
7.3. Background and observation error covariance matrix: By default, is set to 0.01 time identity matrix, scaled with an editable coefficient. The user option gives access to Edit knob, that makes full editing possible. The useful coefficients of the matrix only (i.e. for controlled d.o.f) are displayed. See example on the left: coefficients related to uncontrolled y are not accessible. Same principle for the background error covariance matrix. The default value is the climatologic. 7.4. Ensemble methods. This option can be used to produce a set of almost identical simulations. The only difference is that each of them includes additional noise both for background (starting point) and observations. This option is not usable for irrelevant methods (Optimal Interpolation for example). Ensemble members number can be selected when this option is set on: 7.5. Reduced rank methods This kind of methods is irrelevant for such small models, and has hence been disabled. It will be useful, though, for further more complex models still to be included. 7.6. Model error growth term For adequate methods (Kalman filter), this particular term can be taken into account. This matrix, named in equation (6.2), is predefined (valid for a time step equal to 0,02 time unit) and hard coded, so one have to modify program init_model.m L change it. No effect for damped oscillator model. 8. Assimilation Main window displaying process also creates a MATLAB structure, named par. For more details about this structure, please refer to the annex. Pushing the Assimilation knob on the left has several effects: User- chosen parameters and other derived quantities, are stored in par. Measurements and initial conditions are generated. Assimilation itself is performed for each experiment. Messages are informing the user about the computing progress. 9. Displaying the results Drawings are obtained after assimilation by pushing the display knob. There are four windows. There are four windows. Two different experiences can be displayed at the same time ; they are chosen with the rolling menus on the right of the drawing panels. See example, for three simultaneous experiments. * The two left graphs show the trajectories and the measurements. * The two right graphs show diagnostics (TmA, TmP, OmA, FmA when possible)
The sub- menu Variables helps to select the variables to display ; all option displays a 3D trajectory (and first variable for diagnostics). Here s an example for three experiments, the first one being displayed in 3D mode: The Forecast wind(%) editable boxes help to choose the ratio fc between the forecast and the assimilation window lengths. /\ Hence, fc is not a pure display parameter: it can t be changed after assimilation To improve results comparison, the horizontal scales are identical for every experiment. So the model is always integrated until tf, with = max 1 + ". "
Annex 1: Integration algorithm Both models are governed by first order differential systems that can be rewritten: =, " Second order Runge- Kutta method is one of the simplest ways to solve such systems: + Δ = + Δ. where: =, and = + Δ., + Δ 2 1. Direct model If is only depending on time through, and if we note = : = +. + 2 2. Tangent linear model If = +, direct model rewrites: = +. We have: =. Also: = 1 +..., so: =. + Globally, the tangent linear model can be expressed this way: " = +.. + 2 3. Adjoint model It is defined by the relation :. =.. After some algebra: " = +. + 2. Annex 2: Cost function derivatives A minimization method requires the gradient of J, derived by taking the gradient of (5):.... =. The Hessian matrix is also required. Here is the full expression: =........ + The second order term involving crossed derivatives is usually neglected, because it causes numerical instabilities. Resulting expression is: = +....
Annex 3: Levenberg Marquardt method To find the minimum of a cost function, gradient method is safe, but slow. It consists in searching the minimum along the direction given by the local gradient. A more efficient method, often used in operational assimilation systems, is the conjugate gradient, also called Newton method, based in a parabolic approximation of the J hyper- surface in the minimum vicinity. Much faster, this strategy is not robust far from the minimum, where the parabolic approximation does not stand anymore. Here, we are talking of quasi- newtonian method because of the approximation on the Hessian (second partial derivative terms suppressed), by contrast with a pure newtonian method, which would include the crossed derivatives term. The Levenberg Marquardt is a compromise combining the advantages of both methods. The diagonal of the Hessian, used in the matrix system giving the quasi- newtonian increment, is multiplied by +, where is an adjustable coefficient: If, the algorithm tends to be quasi- Newtonian. If, the algorithm tends to the gradient method. Roughly, the algorithm is the following: (1) = 0.001 (2) J, and are computed (where = and = ) (3) Quasi- Newton system is solved ( "# = "# +. ) (4) As long as J is decreasing, is divided by 10 - > to (3) (tends to quasi- Newton) (5) As soon as J is increasing, is multiplied by 10 - > to (2) (tends to gradient step) The global convergence is achieved when the relative difference between two successive J values is lower than a predefined small value. Annex 4: The matlab structure used in the program. We are only giving the main components of this structure. par(k).f1.f2 is the sub- field f2 of field f1 of experience n k. The parameters come directly (m) or are derived (d) from the menu window reading. F1 F2 Rôle Variable(s) menu m/d = Model dt Model integration time step TStep (e) m fc Total integration time (divided by t a) frcst (e) d 0.01*frcst Obs dob Spacing between obs (in time steps) Sampl (p) m Obs nob Observations number d da/dt Obs iob Observations indices in vectors d 1+(1:nob)*dob Obs tob Observations times vector d (1:nob)*ta/nob Obs NVar Observation noise variance NoisV (e) m Obs Crl Indices of controled variables Crli (e) (i=1:nv) d find([crl1 crl2...]) Obs H Observation operator d I nv(crl,:) Obs Rtrue Real meas. error covariance matrix d NVar*I nv Obs R0 Initial meas. Error covariance matrix R0entr (e) / R (m) d R0entr*Rtrue/R 1 Assim algo Assimilation algorithm Method (p) m Assim Ta Temps d assimilation WSize (p) m Assim Na Assimilation time (in time steps) d ta/dt Assim Nt Total integration time steps number d fc.ta/dt Bkg Btrue True background error cov. matrix Bscal (e) d 0.01*Bscal*Bclim Bkg B0 Initial background error cov. Matrix B0entr (e) / B (m) d B0entr*Btrue/B 1,2
1 Two possible modes for R0 and B0 computing : keep a fraction of the exact matrix ; then, R0entr is used. full manual mode is used ; then, R parameter menu is used. 2 Matrix R0 is restricted to the controlled variables, indicated by the vector Crl. Note : Inv is a nv*nv identity matrix, where nv is the number of variables. Annex 5: References. [1] Edward N. Lorenz, Deterministic nonperiodic flow, J. atmos. Sci., 20, 130-141, 1963 [2] Saltzman, B., Finite amplitude free convection as an initial value problem I, J. atmos. Sci., 19, 329-341, 1962 [3] Bouttier, F. ; Courtier, P, D Data assimilation concepts and methods, ECMWF Lecture Notes, 1999