-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPart_2_Ex_1.m
More file actions
58 lines (49 loc) · 2 KB
/
Part_2_Ex_1.m
File metadata and controls
58 lines (49 loc) · 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
%% Launching the ensemble run
% First, we need to load the configuration file. Let's print the general settings
% in the configuration to ensure we have it right.
clc, clear all;
load("Config_base.mat");
% config.run.todate = '2007-12-31';
disp(config.run)
%%
% We also add the path where all the functions are located to Matlab.
addpath(genpath('./Codes/'));
%%
% Finally, we will set a command to launch the debugger if an error occurs (this
% should not happen).
dbstop if error;
%% The ensemble run
% We will now launch the ensemble run. To keep it simple, in this example the
% 8 model runs will here be run sequentially. In an real DA experiment, this process
% would be parallelized in different threads in order to speed up the computation.
nE = config.ensembleOptions.nE; % Number of ensemble members.
% Perform model run.
for i=1:nE
%%
% First, we need to replace the keyword %n for the number of the ensemble member
% we are processing. Let us also print one of them to make sure the replacement
% was done correctly.
config_ens = config;
% Assign proper directories to each ensemble member:
config_ens.input.pars = strrep(config_ens.input.pars,'%n',num2str(i));
config_ens.input.forcing.prcp = strrep(config_ens.input.forcing.prcp,'%n',num2str(i));
config_ens.states.directory = strrep(config_ens.states.directory,'%n',num2str(i));
disp(config_ens.states.directory)
%%
% We are now ready to launch the model run for this ensemble member:
% Run ensemble member.
RUN_W3RA(config_ens);
end
%% Result extraction
% Now that all the ensembles have been run, we can compute the ensemble-averaged
% results
F02_ensemble_extract_state_results_W3RA(config);
%% Result visualization
% Finally, let us visualize the results of the ensemble run. For that, we can
% use an existing function.
F_visualizeEx1(config)
%% Reflection questions:
%%
% # What can be the benefits and drawbacks of running a distributed model compared
% to a lumped model?
%%