1% Include constraint from EOFs.
2%
3% s = divand_eof_contraint(s,EOF_lambda,EOF)
4%
5% Include the constraint from the EOF and their eigenvalues (EOF_lambda)
6% in the cost function described by the structure s.
7%
8
9function s = divand_eof_contraint(s,EOF_lambda,EOF)
10
11iB = s.iB;
12sv = s.sv;
13WE = s.WE;
14
15coeff = s.coeff;
16
17% remove land points
18E = statevector_pack(sv,EOF);
19% units m^(-n/2)
20
21% normalize by surface
22% for coeff see divand_background.m
23%E = WE * E;
24%EOF_lambda
25
26E = WE^2 * E * diag(sqrt(EOF_lambda / coeff));
27%% units:  m^(n) m^(-n/2) sqrt(m^(-n)) = 1
28
29if 0
30
31BE = iB \ E;
32
33
34
35A = BE * inv(E'*BE - eye(size(E,2)));
36Beof_var = - sum(A .* BE,2);
37
38% scaling factor to enshure that:
39% scaling * inv(iB - E E') has a  variance of 1 far from boundaries
40
41scaling = 1/(1 + mean(Beof_var))
42scaling = 1
43
44%disp('apply scaling')
45E = 1/sqrt(scaling) * E;
46iB = iB/scaling;
47
48s.scaling = scaling;
49
50end
51
52s.E = E;
53s.iB = iB;
54
55% Copyright (C) 2014 Alexander Barth <a.barth@ulg.ac.be>
56%
57% This program is free software; you can redistribute it and/or modify it under
58% the terms of the GNU General Public License as published by the Free Software
59% Foundation; either version 2 of the License, or (at your option) any later
60% version.
61%
62% This program is distributed in the hope that it will be useful, but WITHOUT
63% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
64% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
65% details.
66%
67% You should have received a copy of the GNU General Public License along with
68% this program; if not, see <http://www.gnu.org/licenses/>.
69