1 |
gforget |
1.7 |
function []=cost_altimeter(dirModel,dirMat); |
2 |
|
|
%object: compute or plot the various sea level statistics |
3 |
|
|
% (std model-obs, model, obs, leading to cost function terms) |
4 |
|
|
%inputs: dirModel is the model run directory |
5 |
|
|
% dirMat is the directory where diagnozed .mat files will be saved |
6 |
|
|
% -> set it to '' to use the default [dirModel 'mat/'] |
7 |
|
|
% doComp is the switch from computation to plot |
8 |
gforget |
1.13 |
|
9 |
gforget |
1.19 |
4.2 |
10 |
|
|
|
11 |
gforget |
1.4 |
doComp=1; |
12 |
|
|
if doComp==1; |
13 |
gforget |
1.11 |
doSave=1; |
14 |
|
|
doPlot=0; |
15 |
gforget |
1.4 |
else; |
16 |
gforget |
1.11 |
doSave=0; |
17 |
|
|
doPlot=1; |
18 |
gforget |
1.4 |
end; |
19 |
|
|
doPrint=0; |
20 |
|
|
|
21 |
gforget |
1.14 |
%%%%%%%%%%% |
22 |
|
|
%load grid: |
23 |
|
|
%%%%%%%%%%% |
24 |
|
|
|
25 |
|
|
gcmfaces_global; |
26 |
|
|
if ~isfield(mygrid,'XC'); grid_load('./GRID/',5,'compact'); end; |
27 |
|
|
if ~isfield(mygrid,'LATS_MASKS'); gcmfaces_lines_zonal; end; |
28 |
|
|
|
29 |
|
|
%%%%%%%%%%%%%%% |
30 |
|
|
%define pathes: |
31 |
|
|
%%%%%%%%%%%%%%% |
32 |
|
|
|
33 |
gforget |
1.19 |
%search for nctiles files |
34 |
|
|
useNctiles=0; |
35 |
|
|
dirNctiles=[dirModel 'nctiles_remotesensing/sealevel/']; |
36 |
|
|
if ~isempty(dir(dirNctiles)); useNctiles=1; end; |
37 |
|
|
|
38 |
|
|
nameSigma={'sigma_MDT_glob_eccollc.bin','slaerr_largescale_r5.err','slaerr_gridscale_r5.err'}; maxLatObs=90 |
39 |
|
|
|
40 |
|
|
dirSigma=dirModel; |
41 |
|
|
if ~isempty(dir([dirModel 'inputfiles/' nameSigma{1}])); |
42 |
gforget |
1.17 |
dirSigma=[dirModel 'inputfiles/']; |
43 |
gforget |
1.14 |
end; |
44 |
|
|
|
45 |
gforget |
1.19 |
dirEcco=dirModel; |
46 |
|
|
if ~isempty(dir([dirModel 'barfiles'])); |
47 |
gforget |
1.14 |
dirEcco=[dirModel 'barfiles' filesep]; |
48 |
|
|
end; |
49 |
|
|
|
50 |
|
|
if isempty(dirMat); dirMat=[dirModel 'mat/']; else; dirMat=[dirMat '/']; end; |
51 |
|
|
if isempty(dir(dirMat)); mkdir([dirMat]); end; |
52 |
|
|
if ~isdir([dirMat 'cost/']); mkdir([dirMat 'cost/']); end; |
53 |
|
|
runName=pwd; tmp1=strfind(runName,filesep); runName=runName(tmp1(end)+1:end); |
54 |
|
|
|
55 |
gforget |
1.15 |
%%%%%%%%%%%%%%%%% |
56 |
|
|
%global means: |
57 |
|
|
%%%%%%%%%%%%%%%%% |
58 |
|
|
|
59 |
|
|
tmpName=dir([dirEcco 'm_eta_day*data']); |
60 |
|
|
avisoName=which('MSL_aviso.bin'); |
61 |
|
|
if length(tmpName)==1&~isempty(avisoName); |
62 |
|
|
m_eta_day=rdmds2gcmfaces([dirEcco tmpName.name(1:end-5)]); |
63 |
|
|
avisoName=which('MSL_aviso.bin'); |
64 |
|
|
etaglo_aviso=read2memory(avisoName)'; |
65 |
|
|
%global mean |
66 |
|
|
nt=size(m_eta_day{1},3); etaglo=NaN*zeros(1,nt); |
67 |
|
|
area=mygrid.mskC(:,:,1).*mygrid.RAC; areatot=nansum(area); |
68 |
|
|
for tt=1:nt; |
69 |
|
|
etaglo(tt)=nansum(area.*m_eta_day(:,:,tt))/areatot; |
70 |
|
|
end; |
71 |
|
|
%monthly mean |
72 |
|
|
etaglo_mon=NaN*zeros(1,240); |
73 |
|
|
etaglo_aviso_mon=NaN*zeros(1,240); |
74 |
|
|
etadate=datenum([1992 1 1 12 0 0])+[1:nt]-1; |
75 |
|
|
for mm=1:240; |
76 |
|
|
t0=datenum([1992 1+(mm-1) 1 0 0 0]); |
77 |
|
|
t1=datenum([1992 1+mm 1 0 0 0]); |
78 |
|
|
tt=find(etadate>t0&etadate<t1); |
79 |
|
|
etaglo_mon(mm)=mean(etaglo(tt)); |
80 |
|
|
etaglo_aviso_mon(mm)=mean(etaglo_aviso(tt)); |
81 |
|
|
end; |
82 |
|
|
% |
83 |
|
|
if doSave; eval(['save ' dirMat 'cost/cost_altimeter_etaglo.mat etaglo*;']); end; |
84 |
|
|
end; |
85 |
|
|
|
86 |
gforget |
1.14 |
%%%%%%%%%%%%%%%%% |
87 |
gforget |
1.19 |
%uncertainties: |
88 |
|
|
%%%%%%%%%%%%%%%%% |
89 |
|
|
|
90 |
|
|
sig_mdt=NaN*mygrid.RAC; |
91 |
|
|
file0=[dirSigma nameSigma{1}]; |
92 |
|
|
if ~isempty(dir(file0)); sig_mdt=read_bin(file0,1,0); end; |
93 |
|
|
%missing field: |
94 |
|
|
%if useNctiles; sig_mdt=read_nctiles([dirNctiles 'sealevel'],'mdt_sigma'); end; |
95 |
|
|
|
96 |
|
|
sig_sladiff_smooth=NaN*mygrid.RAC; |
97 |
|
|
file0=[dirSigma nameSigma{2}]; |
98 |
|
|
if ~isempty(dir(file0)); sig_sladiff_smooth=read_bin(file0,1,0); end; |
99 |
|
|
if useNctiles; sig_sladiff_smooth=read_nctiles([dirNctiles 'sealevel'],'lsc_sigma_r5'); end; |
100 |
|
|
|
101 |
|
|
sig_sladiff_point=NaN*mygrid.RAC; |
102 |
|
|
file0=[dirSigma nameSigma{2}]; |
103 |
|
|
if ~isempty(dir(file0)); sig_sladiff_point=read_bin(file0,1,0); end; |
104 |
|
|
if useNctiles; sig_sladiff_point=read_nctiles([dirNctiles 'sealevel'],'point_sigma_r5'); end; |
105 |
|
|
|
106 |
|
|
sig_mdt(find(sig_mdt==0))=NaN; |
107 |
|
|
sig_sladiff_point(find(sig_sladiff_point==0))=NaN; |
108 |
|
|
sig_sladiff_smooth(find(sig_sladiff_smooth==0))=NaN; |
109 |
|
|
|
110 |
|
|
myflds.sig_mdt=sig_mdt; |
111 |
|
|
myflds.sig_sladiff_point=sig_sladiff_point; |
112 |
|
|
myflds.sig_sladiff_smooth=sig_sladiff_smooth; |
113 |
|
|
|
114 |
|
|
fprintf('done with init\n'); clock |
115 |
|
|
|
116 |
|
|
%%%%%%%%%%%%%%%%% |
117 |
gforget |
1.14 |
%do computations: |
118 |
|
|
%%%%%%%%%%%%%%%%% |
119 |
|
|
|
120 |
gforget |
1.4 |
for doDifObsOrMod=1:3; |
121 |
gforget |
1.14 |
|
122 |
gforget |
1.11 |
if doDifObsOrMod==1; suf='modMobs'; elseif doDifObsOrMod==2; suf='obs'; else; suf='mod'; end; |
123 |
|
|
|
124 |
|
|
if doComp==0; |
125 |
|
|
eval(['load ' dirMat 'cost/cost_altimeter_' suf '.mat myflds;']); |
126 |
|
|
else; |
127 |
|
|
|
128 |
|
|
%mdt cost function term (misfit plot) |
129 |
gforget |
1.19 |
dif_mdt=NaN*mygrid.RAC; |
130 |
|
|
file0=[dirEcco 'mdtdiff_smooth.data']; |
131 |
|
|
if ~isempty(dir(file0)); dif_mdt=read_bin(file0,1,0); end; |
132 |
|
|
if useNctiles; dif_mdt=read_nctiles([dirNctiles 'sealevel'],'mdt_misfit'); end; |
133 |
|
|
% |
134 |
gforget |
1.11 |
myflds.dif_mdt=dif_mdt; |
135 |
gforget |
1.19 |
|
136 |
|
|
fprintf('done with mdt\n'); clock |
137 |
|
|
|
138 |
|
|
if ~useNctiles; |
139 |
gforget |
1.11 |
%skip blanks: |
140 |
gforget |
1.14 |
tmp1=dir([dirEcco 'sladiff_smooth*data']); |
141 |
gforget |
1.11 |
nrec=tmp1.bytes/90/1170/4; |
142 |
|
|
ttShift=17; |
143 |
|
|
%skip 1992 |
144 |
|
|
listRecs=[1+365-ttShift:17+365*18-ttShift]; |
145 |
|
|
nRecs=length(listRecs); TT=1993+[0:nRecs-1]/365.25; |
146 |
gforget |
1.18 |
|
147 |
gforget |
1.19 |
tic; |
148 |
gforget |
1.18 |
%pre-load lsc cost function term to add it back to pointwise/1day terms: |
149 |
|
|
if doDifObsOrMod==1; |
150 |
|
|
sladiff_smooth=cost_altimeter_read([dirEcco 'sladiff_smooth'],listRecs); |
151 |
|
|
elseif doDifObsOrMod==2; |
152 |
|
|
sladiff_smooth=cost_altimeter_read([dirEcco 'slaobs_smooth'],listRecs); |
153 |
|
|
else; |
154 |
|
|
sladiff_smooth=cost_altimeter_read([dirEcco 'sladiff_smooth'],listRecs); |
155 |
|
|
sladiff_smooth=sladiff_smooth+cost_altimeter_read([dirEcco 'slaobs_smooth'],listRecs); |
156 |
|
|
end; |
157 |
gforget |
1.19 |
toc; |
158 |
|
|
end;%if ~useNctiles; |
159 |
|
|
|
160 |
|
|
if useNctiles; |
161 |
|
|
if doDifObsOrMod==1; |
162 |
|
|
sladiff_smooth=read_nctiles([dirNctiles 'sealevel'],'lsc_misfit'); |
163 |
|
|
elseif doDifObsOrMod==2; |
164 |
|
|
sladiff_smooth=read_nctiles([dirNctiles 'sealevel'],'lsc_sla'); |
165 |
|
|
else; |
166 |
|
|
sladiff_smooth=read_nctiles([dirNctiles 'sealevel'],'lsc_misfit'); |
167 |
|
|
sladiff_smooth=sladiff_smooth+read_nctiles([dirNctiles 'sealevel'],'lsc_sla'); |
168 |
|
|
end; |
169 |
|
|
nRecs=size(sladiff_smooth{1},3); |
170 |
|
|
TT=1992+[0:nRecs-1]/365.25; |
171 |
|
|
end; |
172 |
|
|
|
173 |
|
|
fprintf('done with lsc\n'); clock |
174 |
|
|
|
175 |
gforget |
1.11 |
%pointwise/1day terms: |
176 |
|
|
sladiff_point=repmat(0*mygrid.RAC,[1 1 nRecs]); count_point=sladiff_point; |
177 |
|
|
for ii=1:3; |
178 |
|
|
if ii==1; myset='tp'; elseif ii==2; myset='gfo'; else; myset='ers'; end; |
179 |
|
|
%topex pointwise misfits: |
180 |
gforget |
1.19 |
if ~useNctiles; |
181 |
gforget |
1.11 |
if doDifObsOrMod==1; |
182 |
gforget |
1.14 |
sladiff_tmp=cost_altimeter_read([dirEcco 'sladiff_' myset '_raw'],ttShift+listRecs); |
183 |
gforget |
1.11 |
elseif doDifObsOrMod==2; |
184 |
gforget |
1.14 |
sladiff_tmp=cost_altimeter_read([dirEcco 'slaobs_' myset '_raw'],ttShift+listRecs); |
185 |
gforget |
1.11 |
else; |
186 |
gforget |
1.14 |
sladiff_tmp=cost_altimeter_read([dirEcco 'sladiff_' myset '_raw'],ttShift+listRecs); |
187 |
|
|
sladiff_tmp=sladiff_tmp+cost_altimeter_read([dirEcco 'slaobs_' myset '_raw'],ttShift+listRecs); |
188 |
gforget |
1.11 |
end; |
189 |
gforget |
1.19 |
%add back the smoothed values that has been subtracted in cost_gencost_sshv4 |
190 |
gforget |
1.18 |
sladiff_smooth_tmp=sladiff_smooth; |
191 |
|
|
sladiff_smooth_tmp(sladiff_tmp==0)=0; |
192 |
|
|
sladiff_tmp=sladiff_tmp+sladiff_smooth_tmp; |
193 |
gforget |
1.19 |
end;%if ~useNctiles; |
194 |
|
|
|
195 |
|
|
if useNctiles; |
196 |
|
|
if doDifObsOrMod==1; |
197 |
|
|
sladiff_tmp=read_nctiles([dirNctiles 'sealevel'],[myset '_misfit']); |
198 |
|
|
elseif doDifObsOrMod==2; |
199 |
|
|
sladiff_tmp=read_nctiles([dirNctiles 'sealevel'],[myset '_sla']); |
200 |
|
|
else; |
201 |
|
|
sladiff_tmp=read_nctiles([dirNctiles 'sealevel'],[myset '_misfit']); |
202 |
|
|
sladiff_tmp=sladiff_tmp+read_nctiles([dirNctiles 'sealevel'],[myset '_sla']); |
203 |
|
|
end; |
204 |
|
|
sladiff_tmp(isnan(sladiff_tmp))=0; |
205 |
|
|
end; |
206 |
|
|
|
207 |
gforget |
1.11 |
%add to overall data set: |
208 |
|
|
sladiff_point=sladiff_point+sladiff_tmp; count_point=count_point+(sladiff_tmp~=0); |
209 |
|
|
%finalize data set: |
210 |
|
|
sladiff_tmp(sladiff_tmp==0)=NaN; |
211 |
|
|
%compute rms: |
212 |
|
|
count_tmp=sum(~isnan(sladiff_tmp),3); count_tmp(find(count_tmp<10))=NaN; msk_tmp=1+0*count_tmp; |
213 |
|
|
eval(['myflds.rms_' myset '=sqrt(nansum(sladiff_tmp.^2,3)./count_tmp);']); |
214 |
|
|
eval(['myflds.std_' myset '=nanstd(sladiff_tmp,0,3).*msk_tmp;']); |
215 |
|
|
end; |
216 |
gforget |
1.19 |
|
217 |
|
|
fprintf('done with point\n'); clock |
218 |
|
|
|
219 |
gforget |
1.11 |
%finalize overall data set: |
220 |
|
|
count_point(count_point==0)=NaN; |
221 |
|
|
sladiff_point=sladiff_point./count_point; |
222 |
|
|
%compute overall rms,std: |
223 |
|
|
count_tmp=sum(~isnan(sladiff_point),3); count_tmp(find(count_tmp<10))=NaN; msk_tmp=1+0*count_tmp; |
224 |
|
|
myflds.rms_sladiff_point=sqrt(nansum(sladiff_point.^2,3)./count_tmp); |
225 |
|
|
myflds.std_sladiff_point=nanstd(sladiff_point,0,3).*msk_tmp; |
226 |
|
|
% |
227 |
|
|
msk_point=1*(count_point>0); |
228 |
|
|
%fill blanks: |
229 |
|
|
warning('off','MATLAB:divideByZero'); |
230 |
|
|
msk=mygrid.mskC(:,:,1); msk(find(abs(mygrid.YC)>maxLatObs))=NaN; |
231 |
|
|
myflds.xtrp_rms_sladiff_point=diffsmooth2D_extrap_inv(myflds.rms_sladiff_point,msk); |
232 |
|
|
myflds.xtrp_std_sladiff_point=diffsmooth2D_extrap_inv(myflds.std_sladiff_point,msk); |
233 |
|
|
warning('on','MATLAB:divideByZero'); |
234 |
gforget |
1.19 |
|
235 |
|
|
if ~useNctiles; |
236 |
gforget |
1.11 |
%computational mask : only points that were actually observed, and in 35d average |
237 |
gforget |
1.14 |
msk_point35d=cost_altimeter_read([dirEcco 'sladiff_raw'],listRecs); |
238 |
gforget |
1.11 |
msk_point35d=1*(msk_point35d~=0); |
239 |
|
|
tmp1=sum(msk_point35d==0&msk_point~=0); |
240 |
|
|
tmp2=sum(msk_point35d~=0&msk_point~=0); |
241 |
|
|
fprintf('after masking : %d omitted, %d retained \n',tmp1,tmp2); |
242 |
|
|
msk_point=msk_point.*msk_point35d; |
243 |
gforget |
1.19 |
end;%if ~useNctiles; |
244 |
|
|
|
245 |
|
|
%plotting mask : regions of less than 100 observations are omitted |
246 |
gforget |
1.11 |
msk_point(msk_point==0)=NaN; |
247 |
|
|
msk_100pts=1*(nansum(msk_point,3)>=100); |
248 |
|
|
msk_100pts(msk_100pts==0)=NaN; |
249 |
|
|
%store |
250 |
|
|
myflds.msk_100pts=msk_100pts; |
251 |
gforget |
1.19 |
|
252 |
|
|
fprintf('done with msk100\n'); clock |
253 |
gforget |
1.11 |
|
254 |
gforget |
1.19 |
if ~useNctiles; |
255 |
|
|
tic; |
256 |
gforget |
1.11 |
%lsc cost function term: |
257 |
|
|
if doDifObsOrMod==1; |
258 |
gforget |
1.14 |
sladiff_smooth=cost_altimeter_read([dirEcco 'sladiff_smooth'],listRecs); |
259 |
gforget |
1.11 |
elseif doDifObsOrMod==2; |
260 |
gforget |
1.14 |
sladiff_smooth=cost_altimeter_read([dirEcco 'slaobs_smooth'],listRecs); |
261 |
gforget |
1.11 |
else; |
262 |
gforget |
1.14 |
sladiff_smooth=cost_altimeter_read([dirEcco 'sladiff_smooth'],listRecs); |
263 |
|
|
sladiff_smooth=sladiff_smooth+cost_altimeter_read([dirEcco 'slaobs_smooth'],listRecs); |
264 |
gforget |
1.11 |
end; |
265 |
|
|
%mask missing points: |
266 |
|
|
sladiff_smooth(sladiff_smooth==0)=NaN; |
267 |
|
|
sladiff_smooth=sladiff_smooth.*msk_point; |
268 |
|
|
count_tmp=sum(~isnan(sladiff_smooth),3); count_tmp(find(count_tmp<10))=NaN; msk_tmp=1+0*count_tmp; |
269 |
|
|
%compute rms: |
270 |
|
|
rms_sladiff_smooth=msk_tmp.*sqrt(nanmean(sladiff_smooth.^2,3)); |
271 |
|
|
std_sladiff_smooth=msk_tmp.*nanstd(sladiff_smooth,0,3); |
272 |
gforget |
1.19 |
toc; |
273 |
|
|
end;%if ~useNctiles; |
274 |
|
|
|
275 |
|
|
if useNctiles; |
276 |
|
|
rms_sladiff_smooth=sqrt(nanmean(sladiff_smooth.^2,3)); |
277 |
|
|
std_sladiff_smooth=nanstd(sladiff_smooth,0,3); |
278 |
|
|
end; |
279 |
|
|
|
280 |
gforget |
1.11 |
%store: |
281 |
|
|
myflds.rms_sladiff_smooth=rms_sladiff_smooth; |
282 |
|
|
myflds.std_sladiff_smooth=std_sladiff_smooth; |
283 |
gforget |
1.19 |
|
284 |
|
|
fprintf('done with rms\n'); clock |
285 |
gforget |
1.11 |
|
286 |
gforget |
1.19 |
if ~useNctiles; |
287 |
|
|
tic; |
288 |
gforget |
1.11 |
%pointwise/point35days cost function term: |
289 |
|
|
if doDifObsOrMod==1; |
290 |
gforget |
1.14 |
sladiff_point35d=cost_altimeter_read([dirEcco 'sladiff_raw'],listRecs); |
291 |
gforget |
1.11 |
elseif doDifObsOrMod==2; |
292 |
gforget |
1.14 |
sladiff_point35d=cost_altimeter_read([dirEcco 'slaobs_raw'],listRecs); |
293 |
gforget |
1.11 |
else; |
294 |
gforget |
1.14 |
sladiff_point35d=cost_altimeter_read([dirEcco 'sladiff_raw'],listRecs); |
295 |
|
|
sladiff_point35d=sladiff_point35d+cost_altimeter_read([dirEcco 'slaobs_raw'],listRecs); |
296 |
gforget |
1.11 |
end; |
297 |
|
|
%mask missing points: |
298 |
|
|
sladiff_point35d(sladiff_point35d==0)=NaN; |
299 |
|
|
sladiff_point35d=sladiff_point35d.*msk_point; |
300 |
|
|
count_tmp=sum(~isnan(sladiff_point35d),3); count_tmp(find(count_tmp<10))=NaN; msk_tmp=1+0*count_tmp; |
301 |
|
|
%compute rms: |
302 |
|
|
rms_sladiff_point35d=msk_tmp.*sqrt(nanmean(sladiff_point35d.^2,3)); |
303 |
|
|
std_sladiff_point35d=msk_tmp.*nanstd(sladiff_point35d,0,3); |
304 |
|
|
%store: |
305 |
|
|
myflds.rms_sladiff_point35d=rms_sladiff_point35d; |
306 |
|
|
myflds.std_sladiff_point35d=std_sladiff_point35d; |
307 |
|
|
|
308 |
|
|
if 0; |
309 |
|
|
%difference between scales |
310 |
|
|
rms_sladiff_35dMsmooth=msk_tmp.*sqrt(nanmean((sladiff_point35d-sladiff_smooth).^2,3)); |
311 |
|
|
std_sladiff_35dMsmooth=msk_tmp.*nanstd((sladiff_point35d-sladiff_smooth),0,3); |
312 |
|
|
%store: |
313 |
|
|
myflds.rms_sladiff_35dMsmooth=rms_sladiff_35dMsmooth; |
314 |
|
|
myflds.std_sladiff_35dMsmooth=std_sladiff_35dMsmooth; |
315 |
|
|
|
316 |
|
|
%difference between scales |
317 |
|
|
rms_sladiff_pointMpoint35d=msk_tmp.*sqrt(nanmean((sladiff_point-sladiff_point35d).^2,3)); |
318 |
|
|
std_sladiff_pointMpoint35d=msk_tmp.*nanstd((sladiff_point-sladiff_point35d),0,3); |
319 |
|
|
%store: |
320 |
|
|
myflds.rms_sladiff_pointMpoint35d=rms_sladiff_pointMpoint35d; |
321 |
|
|
myflds.std_sladiff_pointMpoint35d=std_sladiff_pointMpoint35d; |
322 |
|
|
end; |
323 |
gforget |
1.19 |
toc; |
324 |
|
|
end;%if ~useNctiles; |
325 |
|
|
|
326 |
|
|
if useNctiles; |
327 |
|
|
%store: |
328 |
|
|
myflds.rms_sladiff_point35d=NaN*rms_sladiff_smooth; |
329 |
|
|
myflds.std_sladiff_point35d=NaN*std_sladiff_smooth; |
330 |
|
|
end; |
331 |
gforget |
1.11 |
|
332 |
|
|
%compute zonal mean/median: |
333 |
|
|
for ii=1:4; |
334 |
|
|
switch ii; |
335 |
|
|
case 1; tmp1='mdt'; cost_fld=(mygrid.mskC(:,:,1).*myflds.dif_mdt./myflds.sig_mdt).^2; |
336 |
|
|
case 2; tmp1='lsc'; cost_fld=(mygrid.mskC(:,:,1).*myflds.rms_sladiff_smooth./myflds.sig_sladiff_smooth).^2; |
337 |
|
|
case 3; tmp1='point35d'; cost_fld=(mygrid.mskC(:,:,1).*myflds.rms_sladiff_point35d./myflds.sig_sladiff_point).^2; |
338 |
|
|
case 4; tmp1='point'; cost_fld=(mygrid.mskC(:,:,1).*myflds.rms_sladiff_point./myflds.sig_sladiff_point).^2; |
339 |
|
|
end; |
340 |
|
|
cost_zmean=calc_zonmean_T(cost_fld); eval(['mycosts_mean.' tmp1 '=cost_zmean;']); |
341 |
|
|
cost_zmedian=calc_zonmedian_T(cost_fld); eval(['mycosts_median.' tmp1 '=cost_zmedian;']); |
342 |
|
|
end; |
343 |
gforget |
1.19 |
|
344 |
|
|
fprintf(['done with ' suf '\n']); clock |
345 |
gforget |
1.11 |
|
346 |
gforget |
1.19 |
%write to disk: |
347 |
gforget |
1.11 |
if doSave; eval(['save ' dirMat 'cost/cost_altimeter_' suf '.mat myflds mycosts_mean mycosts_median;']); end; |
348 |
|
|
|
349 |
|
|
end;%if doComp |
350 |
|
|
|
351 |
|
|
if doPlot; |
352 |
|
|
cc=[-0.4:0.05:-0.25 -0.2:0.03:-0.05 -0.03:0.01:0.03 0.05:0.03:0.2 0.25:0.05:0.4]; |
353 |
|
|
figure; m_map_gcmfaces(myflds.dif_mdt,0,{'myCaxis',cc}); drawnow; |
354 |
|
|
cc=[0:0.005:0.02 0.03:0.01:0.05 0.06:0.02:0.1 0.14:0.03:0.2 0.25:0.05:0.4]; |
355 |
|
|
figure; m_map_gcmfaces(myflds.rms_sladiff_smooth,0,{'myCaxis',cc}); drawnow; |
356 |
|
|
figure; m_map_gcmfaces(myflds.rms_sladiff_point35d,0,{'myCaxis',cc}); drawnow; |
357 |
|
|
figure; m_map_gcmfaces(myflds.rms_sladiff_point,0,{'myCaxis',cc}); drawnow; |
358 |
|
|
end; |
359 |
|
|
|
360 |
|
|
if doPlot&doPrint; |
361 |
|
|
dirFig='../figs/altimeter/'; ff0=gcf-4; |
362 |
|
|
for ff=1:4; |
363 |
|
|
figure(ff+ff0); saveas(gcf,[dirFig runName '_' suf num2str(ff)],'fig'); |
364 |
|
|
eval(['print -depsc ' dirFig runName '_' suf num2str(ff) '.eps;']); |
365 |
|
|
eval(['print -djpeg90 ' dirFig runName '_' suf num2str(ff) '.jpg;']); |
366 |
|
|
end; |
367 |
|
|
end; |
368 |
|
|
|
369 |
gforget |
1.4 |
end;%for doDifObsOrMod=1:3; |
370 |
|
|
|
371 |
|
|
|
372 |
|
|
|
373 |
|
|
function [fldOut]=cost_altimeter_read(fileIn,recIn); |
374 |
|
|
|
375 |
|
|
nrec=length(recIn); |
376 |
|
|
global mygrid; siz=[size(convert2gcmfaces(mygrid.XC)) nrec]; |
377 |
|
|
lrec=siz(1)*siz(2)*4; |
378 |
|
|
myprec='float32'; |
379 |
|
|
|
380 |
|
|
fldOut=zeros(siz); |
381 |
|
|
fid=fopen([fileIn '.data'],'r','b'); |
382 |
|
|
for irec=1:nrec; |
383 |
gforget |
1.11 |
status=fseek(fid,(recIn(irec)-1)*lrec,'bof'); |
384 |
|
|
fldOut(:,:,irec)=fread(fid,siz(1:2),myprec); |
385 |
gforget |
1.4 |
end; |
386 |
|
|
|
387 |
|
|
fldOut=convert2gcmfaces(fldOut); |
388 |
|
|
|
389 |
|
|
|
390 |
|
|
|