-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptimal_univariate_localization_radius_save_output.m
More file actions
239 lines (216 loc) · 11.2 KB
/
Copy pathoptimal_univariate_localization_radius_save_output.m
File metadata and controls
239 lines (216 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
%% Saves output from EnKF with different univariate localization radii
%
% Author: Zofia Stanley
%% Set fixed parameters
params = struct('K',36,'J',10,'F',10,'a',10,'b',10,'h',2); %L96 params
Nt = 3000; % Number of assimilation cycles
sigma2Y = 0.005; % Y obs error variance
sigma2X = 0.28; % X obs error variance
Ne = 20; % Ensemble size
x_position = 'middle'; % Where is X_k located? (middle or first)
rInf = sqrt(1.21); % Inflation factor
Adapt_Inf = true; % Use adaptive inflation or constant inflation?
True_Fcast_Err = false; % Save true forecast error correlations?
Ntrial = 3; % Number of trials
loc_rad = [5, 10, 15, 20, 30, 45]; % localization radii
%% Run Experiments
% 1. All Y, No X
fprintf('All Y, No X.\n')
dtObs = 0.005; % Time between assimilation cycles
Frac_Obs_Y = 1; % Fraction of Y variables that are observed
Frac_Obs_X = 0; % Fraction of X variables that are observed
% Initialize arrays
RMSE_Y_YnoX_UVGC = zeros(1, length(loc_rad));
RMSE_X_YnoX_UVGC = zeros(1, length(loc_rad));
RMSE_Y_YnoX_UVBW = zeros(1, length(loc_rad));
RMSE_X_YnoX_UVBW = zeros(1, length(loc_rad));
RMSE_Y_YnoX_UVA = zeros(1, length(loc_rad));
RMSE_X_YnoX_UVA = zeros(1, length(loc_rad));
RMSE_Y_YnoX_UVW = zeros(1, length(loc_rad));
RMSE_X_YnoX_UVW = zeros(1, length(loc_rad));
% 1A. Gaspari-Cohn
fprintf('\nGaspari-Cohn\n')
loc_fun_name = 'gaspari_cohn' ; % localization function name
for ii = 1:length(loc_rad)
R = loc_rad(ii);
loc_params = struct('rYY', R, 'rXX', R, 'beta', 1); % localization parameters
[RMSE_Y, RMSE_X] = L96_EnKF_Multitrial(params, Nt, dtObs, sigma2Y, sigma2X,...
Frac_Obs_Y, Frac_Obs_X, Ne, x_position, rInf, Adapt_Inf, ...
loc_fun_name, loc_params, True_Fcast_Err, Ntrial);
RMSE_Y_YnoX_UVGC(ii) = mean(reshape(RMSE_Y(:, 1001:end), 1, []));
RMSE_X_YnoX_UVGC(ii) = mean(reshape(RMSE_X(:, 1001:end), 1, []));
end
save('optimal_univariate_localization_radius.mat', 'loc_rad', 'RMSE_Y_YnoX_UVGC', 'RMSE_X_YnoX_UVGC')
% 1B. Bolin-Wallin
fprintf('\nBolin-Wallin\n')
loc_fun_name = 'bolin_wallin' ;
for ii = 1:length(loc_rad)
R = loc_rad(ii);
loc_params = struct('rYY', R, 'rXX', R, 'beta', 1);
[RMSE_Y, RMSE_X] = L96_EnKF_Multitrial(params, Nt, dtObs, sigma2Y, sigma2X,...
Frac_Obs_Y, Frac_Obs_X, Ne, x_position, rInf, Adapt_Inf, ...
loc_fun_name, loc_params, True_Fcast_Err, Ntrial);
RMSE_Y_YnoX_UVBW(ii) = mean(reshape(RMSE_Y(:, 1001:end), 1, []));
RMSE_X_YnoX_UVBW(ii) = mean(reshape(RMSE_X(:, 1001:end), 1, []));
end
save('optimal_univariate_localization_radius.mat', 'RMSE_Y_YnoX_UVBW', 'RMSE_X_YnoX_UVBW', '-append')
% 1C. Askey
fprintf('\nAskey\n')
loc_fun_name = 'askey' ;
for ii = 1:length(loc_rad)
R = loc_rad(ii);
loc_params = struct('rYY', R, 'rXX', R, 'rXY', R, 'nu', 1, 'gammaYY', 0, 'gammaXX', 0, 'gammaXY', 0,'beta', 1);
[RMSE_Y, RMSE_X] = L96_EnKF_Multitrial(params, Nt, dtObs, sigma2Y, sigma2X,...
Frac_Obs_Y, Frac_Obs_X, Ne, x_position, rInf, Adapt_Inf, ...
loc_fun_name, loc_params, True_Fcast_Err, Ntrial);
RMSE_Y_YnoX_UVA(ii) = mean(reshape(RMSE_Y(:, 1001:end), 1, []));
RMSE_X_YnoX_UVA(ii) = mean(reshape(RMSE_X(:, 1001:end), 1, []));
end
save('optimal_univariate_localization_radius.mat', 'RMSE_Y_YnoX_UVA', 'RMSE_X_YnoX_UVA', '-append')
% 1D. Wendland
fprintf('\nWendland\n')
loc_fun_name = 'wendland' ;
for ii = 1:length(loc_rad)
R = loc_rad(ii);
loc_params = struct('rYY', R, 'rXX', R, 'rXY', R, 'nu', 2, 'gammaYY', 0, 'gammaXX', 0, 'gammaXY', 0, 'k', 1, 'beta', 1);
[RMSE_Y, RMSE_X] = L96_EnKF_Multitrial(params, Nt, dtObs, sigma2Y, sigma2X,...
Frac_Obs_Y, Frac_Obs_X, Ne, x_position, rInf, Adapt_Inf, ...
loc_fun_name, loc_params, True_Fcast_Err, Ntrial);
RMSE_Y_YnoX_UVW(ii) = mean(reshape(RMSE_Y(:, 1001:end), 1, []));
RMSE_X_YnoX_UVW(ii) = mean(reshape(RMSE_X(:, 1001:end), 1, []));
end
save('optimal_univariate_localization_radius.mat', 'RMSE_Y_YnoX_UVW', 'RMSE_X_YnoX_UVW', '-append')
% 2. All X, No Y
fprintf('\nAll X, No Y.\n')
dtObs = 0.05; % Time between assimilation cycles
Frac_Obs_Y = 0; % Fraction of Y variables that are observed
Frac_Obs_X = 1; % Fraction of X variables that are observed
% Initialize arrays
RMSE_Y_XnoY_UVGC = zeros(1, length(loc_rad));
RMSE_X_XnoY_UVGC = zeros(1, length(loc_rad));
RMSE_Y_XnoY_UVBW = zeros(1, length(loc_rad));
RMSE_X_XnoY_UVBW = zeros(1, length(loc_rad));
RMSE_Y_XnoY_UVA = zeros(1, length(loc_rad));
RMSE_X_XnoY_UVA = zeros(1, length(loc_rad));
RMSE_Y_XnoY_UVW = zeros(1, length(loc_rad));
RMSE_X_XnoY_UVW = zeros(1, length(loc_rad));
% 2A. Gaspari-Cohn
fprintf('\nGaspari-Cohn\n')
loc_fun_name = 'gaspari_cohn' ; % localization function name
for ii = 1:length(loc_rad)
R = loc_rad(ii);
loc_params = struct('rYY', R, 'rXX', R, 'beta', 1); % localization parameters
[RMSE_Y, RMSE_X] = L96_EnKF_Multitrial(params, Nt, dtObs, sigma2Y, sigma2X,...
Frac_Obs_Y, Frac_Obs_X, Ne, x_position, rInf, Adapt_Inf, ...
loc_fun_name, loc_params, True_Fcast_Err, Ntrial);
RMSE_Y_XnoY_UVGC(ii) = mean(reshape(RMSE_Y(:, 1001:end), 1, []));
RMSE_X_XnoY_UVGC(ii) = mean(reshape(RMSE_X(:, 1001:end), 1, []));
end
save('optimal_univariate_localization_radius.mat', 'RMSE_Y_XnoY_UVGC', 'RMSE_X_XnoY_UVGC', '-append')
% 2B. Bolin-Wallin
fprintf('\nBolin-Wallin\n')
loc_fun_name = 'bolin_wallin' ;
for ii = 1:length(loc_rad)
R = loc_rad(ii);
loc_params = struct('rYY', R, 'rXX', R, 'beta', 1);
[RMSE_Y, RMSE_X] = L96_EnKF_Multitrial(params, Nt, dtObs, sigma2Y, sigma2X,...
Frac_Obs_Y, Frac_Obs_X, Ne, x_position, rInf, Adapt_Inf, ...
loc_fun_name, loc_params, True_Fcast_Err, Ntrial);
RMSE_Y_XnoY_UVBW(ii) = mean(reshape(RMSE_Y(:, 1001:end), 1, []));
RMSE_X_XnoY_UVBW(ii) = mean(reshape(RMSE_X(:, 1001:end), 1, []));
end
save('optimal_univariate_localization_radius.mat', 'RMSE_Y_XnoY_UVBW', 'RMSE_X_XnoY_UVBW', '-append')
% 2C. Askey
fprintf('\nAskey\n')
loc_fun_name = 'askey' ;
for ii = 1:length(loc_rad)
R = loc_rad(ii);
loc_params = struct('rYY', R, 'rXX', R, 'rXY', R, 'nu', 1, 'gammaYY', 0, 'gammaXX', 0, 'gammaXY', 0,'beta', 1);
[RMSE_Y, RMSE_X] = L96_EnKF_Multitrial(params, Nt, dtObs, sigma2Y, sigma2X,...
Frac_Obs_Y, Frac_Obs_X, Ne, x_position, rInf, Adapt_Inf, ...
loc_fun_name, loc_params, True_Fcast_Err, Ntrial);
RMSE_Y_XnoY_UVA(ii) = mean(reshape(RMSE_Y(:, 1001:end), 1, []));
RMSE_X_XnoY_UVA(ii) = mean(reshape(RMSE_X(:, 1001:end), 1, []));
end
save('optimal_univariate_localization_radius.mat', 'RMSE_Y_XnoY_UVA', 'RMSE_X_XnoY_UVA', '-append')
% 2D. Wendland
fprintf('\nWendland\n')
loc_fun_name = 'wendland' ;
for ii = 1:length(loc_rad)
R = loc_rad(ii);
loc_params = struct('rYY', R, 'rXX', R, 'rXY', R, 'nu', 2, 'gammaYY', 0, 'gammaXX', 0, 'gammaXY', 0, 'k', 1, 'beta', 1);
[RMSE_Y, RMSE_X] = L96_EnKF_Multitrial(params, Nt, dtObs, sigma2Y, sigma2X,...
Frac_Obs_Y, Frac_Obs_X, Ne, x_position, rInf, Adapt_Inf, ...
loc_fun_name, loc_params, True_Fcast_Err, Ntrial);
RMSE_Y_XnoY_UVW(ii) = mean(reshape(RMSE_Y(:, 1001:end), 1, []));
RMSE_X_XnoY_UVW(ii) = mean(reshape(RMSE_X(:, 1001:end), 1, []));
end
save('optimal_univariate_localization_radius.mat', 'RMSE_Y_XnoY_UVW', 'RMSE_X_XnoY_UVW', '-append')
% 3. Both X and Y
fprintf('\nBoth X and Y.\n')
dtObs = 0.005; % Time between assimilation cycles
Frac_Obs_Y = 0.75; % Fraction of Y variables that are observed
Frac_Obs_X = 0.75; % Fraction of X variables that are observed
sigma2Y = 0.01; % Y obs error variance
sigma2X = 0.57; % X obs error variance
% Initialize arrays
RMSE_Y_BothXY_UVGC = zeros(1, length(loc_rad));
RMSE_X_BothXY_UVGC = zeros(1, length(loc_rad));
RMSE_Y_BothXY_UVBW = zeros(1, length(loc_rad));
RMSE_X_BothXY_UVBW = zeros(1, length(loc_rad));
RMSE_Y_BothXY_UVA = zeros(1, length(loc_rad));
RMSE_X_BothXY_UVA = zeros(1, length(loc_rad));
RMSE_Y_BothXY_UVW = zeros(1, length(loc_rad));
RMSE_X_BothXY_UVW = zeros(1, length(loc_rad));
% 3A. Gaspari-Cohn
fprintf('\nGaspari-Cohn\n')
loc_fun_name = 'gaspari_cohn' ; % localization function name
for ii = 1:length(loc_rad)
R = loc_rad(ii);
loc_params = struct('rYY', R, 'rXX', R, 'beta', 1); % localization parameters
[RMSE_Y, RMSE_X] = L96_EnKF_Multitrial(params, Nt, dtObs, sigma2Y, sigma2X,...
Frac_Obs_Y, Frac_Obs_X, Ne, x_position, rInf, Adapt_Inf, ...
loc_fun_name, loc_params, True_Fcast_Err, Ntrial);
RMSE_Y_BothXY_UVGC(ii) = mean(reshape(RMSE_Y(:, 1001:end), 1, []));
RMSE_X_BothXY_UVGC(ii) = mean(reshape(RMSE_X(:, 1001:end), 1, []));
end
save('optimal_univariate_localization_radius.mat', 'RMSE_Y_BothXY_UVGC', 'RMSE_X_BothXY_UVGC', '-append')
% 3B. Bolin-Wallin
fprintf('\nBolin-Wallin\n')
loc_fun_name = 'bolin_wallin' ;
for ii = 1:length(loc_rad)
R = loc_rad(ii);
loc_params = struct('rYY', R, 'rXX', R, 'beta', 1);
[RMSE_Y, RMSE_X] = L96_EnKF_Multitrial(params, Nt, dtObs, sigma2Y, sigma2X,...
Frac_Obs_Y, Frac_Obs_X, Ne, x_position, rInf, Adapt_Inf, ...
loc_fun_name, loc_params, True_Fcast_Err, Ntrial);
RMSE_Y_BothXY_UVBW(ii) = mean(reshape(RMSE_Y(:, 1001:end), 1, []));
RMSE_X_BothXY_UVBW(ii) = mean(reshape(RMSE_X(:, 1001:end), 1, []));
end
save('optimal_univariate_localization_radius.mat', 'RMSE_Y_BothXY_UVBW', 'RMSE_X_BothXY_UVBW', '-append')
% 3C. Askey
fprintf('\nAskey\n')
loc_fun_name = 'askey' ;
for ii = 1:length(loc_rad)
R = loc_rad(ii);
loc_params = struct('rYY', R, 'rXX', R, 'rXY', R, 'nu', 1, 'gammaYY', 0, 'gammaXX', 0, 'gammaXY', 0,'beta', 1);
[RMSE_Y, RMSE_X] = L96_EnKF_Multitrial(params, Nt, dtObs, sigma2Y, sigma2X,...
Frac_Obs_Y, Frac_Obs_X, Ne, x_position, rInf, Adapt_Inf, ...
loc_fun_name, loc_params, True_Fcast_Err, Ntrial);
RMSE_Y_BothXY_UVA(ii) = mean(reshape(RMSE_Y(:, 1001:end), 1, []));
RMSE_X_BothXY_UVA(ii) = mean(reshape(RMSE_X(:, 1001:end), 1, []));
end
save('optimal_univariate_localization_radius.mat', 'RMSE_Y_BothXY_UVA', 'RMSE_X_BothXY_UVA', '-append')
% 3D. Wendland
fprintf('\nWendland\n')
loc_fun_name = 'wendland' ;
for ii = 1:length(loc_rad)
R = loc_rad(ii);
loc_params = struct('rYY', R, 'rXX', R, 'rXY', R, 'nu', 2, 'gammaYY', 0, 'gammaXX', 0, 'gammaXY', 0, 'k', 1, 'beta', 1);
[RMSE_Y, RMSE_X] = L96_EnKF_Multitrial(params, Nt, dtObs, sigma2Y, sigma2X,...
Frac_Obs_Y, Frac_Obs_X, Ne, x_position, rInf, Adapt_Inf, ...
loc_fun_name, loc_params, True_Fcast_Err, Ntrial);
RMSE_Y_BothXY_UVW(ii) = mean(reshape(RMSE_Y(:, 1001:end), 1, []));
RMSE_X_BothXY_UVW(ii) = mean(reshape(RMSE_X(:, 1001:end), 1, []));
end
save('optimal_univariate_localization_radius.mat', 'RMSE_Y_BothXY_UVW', 'RMSE_X_BothXY_UVW', '-append')