-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
269 lines (179 loc) · 8.73 KB
/
main.m
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
% --------------------------------------------------------------------
% main script to postprocess and visualise CESM output: CTL and IRR
% --------------------------------------------------------------------
tic
% clean up
clc;
clear;
close all;
clearvars;
% flags
flags.loadlinear = 0; % 0: do not load data using linear regression method
% 1: load data using linear regression
flags.loadsens = 1; % 0: do not load data using sen's slope method
% 1: load data using sen's slope method
flags.loadCA = 0; % 0: do not load CA data using linear regression method
% 1: load CA data using linear regression method
flags.loadCAsens = 0; % 0: do not load CA data using sens slope method
% 1: load CA data using sens slope method
flags.eval = 0; % 0: do not evaluate model
% 1: evaluate model
flags.evalthesis = 0; % 0: do not evaluate model
% 1: evaluate model
flags.evalpriorfieldmean = 0; % 0: do not evaluate model
% 1: evaluate model
flags.evalpriorfieldmeanCA = 0; % 0: do not evaluate model
% 1: evaluate model
flags.stat = 0; % 0: do not compute statistical significance of change
% 1: compute statistical significance of change
flags.STCD = 0; % 0: do not decompose the Surface Temperature change
% 1: decompose the Surface Temperature change
flags.perc = 0; % 0: do not compute percentile changes
% 1: compute percentile changes
flags.offli = 0; % 0: do not process offline simulations
% 1: process offline simulations
flags.valp = 0; % 0: do not compute values used in the paper
% 1: compute values used in the paper
flags.plot = 1; % 0: do not plot
% 1: plot
flags.plotCA = 0; % 0: do not plot CA
% 1: plot
flags.local = 0; % 0: do not compute local effect
% 1: compute local effect
flags.localthesis = 0; % 0: no local effects computation
% 1: compute local effect
% --------------------------------------------------------------------
% initialisation
% --------------------------------------------------------------------
% declare globals
global island %#ok<NUSED>
% add matlab scripts directory to path
addpath(genpath('C:Users\e200157\Documents\CESM_new'));
% add directory containing nc files to path
addpath(genpath('C:\Users\e200157\Documents\CESM_new\ncfiles'));
% initialise model parameters
nens = 5; % number of ensemble members
% initialise time parameters - CESM
time_begin = [1981, 1, 1, 0,0,0];
time_end = [2010,12,31,23,0,0];
years = (time_begin(1):time_end(1))';
nyears = length(years);
% initialise time parameters - analysis based on Donat
time_begin2 = [1951, 1, 1, 0,0,0];
years2 = (time_begin2(1):time_end(1))';
nyears2 = length(years);
% initialise physical constants
[Lvap, rhow, a_earth] = mf_inicon('Lvap', 'rhow', 'a_earth');
% initialise srex variable/unit/region names - TSA
srex_vars = {'QIRRIG' , 'TSA' , 'Qle' , 'FSH' , 'FSA' , 'FIRA' , 'PRECT' , 'QRUNOFF' }; % srex variables considered in this study ...
srex_ylabels = {'Q_i_r_r' , 'T_2_m', 'LHF' , 'SHF' , 'SW_n_e_t', 'LW_n_e_t', 'Precipitation', 'Q_R_U_N_O_F_F' }; % ... their y-axis label,
srex_units = {'mm d^-^1', 'K' , 'W m^-^1', 'W m^-^1', 'W m^-^1' , 'W m^-^1' , 'mm d^-^1' , 'mm d^-^1' }; % ... their units,
srex_block = {'lnd' , 'lnd' , 'lnd' , 'lnd' , 'lnd' , 'lnd' , 'atm' , 'lnd' }; % ... and whether it's a land or atmospheric variable
srex_reg = {'WNA', 'CNA', 'MED', 'WAS', 'SAS', 'SEA', 'EAS'}; %for IRR % srex regions considered in this study
%srex_reg = {'WNA', 'CNA', 'MED','CEU','SSA', 'SAU'}; %for CA
%in for srex_ctl i=1:length(srex_vars), the 8 x7x5 is variables by regions
%so srex_ctl loads tempt/SHF etc average at regions, squeezed into 1D
%so use slope instead
% initialise observational product names
%prod_names = {'Qirr census', 'LHF LandFlux', 'LHF GLEAM', 'SWnet SRB', 'LWnet SRB', 'T2m CRU', ' Precipitation CRU', ' Precipitation GPCP', 'TXx GHCNDEX', 'TXx HadEx2', 'TNn GHCNDEX', 'TNn HadEx2'};
prod_names = {'T2m CRU', 'TXx GHCNDEX', 'TXx HadEx2'};
% --------------------------------------------------------------------
% load data using linear regression
% --------------------------------------------------------------------
if flags.loadlinear == 1
ms_load;
end
% --------------------------------------------------------------------
% load data using Sen's slope regression
% --------------------------------------------------------------------
if flags.loadsens == 1
ms_loadsens2;
end
% --------------------------------------------------------------------
% load CA data using linear regression
% --------------------------------------------------------------------
if flags.loadCA == 1
ms_loadCA;
end
% --------------------------------------------------------------------
% load CA data using SENS SLOPE
% --------------------------------------------------------------------
if flags.loadCAsens == 1
ms_loadCAsens;
end
% --------------------------------------------------------------------
% manipulations: general
% --------------------------------------------------------------------
ms_manip
% --------------------------------------------------------------------
% CA mask
% --------------------------------------------------------------------
ca_mask_cesm
% --------------------------------------------------------------------
% Model evaluation
% --------------------------------------------------------------------
if flags.eval == 1
ms_evaluation;
end
% --------------------------------------------------------------------
% Model evaluation for thesis-specific
% --------------------------------------------------------------------
if flags.evalthesis == 1
ms_evalthesis;
end
% --------------------------------------------------------------------
% Model evaluation for thesis - using fieldmean without 'area' spatialing
% --------------------------------------------------------------------
if flags.evalpriorfieldmean == 1
ms_eval_priorfieldmean;
end
% --------------------------------------------------------------------
% Model evaluation for thesis - using fieldmean without 'area' spatialing
% CA
% --------------------------------------------------------------------
if flags.evalpriorfieldmeanCA == 1
ms_eval_priorfieldmeanCA;
end
% --------------------------------------------------------------------
% Statistical significance
% --------------------------------------------------------------------
if flags.stat == 1
ms_statsign;
end
% --------------------------------------------------------------------
% Surface Energy Balance decomposition
% --------------------------------------------------------------------
if flags.STCD == 1
ms_STCdecomp
end
% --------------------------------------------------------------------
% Percentile change
% --------------------------------------------------------------------
if flags.perc == 1
ms_perc
end
% --------------------------------------------------------------------
% get values used in the paper
% --------------------------------------------------------------------
if flags.valp == 1
ms_valp
end
% --------------------------------------------------------------------
% visualise output
% --------------------------------------------------------------------
if flags.plot == 1
ms_plotscriptTHESIS
end
if flags.plotCA == 1
ms_plotscriptTHESISCA
end
% --------------------------------------------------------------------
% local effects
% --------------------------------------------------------------------
if flags.local == 1
ms_local
end
if flags.localthesis == 1
ms_localthesis
end
toc