1% Solve the variational problem with the contraints from EOFs. 2% 3% [fi,s] = divand_solve_eof(s,yo,EOF_lambda,EOF) 4% 5% Derive the analysis based on all contraints included in s and using the 6% observations yo and EOFs 7% 8% Input: 9% s: structure created by divand_factorize 10% yo: value of the observations 11% EOF_lambda: weight of each EOF (adimentional) 12% EOF: matrix containing the EOFs (units m^(-n/2)) 13% 14% Output: 15% fi: analyzed field 16% s.E: scaled EOFs 17 18 19function [fi,s] = divand_solve_eof(s,yo,EOF_lambda,EOF) 20 21H = s.H; 22sv = s.sv; 23R = s.R; 24P = s.P; 25E = s.E; 26 27 28r = size(E,2); 29 30%E = zeros(s.sv.n,r); 31%for i=1:r 32% E(:,i) = statevector_pack(sv,EOF(:,i)); 33%end 34 35yo2 = (H'* (R \ yo(:))); 36 37% "classical analysis" 38xa = P * yo2; 39 40% apply Pa to all EOFs 41PaE = P * E; 42 43%keyboard 44 45M = E'*PaE - eye(r); 46 47% analysis with EOFs 48xa = xa - PaE * pinv(M) * (E'*xa); 49 50[fi] = statevector_unpack(sv,xa); 51 52fi(~s.mask) = NaN; 53 54 55% debugging information 56s.cond = cond(M); 57%lam = eig(M); 58%s.lambda_min = min(lam); 59 60% Copyright (C) 2014 Alexander Barth <a.barth@ulg.ac.be> 61% 62% This program is free software; you can redistribute it and/or modify it under 63% the terms of the GNU General Public License as published by the Free Software 64% Foundation; either version 2 of the License, or (at your option) any later 65% version. 66% 67% This program is distributed in the hope that it will be useful, but WITHOUT 68% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 69% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 70% details. 71% 72% You should have received a copy of the GNU General Public License along with 73% this program; if not, see <http://www.gnu.org/licenses/>. 74