1 |
gforget |
1.1 |
|
2 |
gforget |
1.5 |
doOmit3Dfields=0; |
3 |
|
|
|
4 |
gforget |
1.1 |
if userStep==1;%diags to be computed |
5 |
gforget |
1.2 |
%here _s stands for cumulative sum and _2s for cumulative sum of squares |
6 |
|
|
%the _s should be stated first |
7 |
gforget |
1.5 |
listDiags=['SIatmQnt_s SIatmFW_s oceQnet_s oceFWflx_s ' ... |
8 |
gforget |
1.2 |
'fldTZ_s fldTM_s curlTau_s fldETAN_s fldETANLEADS_s fldMLD_s ' ... |
9 |
gforget |
1.5 |
'SIatmQnt_2s SIatmFW_2s oceQnet_2s oceFWflx_2s ' ... |
10 |
gforget |
1.2 |
'fldTZ_2s fldTM_2s curlTau_2s fldETAN_2s fldETANLEADS_2s fldMLD_2s']; |
11 |
gforget |
1.5 |
if ~doOmit3Dfields; |
12 |
|
|
listDiags=[listDiags 'THETA_s SALT_s WVELMASS_s THETA_2s SALT_2s WVELMASS_2s']; |
13 |
|
|
end; |
14 |
gforget |
1.4 |
|
15 |
gforget |
1.1 |
elseif userStep==2;%input files and variables |
16 |
gforget |
1.5 |
listFlds={ 'SIatmQnt','SIatmFW ','oceQnet ','oceFWflx','oceTAUX','oceTAUY','ETAN','sIceLoad','MXLDEPTH'}; |
17 |
|
|
if ~doOmit3Dfields; |
18 |
|
|
listFlds={listFlds{:} ,'THETA','SALT','WVELMASS'}; |
19 |
|
|
end; |
20 |
gforget |
1.1 |
listFldsNames=deblank(listFlds); |
21 |
gforget |
1.5 |
listFiles={'state_3d_set1','trsp_3d_set1','state_2d_set1','other_2d_set1'}; |
22 |
|
|
listSubdirs={[dirModel 'diags/OTHER/' ],[dirModel 'diags/STATE/' ],[dirModel 'diags/TRSP/' ]}; |
23 |
gforget |
1.4 |
|
24 |
|
|
elseif userStep==3;%computation |
25 |
gforget |
1.1 |
%mask fields: |
26 |
|
|
SIatmQnt=SIatmQnt.*mygrid.mskC(:,:,1); |
27 |
|
|
SIatmFW=SIatmFW.*mygrid.mskC(:,:,1); |
28 |
|
|
oceQnet=oceQnet.*mygrid.mskC(:,:,1); |
29 |
|
|
oceFWflx=oceFWflx.*mygrid.mskC(:,:,1); |
30 |
|
|
fldTX=oceTAUX.*mygrid.mskW(:,:,1); |
31 |
|
|
fldTY=oceTAUY.*mygrid.mskS(:,:,1); |
32 |
|
|
%compute Eastward/Northward wind stresses: |
33 |
|
|
[fldTZ,fldTM]=calc_UEVNfromUXVY(fldTX,fldTY); |
34 |
|
|
%compute wind stress curl: |
35 |
|
|
curlTau=calc_UV_curl(fldTX, fldTY,1 );%the doMask argument should not matter as msk was already applied |
36 |
|
|
%mask and re-arrange fields: |
37 |
|
|
fldETAN=ETAN.*mygrid.mskC(:,:,1); |
38 |
|
|
fldETANLEADS=(ETAN+sIceLoad/myparms.rhoconst).*mygrid.mskC(:,:,1); |
39 |
|
|
fldMLD=MXLDEPTH.*mygrid.mskC(:,:,1); |
40 |
|
|
% |
41 |
gforget |
1.5 |
if ~doOmit3Dfields; |
42 |
|
|
THETA=THETA.*mygrid.mskC; |
43 |
|
|
SALT=SALT.*mygrid.mskC; |
44 |
|
|
WVELMASS=WVELMASS.*mygrid.mskC; |
45 |
|
|
end; |
46 |
gforget |
1.2 |
% |
47 |
|
|
if ii>1; |
48 |
|
|
fileMatPrev=['diags_set_' tmp1 '_' num2str(listTimes(ii-1)) '.mat']; |
49 |
gforget |
1.4 |
listTimesBak=listTimes; |
50 |
gforget |
1.2 |
load([dirMat fileMatPrev]); |
51 |
gforget |
1.4 |
listTimes=listTimesBak; |
52 |
gforget |
1.2 |
end; |
53 |
|
|
for jj=1:length(listDiags)/2; |
54 |
|
|
myDiag=listDiags{jj}(1:end-2); |
55 |
|
|
if ii==1; |
56 |
|
|
eval([myDiag '_s=0*' myDiag ';']); |
57 |
|
|
eval([myDiag '_2s=0*' myDiag '.^2;']); |
58 |
|
|
end; |
59 |
|
|
eval([myDiag '_s=' myDiag '_s+' myDiag ';']); |
60 |
|
|
eval([myDiag '_2s=' myDiag '_2s+' myDiag '.^2;']); |
61 |
|
|
end; |
62 |
|
|
|
63 |
gforget |
1.4 |
%===================== COMPUTATIONAL SEQUENCE ENDS =========================% |
64 |
|
|
%===================== PLOTTING SEQUENCE BEGINS =========================% |
65 |
|
|
|
66 |
|
|
elseif userStep==0;%loading / post-processing of mat files |
67 |
|
|
|
68 |
|
|
%load last cumsum |
69 |
|
|
alldiag=alldiag_load(dirMat,[fileMat '_*.mat'],'',myparms.recInAve(2)); |
70 |
|
|
%load first cumsum |
71 |
|
|
if myparms.recInAve(1)>1; |
72 |
|
|
tmpdiag=alldiag_load(dirMat,[fileMat '_*.mat'],'',myparms.recInAve(1)-1); |
73 |
|
|
for ii=1:length(alldiag.listDiags); |
74 |
|
|
tmp0=alldiag.listDiags{ii}; |
75 |
|
|
if ~strcmp(tmp0,'listTimes')&~strcmp(tmp0,'listSteps'); |
76 |
|
|
tmp1=getfield(alldiag,alldiag.listDiags{ii}); |
77 |
|
|
tmp2=getfield(tmpdiag,alldiag.listDiags{ii}); |
78 |
|
|
alldiag=setfield(alldiag,tmp0,tmp1-tmp2); |
79 |
|
|
end; |
80 |
|
|
end; |
81 |
|
|
end; |
82 |
|
|
%accomodate missing fields (old MITgcm version) |
83 |
|
|
listFlds={'SIatmQnt_s','oceQnet_s','SIatmFW_s','oceFWflx_s',... |
84 |
gforget |
1.5 |
'THETA_s','SALT_s','WVELMASS_s',... |
85 |
gforget |
1.4 |
'fldTZ_s','fldTM_s','curlTau_s','fldETAN_s','fldETANLEADS_s',... |
86 |
|
|
'SIatmQnt_2s','oceQnet_2s','SIatmFW_2s','oceFWflx_2s',... |
87 |
gforget |
1.5 |
'fldTZ_2s','fldTM_2s','curlTau_2s','fldETAN_2s','fldETANLEADS_2s',... |
88 |
|
|
'THETA_2s','SALT_2s','WVELMASS_2s'}; |
89 |
gforget |
1.4 |
for ii=1:length(listFlds); |
90 |
|
|
if ~sum(strcmp(fieldnames(alldiag),listFlds{ii})); |
91 |
|
|
eval(['alldiag.' listFlds{ii} '=NaN*alldiag.fldETAN_s;']); |
92 |
|
|
end; |
93 |
|
|
end; |
94 |
|
|
% |
95 |
|
|
n=diff(myparms.recInAve)+1; |
96 |
|
|
for ii=1:length(alldiag.listDiags)/2; |
97 |
|
|
tmp0=alldiag.listDiags{ii}; |
98 |
|
|
if ~strcmp(tmp0,'listTimes')&~strcmp(tmp0,'listSteps'); |
99 |
|
|
tmp1=1/n*getfield(alldiag,tmp0); |
100 |
|
|
tmp2=1/n*getfield(alldiag,[tmp0(1:end-1) '2s']); |
101 |
|
|
tmp2=(tmp2-tmp1.^2); |
102 |
|
|
tmp2=n/(n-1)*tmp2; |
103 |
|
|
%tmp2(tmp2<0)=0; |
104 |
|
|
tmp2=sqrt(tmp2); |
105 |
|
|
alldiag=setfield(alldiag,[tmp0(1:end-2) '_mean'],tmp1); |
106 |
|
|
alldiag=setfield(alldiag,[tmp0(1:end-2) '_std'],tmp2); |
107 |
|
|
end; |
108 |
|
|
end; |
109 |
|
|
|
110 |
|
|
diagsWereLoaded=1 |
111 |
|
|
|
112 |
|
|
elseif userStep==-1;%plotting |
113 |
|
|
|
114 |
|
|
if isempty(setDiagsParams); |
115 |
|
|
choicePlot={'all'}; |
116 |
|
|
else; |
117 |
|
|
choicePlot=setDiagsParams; |
118 |
|
|
end; |
119 |
|
|
|
120 |
|
|
if sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'qnet')); |
121 |
|
|
|
122 |
|
|
%qnet from ocean+ice: |
123 |
|
|
fld=-alldiag.SIatmQnt_mean; |
124 |
|
|
cc=[[-250:50:-100] [-75 -50] [-35:10:35] [50 75] [100:50:250]]; title0='QNET to ocean+ice'; |
125 |
|
|
if doAnomalies; cc=scaleAnom*[-1:0.1:1]*10; end; |
126 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
127 |
|
|
myCaption={myYmeanTxt,'mean -- QNET to ocean+ice (W/m2)'}; |
128 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
129 |
|
|
|
130 |
|
|
%qnet to ocean: |
131 |
|
|
fld=alldiag.oceQnet_mean; |
132 |
|
|
cc=[[-250:50:-100] [-75 -50] [-35:10:35] [50 75] [100:50:250]]; title0='QNET to ocean'; |
133 |
|
|
if doAnomalies; cc=scaleAnom*[-1:0.1:1]*10; end; |
134 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
135 |
|
|
myCaption={myYmeanTxt,'mean -- QNET to ocean (W/m2)'}; |
136 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
137 |
|
|
|
138 |
|
|
if multiTimes; |
139 |
|
|
%qnet from ocean+ice: |
140 |
|
|
fld=alldiag.SIatmQnt_std; |
141 |
|
|
cc=[[0:5:25] 35 [50:25:200] [250 300]]; title0='std(QNET to ocean+ice)'; |
142 |
|
|
if doAnomalies; cc=scaleAnom*[0:0.1:1]*5; end; |
143 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
144 |
|
|
myCaption={myYmeanTxt,' standard deviation -- QNET to ocean+ice (W/m2)'}; |
145 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
146 |
|
|
|
147 |
|
|
%qnet from ocean: |
148 |
|
|
fld=alldiag.oceQnet_std; |
149 |
|
|
cc=[[0:5:25] 35 [50:25:200] [250 300]]; title0='std(QNET to ocean)'; |
150 |
|
|
if doAnomalies; cc=scaleAnom*[0:0.1:1]*5; end; |
151 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
152 |
|
|
myCaption={myYmeanTxt,' standard deviation -- QNET to ocean (W/m2)'}; |
153 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
154 |
|
|
end; |
155 |
|
|
|
156 |
|
|
end; |
157 |
|
|
|
158 |
|
|
|
159 |
|
|
if sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'fwf')); |
160 |
|
|
|
161 |
|
|
%FW flux from ocean+ice: |
162 |
|
|
fld=-alldiag.SIatmFW_mean/1000;%conversion to m/s |
163 |
|
|
fld=fld*86400*1000;%conversion to mm/day |
164 |
|
|
cc=[[-250:50:-100] [-75 -50] [-35:10:35] [50 75] [100:50:250]]*0.06; title0='EMPMR to ocean+ice'; |
165 |
|
|
if doAnomalies; cc=scaleAnom*[-1:0.1:1]*0.5; end; |
166 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
167 |
|
|
myCaption={myYmeanTxt,'mean -- EMPMR from ocean+ice (mm/day)'}; |
168 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
169 |
|
|
|
170 |
|
|
%FW flux from ocean: |
171 |
|
|
fld=-alldiag.oceFWflx_mean/1000;%conversion to m/s |
172 |
|
|
fld=fld*86400*1000;%conversion to mm/day |
173 |
|
|
cc=[[-250:50:-100] [-75 -50] [-35:10:35] [50 75] [100:50:250]]*0.06; title0='EMPMR to ocean'; |
174 |
|
|
if doAnomalies; cc=scaleAnom*[-1:0.1:1]*0.5; end; |
175 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
176 |
|
|
myCaption={myYmeanTxt,'mean -- EMPMR from ocean (mm/day)'}; |
177 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
178 |
|
|
|
179 |
|
|
if multiTimes; |
180 |
|
|
%empmr from ocean+ice: |
181 |
|
|
fld=alldiag.SIatmFW_std*86400;%conversion to mm/day |
182 |
|
|
cc=[[0:5:25] 35 [50:25:200] [250 300]]*0.04; title0='std(EMPMR to ocean+ice)'; |
183 |
|
|
if doAnomalies; cc=scaleAnom*[0:0.1:1]*0.5; end; |
184 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
185 |
|
|
myCaption={myYmeanTxt,' standard deviation -- EMPMR to ocean+ice (W/m2)'}; |
186 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
187 |
|
|
|
188 |
|
|
%empmr from ocean: |
189 |
|
|
fld=alldiag.oceFWflx_std*86400;%conversion to mm/day |
190 |
|
|
cc=[[0:5:25] 35 [50:25:200] [250 300]]*0.04; title0='std(EMPMR to ocean)'; |
191 |
|
|
if doAnomalies; cc=scaleAnom*[0:0.1:1]*0.5; end; |
192 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
193 |
|
|
myCaption={myYmeanTxt,' standard deviation -- EMPMR to ocean (W/m2)'}; |
194 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
195 |
|
|
end; |
196 |
|
|
|
197 |
|
|
end; |
198 |
|
|
|
199 |
|
|
if sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'tau')); |
200 |
|
|
|
201 |
|
|
%zonal wind stress: |
202 |
|
|
fld=alldiag.fldTZ_mean; |
203 |
|
|
cc=[[-250:50:-100] [-75 -50] [-35:10:35] [50 75] [100:50:250]]/500; title0='zonal wind stress'; |
204 |
|
|
if doAnomalies; cc=scaleAnom*[-1:0.1:1]*0.01; end; |
205 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
206 |
|
|
myCaption={myYmeanTxt,'mean -- zonal wind stress (N/m2)'}; |
207 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
208 |
|
|
|
209 |
|
|
%meridional wind stress: |
210 |
|
|
fld=alldiag.fldTM_mean; |
211 |
|
|
cc=[[-250:50:-100] [-75 -50] [-35:10:35] [50 75] [100:50:250]]/500; title0='meridional wind stress'; |
212 |
|
|
if doAnomalies; cc=scaleAnom*[-1:0.1:1]*0.01; end; |
213 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
214 |
|
|
myCaption={myYmeanTxt,'mean -- meridional wind stress (N/m2)'}; |
215 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
216 |
|
|
|
217 |
|
|
fld=alldiag.curlTau_mean; |
218 |
|
|
cc=[[-250:50:-100] [-75 -50] [-35:10:35] [50 75] [100:50:250]]/5e8; title0='wind stress curl'; |
219 |
|
|
if doAnomalies; cc=scaleAnom*[-1:0.1:1]*0.01; end; |
220 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
221 |
|
|
myCaption={myYmeanTxt,'mean -- wind stress curl (N/m3)'}; |
222 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
223 |
|
|
|
224 |
|
|
if multiTimes; |
225 |
|
|
%zonal wind stress: |
226 |
|
|
fld=alldiag.fldTZ_std; |
227 |
|
|
cc=[[0:5:25] 35 [50:25:200] [250 300]]/2000; title0='std(tauZ)'; |
228 |
|
|
if doAnomalies; cc=scaleAnom*[0:0.1:1]*0.005; end; |
229 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
230 |
|
|
myCaption={myYmeanTxt,' standard deviation -- tauZ (W/m2)'}; |
231 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
232 |
|
|
|
233 |
|
|
%meridional wind stress: |
234 |
|
|
fld=alldiag.fldTM_std; |
235 |
|
|
cc=[[0:5:25] 35 [50:25:200] [250 300]]/2000; title0='std(tauM)'; |
236 |
|
|
if doAnomalies; cc=scaleAnom*[0:0.1:1]*0.005; end; |
237 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
238 |
|
|
myCaption={myYmeanTxt,' standard deviation -- tauM (W/m2)'}; |
239 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
240 |
|
|
|
241 |
|
|
fld=alldiag.curlTau_std; |
242 |
|
|
cc=[[0:5:25] 35 [50:25:200] [250 300]]/1e9; title0='wind stress curl'; |
243 |
|
|
if doAnomalies; cc=scaleAnom*[-1:0.1:1]*0.01; end; |
244 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
245 |
|
|
myCaption={myYmeanTxt,'standard deviation -- tauCurl (N/m3)'}; |
246 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
247 |
|
|
end; |
248 |
|
|
|
249 |
|
|
end; |
250 |
|
|
|
251 |
|
|
if sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'ssh')); |
252 |
|
|
|
253 |
|
|
%ETAN: |
254 |
|
|
fld=alldiag.fldETAN_mean; |
255 |
|
|
cc=[[-250:50:-100] [-75 -50] [-35:10:35] [50 75] [100:50:250]]/100; title0='sea surface height (EXCLUDING ice)'; |
256 |
|
|
if doAnomalies; cc=scaleAnom*[-1:0.1:1]*0.05; end; |
257 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
258 |
|
|
myCaption={myYmeanTxt,'mean -- sea surface height (EXCLUDING ice, in m)'}; |
259 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
260 |
|
|
|
261 |
|
|
%ETANLEADS: |
262 |
|
|
fld=alldiag.fldETANLEADS_mean; |
263 |
|
|
cc=[[-250:50:-100] [-75 -50] [-35:10:35] [50 75] [100:50:250]]/100; title0='sea surface height (INCLUDING ice)'; |
264 |
|
|
if doAnomalies; cc=scaleAnom*[-1:0.1:1]*0.05; end; |
265 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
266 |
|
|
myCaption={myYmeanTxt,'mean -- sea surface height (INCLUDING ice, in m)'}; |
267 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
268 |
|
|
|
269 |
|
|
if multiTimes; |
270 |
|
|
%ETAN: |
271 |
|
|
fld=alldiag.fldETAN_std; |
272 |
|
|
cc=[0:25:500]/2500; title0='std(ETAN)'; |
273 |
|
|
if doAnomalies; cc=scaleAnom*[0:0.1:1]*0.02; end; |
274 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
275 |
|
|
myCaption={myYmeanTxt,' standard deviation -- sea surface height (EXCLUDING ice, in m)'}; |
276 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
277 |
|
|
|
278 |
|
|
%ETANLEADS: |
279 |
|
|
fld=alldiag.fldETANLEADS_std; |
280 |
|
|
cc=[0:25:500]/2500; title0='std(ETANLEADS)'; |
281 |
|
|
if doAnomalies; cc=scaleAnom*[0:0.1:1]*0.02; end; |
282 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'do_m_coast',1},{'myTitle',title0}); |
283 |
|
|
myCaption={myYmeanTxt,' standard deviation -- sea surface height (INCLUDING ice, in m)'}; |
284 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
285 |
|
|
end; |
286 |
|
|
|
287 |
|
|
end; |
288 |
|
|
|
289 |
gforget |
1.1 |
end; |
290 |
gforget |
1.4 |
|
291 |
|
|
|