/[MITgcm]/MITgcm_contrib/high_res_cube/eddy_flux/plot_UVB.m
ViewVC logotype

Contents of /MITgcm_contrib/high_res_cube/eddy_flux/plot_UVB.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Wed Aug 11 15:49:15 2004 UTC (20 years, 11 months ago) by edhill
Branch: MAIN
CVS Tags: HEAD
 o initial check-in

1 %=======================================================
2 %
3 % $Header: $
4 %
5 % Ed Hill
6 %
7
8 % The following are the MatLAB commands used to create the various
9 % plots related to eddy fluxes using average velocities and densities
10 % (called bouyancy or "b" in many of the variables) from Dimitris'
11 % "cube_5" integration.
12
13 % Groups of commands contained within the following "UNUSED" comments
14 % we not used in this analyssis. They are "left over" from the
15 % previous temperature-based calculations and have been kept for
16 % reference purposes only.
17
18 %------- UNUSED -----------------------
19 % ...Commands...
20 %------- UNUSED -----------------------
21
22
23 matlab -nojvm
24 matlab -nojvm -nodisplay
25
26 %=======================================================
27 % Compute 12-yr averages from the 1-yr averages
28
29 clear all ; close all
30 ne = 510;
31 ntot = ne*ne*6 * 50;
32 by = 1992;
33 ey = 2003;
34 p1 = 'U_ave_%4.4d';
35 p2 = 'V_ave_%4.4d';
36 p3 = 'b-ave-%4.4d';
37 p4 = 'bm1-ave-%4.4d';
38 p5 = 'ub-ave-%4.4d';
39 p6 = 'vb-ave-%4.4d';
40 ft = 1;
41 for ft = 1:6
42 sum = zeros(ntot,1);
43 eval(sprintf('pat = p%d;',ft));
44 disp(sprintf('pat = "%s"',pat));
45 iy = by;
46 for iy = by:ey
47 disp(sprintf(' iy = %d',iy));
48 fid = fopen(sprintf(pat,iy), 'r', 'ieee-be');
49 a = fread(fid, ntot, 'real*4');
50 fclose(fid);
51 sum = sum + a;
52 end
53 a = sum / (ey-by+1);
54 ido = fopen(sprintf([pat '-%4.4d'],by,ey), 'w', 'ieee-be');
55 fwrite(ido, a, 'real*4');
56 fclose(ido);
57 end
58
59 %=======================================================
60 % Compute u'b' and v'b'
61
62 clear all; close all
63
64 bfid = fopen( 'b-ave-1992-2003', 'r', 'ieee-be');
65 ufid = fopen( 'U_ave_1992-2003', 'r', 'ieee-be');
66 vfid = fopen( 'V_ave_1992-2003', 'r', 'ieee-be');
67 ubfid = fopen('ub-ave-1992-2003', 'r', 'ieee-be');
68 vbfid = fopen('vb-ave-1992-2003', 'r', 'ieee-be');
69
70 afid = [ ufid vfid ];
71 av = [ 'ua'; 'va' ];
72
73 nztot = 50;
74 ne = 510;
75 nps = 6 * ne * ne;
76 iz = 1;
77 for iz = 1:nztot
78
79 disp(sprintf('iz = %d', iz));
80
81 offset = (iz - 1)*nps*4;
82 id = 1;
83 for id = 1:length(afid)
84 fseek(afid(id), offset, 'bof');
85 % Convert the horrible JPL mdsio layout to six saner faces
86 ne = 510; tx = 85; ty = 85; nt = 216;
87 phi = unmangleJPL1( reshape(fread(afid(id), nps, 'real*4'), ...
88 tx*nt,ty), ne, tx );
89 comm = [ av(id,:) ' = phi;' ];
90 % disp(comm);
91 eval(comm);
92 end
93 clear phi
94 % surf(ua(:,:,1)), view(2), shading interp, axis equal
95 % surf(va(:,:,1)), view(2), shading interp, axis equal
96
97 fseek(bfid, offset, 'bof');
98 b = reshape(fread(bfid, nps, 'real*4'),ne,ne,6);
99 % surf(b(:,:,1)), view(2), shading interp, axis equal
100 fseek(ubfid, offset, 'bof');
101 ub = reshape(fread(ubfid, nps, 'real*4'),ne,ne,6);
102 % surf(ub(:,:,1)), view(2), shading interp, axis equal
103 fseek(vbfid, offset, 'bof');
104 vb = reshape(fread(vbfid, nps, 'real*4'),ne,ne,6);
105 % surf(vb(:,:,1)), view(2), shading interp, axis equal
106
107 % Fill the (ne+1)*(ne+1) grid with B values
108 ni = ne; nip1 = ni + 1;
109 nj = ne; njp1 = nj + 1;
110 bcubep1 = zeros( [ nip1 njp1 6 ] );
111 for icf = 1:6
112 bcubep1(2:nip1,2:njp1,icf) = b(:,:,icf);
113 end
114
115 % Do the upwind-edge B exchanges
116 bcubep1(1,2:njp1,1) = b(ni:-1:1,nj,5); % -
117 bcubep1(2:nip1,1,1) = b(1:ni,nj,6); % -
118 bcubep1(1,2:njp1,2) = b(ni,1:nj,1); % -
119 bcubep1(2:nip1,1,2) = b(ni,nj:-1:1,6); % -
120 bcubep1(1,2:njp1,3) = b(ni:-1:1,nj,1); % -
121 bcubep1(2:nip1,1,3) = b(1:ni,nj,2); % -
122 bcubep1(1,2:njp1,4) = b(ni,1:nj,3); % -
123 bcubep1(2:nip1,1,4) = b(ni,nj:-1:1,2); % -
124 bcubep1(1,2:njp1,5) = b(ni:-1:1,nj,3); % -
125 bcubep1(2:nip1,1,5) = b(1:ni,nj,4); % -
126 bcubep1(1,2:njp1,6) = b(ni,1:nj,5); % -
127 bcubep1(2:nip1,1,6) = b(ni,nj:-1:1,4); % -
128
129 % Get B values on the U grid points
130 masku = 1.0 - abs(diff(double(bcubep1(2:nip1,:,:) == 0.0),1,2));
131 diffu = 0.5*diff(bcubep1(2:nip1,:,:),1,2);
132 bonu = b(:,:,:) + masku.*diffu;
133
134 % Get B values on the V grid points
135 maskv = 1.0 - abs(diff(double(bcubep1(:,2:nip1,:) == 0.0),1,1));
136 diffv = 0.5*diff(bcubep1(:,2:nip1,:),1,1);
137 bonv = b(:,:,:) + maskv.*diffv;
138
139 % Compute u'B' and v'B'
140 upbp = ub - ua .* bonu;
141 vpbp = vb - va .* bonv;
142
143 % Write the results
144 ubid = fopen('upbp-1992-2003', 'a', 'ieee-be');
145 vbid = fopen('vpbp-1992-2003', 'a', 'ieee-be');
146 fwrite(ubid, upbp, 'real*4');
147 fwrite(vbid, vpbp, 'real*4');
148 fclose(ubid);
149 fclose(vbid);
150
151 end
152
153 %=======================================================
154 % Plot u'B' and v'B' on a Lat-Lon grid
155
156 clear all, close all
157 tx = 85;
158 ty = 85;
159 nt = 216;
160 cx = 510;
161 cy = 510;
162 nz = 1;
163 ne = 510;
164 nps = ne * ne * 6;
165
166 % XCS YCS XGS YGS
167 fnam = [ 'XC' ; 'YC'; 'XG'; 'YG' ];
168 for in = 1:4
169 uid = fopen([fnam(in,:) '.data'], 'r', 'ieee-be');
170 phi = unmangleJPL1( reshape(fread(uid, nps, 'real*4'), ...
171 tx*nt,ty), ne, tx );
172 fclose(uid);
173 eval([lower(fnam(in,:)) ' = phi;']);
174 a = zeros(6*510,510);
175 for i = 1:6
176 xb = (i-1)*510 + 1; xe = xb + 510 - 1;
177 yb = 1; ye = 510;
178 a(xb:xe,yb:ye) = phi(:,:,i);
179 end
180 eval([lower(fnam(in,:)) 's = a;'])
181 end
182 xcs = xcs + -360.0*(xcs > 180.0);
183 xgs = xgs + -360.0*(xgs > 180.0);
184 clear phi a
185
186 %=======================================================
187 % Calculation rotations for Lat-Lon vector alignment
188
189 ne = 510;
190 n1 = ne - 1;
191 dux = zeros(size(xg));
192 duy = zeros(size(xg));
193 dvx = zeros(size(xg));
194 dvy = zeros(size(xg));
195 dux(1:n1,:,:) = diff(xg,1,1); dux(ne,:,:) = dux(n1,:,:);
196 dvx(:,1:n1,:) = diff(xg,1,2); dvx(:,ne,:) = dvx(:,n1,:);
197 duy(1:n1,:,:) = diff(yg,1,1); duy(ne,:,:) = duy(n1,:,:);
198 dvy(:,1:n1,:) = diff(yg,1,2); dvy(:,ne,:) = dvy(:,n1,:);
199 dux = dux + 360*double(dux < 180);
200 dux = dux - 360*double(dux > 180); % [ min(min(dux)) max(max(dux)) ]
201 duy = duy + 360*double(duy < 180);
202 duy = duy - 360*double(duy > 180); % [ min(min(duy)) max(max(duy)) ]
203 dvx = dvx + 360*double(dvx < 180);
204 dvx = dvx - 360*double(dvx > 180); % [ min(min(dvx)) max(max(dvx)) ]
205 dvy = dvy + 360*double(dvy < 180);
206 dvy = dvy - 360*double(dvy > 180); % [ min(min(dvy)) max(max(dvy)) ]
207 llux = dux ./ sqrt(dux.^2 + duy.^2);
208 lluy = duy ./ sqrt(dux.^2 + duy.^2);
209 llvx = dvx ./ sqrt(dvx.^2 + dvy.^2);
210 llvy = dvy ./ sqrt(dvx.^2 + dvy.^2);
211
212 % surf(xg(:,:,2)), view(2), axis equal, shading interp, colorbar
213 % surf(dux(:,:,2)), view(2), axis equal, shading interp, colorbar
214 % surf(duy(:,:,2)), view(2), axis equal, shading interp, colorbar
215
216 delR = [
217 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.01, ...
218 10.03, 10.11, 10.32, 10.80, 11.76, 13.42, 16.04 , 19.82, 24.85, ...
219 31.10, 38.42, 46.50, 55.00, 63.50, 71.58, 78.90, 85.15, 90.18, ...
220 93.96, 96.58, 98.25, 99.25,100.01,101.33,104.56,111.33,122.83, ...
221 139.09,158.94,180.83,203.55,226.50,249.50,272.50,295.50,318.50, ...
222 341.50,364.50,387.50,410.50,433.50,456.50 ];
223 R = cumsum(delR) - 0.5*delR;
224 Rmid = R(1:(length(R)-1)) + 0.5*diff(R);
225
226 ne = 510;
227 nps = ne * ne * 6;
228
229 % u'T' and v'T'
230 upbpid = fopen('upbp-1992-2003', 'r', 'ieee-be');
231 vpbpid = fopen('vpbp-1992-2003', 'r', 'ieee-be');
232
233 clow = [ -1.0 ]; % -0.2;
234 chigh = [ 1.0 ]; % 0.2;
235
236 iz = 1;
237 iz = 15;
238 iz = 25;
239 for iz = [ 1:50 ]
240 disp(sprintf('iz = %d',iz));
241 % iz = 21;
242 offset = (iz - 1)*nps*4;
243 fseek(upbpid, offset, 'bof');
244 fseek(vpbpid, offset, 'bof');
245 upbp = reshape(fread(upbpid, nps, 'real*4'),ne,ne,6);
246 vpbp = reshape(fread(vpbpid, nps, 'real*4'),ne,ne,6);
247
248
249 % Look at u'b' and v'b' on ll coords
250 % surf(xg(:,:,2), yg(:,:,2), upbp(:,:,2)), view(2), shading interp, colorbar
251 % surf(xg(:,:,3), yg(:,:,3), upbp(:,:,3)), view(2), shading interp, colorbar
252 % surf(xg(:,:,4), yg(:,:,4), upbp(:,:,4)), view(2), shading interp, colorbar
253 llupbp = upbp .* llux + vpbp .* llvx;
254 llvpbp = upbp .* lluy + vpbp .* llvy;
255 % surf(xg(:,:,2), yg(:,:,2), lluptp(:,:,2)), view(2), shading interp, colorbar
256 % surf(xg(:,:,2), yg(:,:,2), llvptp(:,:,2)), view(2), shading
257 % interp, colorbar
258
259 % save for later use
260 upbpllid = fopen('upbpll-1992-2003', 'a', 'ieee-be');
261 vpbpllid = fopen('vpbpll-1992-2003', 'a', 'ieee-be');
262 fwrite(upbpllid, llupbp, 'real*4');
263 fwrite(vpbpllid, llvpbp, 'real*4');
264 fclose(upbpllid);
265 fclose(vpbpllid);
266
267 % Look at lat-lon projections of u'T' and v'T'
268 pllupbp = zeros(6*510,510);
269 pllvpbp = zeros(6*510,510);
270 for i = 1:6
271 xb = (i-1)*510 + 1; xe = xb + 510 - 1;
272 yb = 1; ye = 510;
273 pllupbp(xb:xe,yb:ye) = llupbp(:,:,i);
274 pllvpbp(xb:xe,yb:ye) = llvpbp(:,:,i);
275 end
276 shift=-1;
277 grph_CS(sq(pllupbp),xcs,ycs,xgs,ygs,[clow],[chigh],shift);
278 title([ 'u''B'' at ' ...
279 sprintf('%g',R(iz)) ...
280 'm depth on the 510x510x6 cubesphere for 1992--2003 ["cube5"]']);
281 % print('-painters', '-dpng', '-r650', ...
282 % ['upTp_' sprintf('%02d_%07.1f',iz,R(iz)) 'm_650.png'])
283 print('-painters', '-dpng', '-r150', ...
284 ['upBp_' sprintf('%02d_%07.1f',iz,R(iz)) 'm_150.png'])
285
286 grph_CS(sq(pllvpbp),xcs,ycs,xgs,ygs,[clow],[chigh],shift);
287 title([ 'v''B'' at ' ...
288 sprintf('%g',R(iz)) ...
289 'm depth on the 510x510x6 cubesphere for 1992--2003 ["cube5"]']);
290 % print('-painters', '-dpng', '-r650', ...
291 % ['vpTp_' sprintf('%02d_%07.1f',iz,R(iz)) 'm_650.png'])
292 print('-painters', '-dpng', '-r150', ...
293 ['vpBp_' sprintf('%02d_%07.1f',iz,R(iz)) 'm_150.png'])
294
295 end
296
297
298 %=======================================================
299 % Calculate : (v'B')/(dB/dz)
300
301 bid = fopen( 'b-ave-1992-2003', 'r', 'ieee-be');
302 bm1id = fopen('bm1-ave-1992-2003', 'r', 'ieee-be');
303
304 iz = 1;
305 offset = (iz - 1)*nps*4;
306 fseek(upbpid, offset, 'bof');
307 fseek(vpbpid, offset, 'bof');
308 upbp = reshape(fread(upbpid, nps, 'real*4'),ne,ne,6);
309 vpbp = reshape(fread(vpbpid, nps, 'real*4'),ne,ne,6);
310 llvpbp = upbp .* lluy + vpbp .* llvy;
311 llvpbpm1 = llvpbp;
312 ne = 510; tx = 85; ty = 85; nt = 216;
313
314 iz = 2;
315 iz = 15;
316 iz = 16;
317 for iz = 2:50,
318 izm1 = iz - 1;
319 disp(sprintf('iz = %d',iz));
320 % iz = 21;
321 offset = (iz - 1)*nps*4;
322 fseek(upbpid, offset, 'bof');
323 fseek(vpbpid, offset, 'bof');
324 upbp = reshape(fread(upbpid, nps, 'real*4'),ne,ne,6);
325 vpbp = reshape(fread(vpbpid, nps, 'real*4'),ne,ne,6);
326
327 % v'B' on ll coords
328 llvpbp = upbp .* lluy + vpbp .* llvy;
329
330 % B and Bm1
331 fseek(bid, offset, 'bof');
332 b = reshape(fread(bid, nps, 'real*4'),ne,ne,6);
333 offm1 = (iz - 2)*nps*4;
334 fseek(bm1id, offm1, 'bof');
335 bm1 =reshape(fread(bm1id, nps, 'real*4'),ne,ne,6);
336
337 % ( v'B' )/( dB/dz )
338 dbdz = (b - bm1)/(R(iz) - R(izm1));
339 ind0 = find(dbdz==0.0);
340 dbdz(ind0) = 1.0;
341 rdbdz = 1.0 / (dbdz);
342 rdbdz(ind0) = 0.0;
343 vpbpdbdz = 0.5*(llvpbp + llvpbpm1) .* rdbdz;
344
345 % Write the results
346 mid = fopen('vpbpdbdz-1992-2003', 'a', 'ieee-be');
347 fwrite(mid, vpbpdbdz, 'real*4');
348 fclose(mid);
349
350 % Plot results
351 clow = [ -10 ]; % -20;
352 chigh = [ 10 ]; % 20;
353 ll = zeros(6*510,510);
354 for i = 1:6
355 xb = (i-1)*510 + 1; xe = xb + 510 - 1;
356 yb = 1; ye = 510;
357 ll(xb:xe,yb:ye) = vpbpdbdz(:,:,i);
358 end
359 shift=-1;
360 grph_CS(sq(ll),xcs,ycs,xgs,ygs,[clow],[chigh],shift);
361 title([ '(v''B'')/(dB/dz) at ' ...
362 sprintf('%g',Rmid(iz)) ...
363 'm depth on the 510x510x6 cubesphere for 1992--2003 ["cube5"]']);
364 % print('-painters', '-dpng', '-r650', ...
365 % ['vpTpdTdz_' sprintf('%02d_%07.1f',iz,Rmid(iz)) 'm_650.png'])
366 print('-painters', '-dpng', '-r150', ...
367 ['vpBpdBdz_' sprintf('%02d_%07.1f',iz,Rmid(iz)) 'm_150.png'])
368
369
370 % Stress: calc, write, and plot
371 stress = 1000 * (2*pi/(24*3600)*sin(pi*yc/180));
372 stress = stress .* vpbpdbdz;
373 sid = fopen('stress-b-1992-2003', 'a', 'ieee-be');
374 fwrite(sid, stress, 'real*4');
375 fclose(sid);
376 clow = []; % [ -1 ];
377 chigh = []; % [ 1 ];
378 ll = zeros(6*510,510);
379 for i = 1:6
380 xb = (i-1)*510 + 1; xe = xb + 510 - 1;
381 yb = 1; ye = 510;
382 ll(xb:xe,yb:ye) = stress(:,:,i);
383 end
384 shift=-1;
385 grph_CS(sq(ll),xcs,ycs,xgs,ygs,[clow],[chigh],shift);
386 title([ 'Stress at ' ...
387 sprintf('%g',Rmid(iz)) ...
388 'm depth on the 510x510x6 cubesphere for 1994--2003 ["cube5"]']);
389 % print('-painters', '-dpng', '-r650', ...
390 % ['stress_' sprintf('%02d_%07.1f',iz,Rmid(iz)) 'm_650.png'])
391 print('-painters', '-dpng', '-r150', ...
392 ['stress_' sprintf('%02d_%07.1f',iz,Rmid(iz)) 'm_150.png'])
393
394
395 % Next level
396 llvpbpm1 = llvpbp;
397
398 end
399
400
401 %=======================================================
402 % Zonally average vpbpdbdz and stress
403
404 clear all ; close all
405 tx = 85;
406 ty = 85;
407 nt = 216;
408 cx = 510;
409 cy = 510;
410 nz = 1;
411 ne = 510;
412 nps = ne * ne * 6;
413
414 % XCS YCS XGS YGS
415 fnam = [ 'XC' ; 'YC'; 'XG'; 'YG' ];
416 for in = 1:4
417 uid = fopen([fnam(in,:) '.data'], 'r', 'ieee-be');
418 phi = unmangleJPL1( reshape(fread(uid, nps, 'real*4'), ...
419 tx*nt,ty), ne, tx );
420 fclose(uid);
421 eval([lower(fnam(in,:)) ' = phi;']);
422 a = zeros(6*510,510);
423 for i = 1:6
424 xb = (i-1)*510 + 1; xe = xb + 510 - 1;
425 yb = 1; ye = 510;
426 a(xb:xe,yb:ye) = phi(:,:,i);
427 end
428 eval([lower(fnam(in,:)) 's = a;'])
429 end
430 xcs = xcs + -360.0*(xcs > 180.0);
431 xgs = xgs + -360.0*(xgs > 180.0);
432 clear phi a
433
434 nz = 1;
435 nr = 50;
436 nrm1 = nr - 1;
437 nlat = 181; nlatm1 = nlat - 1;
438
439 hvals = linspace(-90,90,nlat);
440 % save indicies for zonal averages
441 i = 2;
442 for i = 2:nlat
443 inds = find(hvals(i-1)<yg & yg<hvals(i));
444 comm = sprintf('inds%04d = uint32(inds);',i-1);
445 eval(comm);
446 end
447
448 % Zonally average vpbp
449 acc = zeros(nlatm1, nrm1);
450 num = zeros(size(acc));
451 ne = 510;
452 nps = ne * ne * 6;
453 zid = fopen('vpbpll-1992-2003', 'r', 'ieee-be');
454 iz = 1;
455 for iz = 1:50,
456 disp(sprintf('iz = %d',iz));
457 offset = (iz - 1)*nps*4;
458 fseek(zid, offset, 'bof');
459 vpbp = reshape(fread(zid, nps, 'real*4'),ne,ne,6);
460
461 for jj = 1:nlatm1
462 eval( sprintf('clear inds; inds = inds%04d;',jj) );
463 tmp = vpbp(inds);
464 nzinds = find(tmp ~= 0.0);
465 num(jj,iz) = length(nzinds);
466 acc(jj,iz) = sum(tmp(nzinds));
467 end
468 end
469 fclose(zid);
470 zvpbp = acc ./ num;
471 % save zvpbp zvpbp
472
473 % zonally average vpbpdbdz
474 acc = zeros(nlatm1, nrm1);
475 num = zeros(size(acc));
476 ne = 510;
477 nps = ne * ne * 6;
478 zid = fopen('vpbpdbdz-1992-2003', 'r', 'ieee-be');
479 iz = 1;
480 for iz = 1:49,
481 disp(sprintf('iz = %d',iz));
482 offset = (iz - 1)*nps*4;
483 fseek(zid, offset, 'bof');
484 vpbpdbdz = reshape(fread(zid, nps, 'real*4'),ne,ne,6);
485
486 for jj = 1:nlatm1
487 eval( sprintf('clear inds; inds = inds%04d;',jj) );
488 tmp = vpbpdbdz(inds);
489 nzinds = find(tmp ~= 0.0);
490 num(jj,iz) = length(nzinds);
491 acc(jj,iz) = sum(tmp(nzinds));
492 end
493 end
494 fclose(zid);
495 zvpbpdbdz = acc ./ num;
496 % save zvpbpdbdz zvpbpdbdz
497
498 % zonally average stress
499 acc = zeros(nlatm1, nrm1);
500 num = zeros(size(acc));
501 ne = 510;
502 nps = ne * ne * 6;
503 zid = fopen('stress-b-1992-2003', 'r', 'ieee-be');
504 iz = 1;
505 for iz = 1:49,
506 disp(sprintf('iz = %d',iz));
507 offset = (iz - 1)*nps*4;
508 fseek(zid, offset, 'bof');
509 stress = reshape(fread(zid, nps, 'real*4'),ne,ne,6);
510 jj = 22;
511 for jj = 1:nlatm1
512 eval( sprintf('clear inds; inds = inds%04d;',jj) );
513 tmp = stress(inds);
514 nzinds = find(tmp ~= 0.0);
515 num(jj,iz) = length(nzinds);
516 acc(jj,iz) = sum(tmp(nzinds));
517 end
518 end
519 fclose(zid);
520 stress = acc ./ num;
521 % save stress stress
522
523 %------- UNUSED -----------------------
524 % zonally average u
525 acc = zeros(nlatm1, 50);
526 num = zeros(size(acc));
527 ne = 510;
528 nps = ne * ne * 6;
529 zid = fopen('Ull_ave_1994--2003', 'r', 'ieee-be');
530 iz = 1;
531 for iz = 1:50,
532 disp(sprintf('iz = %d',iz));
533 offset = (iz - 1)*nps*4;
534 fseek(zid, offset, 'bof');
535 U = reshape(fread(zid, nps, 'real*4'),ne,ne,6);
536 jj = 22;
537 for jj = 1:nlatm1
538 eval( sprintf('clear inds; inds = inds%04d;',jj) );
539 tmp = U(inds);
540 nzinds = find(tmp ~= 0.0);
541 num(jj,iz) = length(nzinds);
542 acc(jj,iz) = sum(tmp(nzinds));
543 end
544 end
545 fclose(zid);
546 zonalu = acc ./ num;
547 % save zonalu zonalu
548 %------- UNUSED -----------------------
549
550 % zonally average B
551 acc = zeros(nlatm1, 50);
552 num = zeros(size(acc));
553 ne = 510;
554 nps = ne * ne * 6;
555 zid = fopen('b-ave-1992-2003', 'r', 'ieee-be');
556 iz = 1;
557 for iz = 1:50,
558 disp(sprintf('iz = %d',iz));
559 offset = (iz - 1)*nps*4;
560 fseek(zid, offset, 'bof');
561 B = reshape(fread(zid, nps, 'real*4'),ne,ne,6);
562 jj = 22;
563 for jj = 1:nlatm1
564 eval( sprintf('clear inds; inds = inds%04d;',jj) );
565 tmp = B(inds);
566 nzinds = find(tmp ~= 0.0);
567 num(jj,iz) = length(nzinds);
568 acc(jj,iz) = sum(tmp(nzinds));
569 end
570 end
571 fclose(zid);
572 zonalB = acc ./ num;
573 % save zonalB zonalB
574
575 %------- UNUSED -----------------------
576 % Vertical gradient of zonally averaged B (dB/dz)
577 load zonalT
578 load allR
579 nz = size(zonalT,1);
580 dzaTdz = zeros(nz,size(zonalT,2)-1);
581 for iz = 2:50
582 dzaTdz(:,iz-1) = (zonalT(:,iz) - zonalT(:,iz-1)) ./ (R(iz) - R(iz-1));
583 end
584 % save dzaTdz dzaTdz
585 %------- UNUSED -----------------------
586
587
588 delR = [
589 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.01, ...
590 10.03, 10.11, 10.32, 10.80, 11.76, 13.42, 16.04 , 19.82, 24.85, ...
591 31.10, 38.42, 46.50, 55.00, 63.50, 71.58, 78.90, 85.15, 90.18, ...
592 93.96, 96.58, 98.25, 99.25,100.01,101.33,104.56,111.33,122.83, ...
593 139.09,158.94,180.83,203.55,226.50,249.50,272.50,295.50,318.50, ...
594 341.50,364.50,387.50,410.50,433.50,456.50 ];
595 R = cumsum(delR) - 0.5*delR;
596 Rmid = R(1:(length(R)-1)) + 0.5*diff(R);
597 hmid = [ -89.5:1:89.5 ];
598 % save allR delR R Rmid hmid
599
600 %------- UNUSED -----------------------
601 surf(hmid,-Rmid,num'), view(2), shading interp, colorbar
602 caxis([ -1 1 ])
603 caxis('manual')
604 surf(hmid,-Rmid,mu'), view(2), shading interp, colorbar
605 title('Zonally Averaged Stress for 1994--2003 [cube5]')
606 xlabel('Latitude [deg]')
607 zlabel('Depth [m]')
608 axis([ -90 90 -5500 200 ])
609
610 % print -dps -painters t_001.ps
611 print('-painters', '-dpng', '-r150', 'za_str_94--03_r150.png')
612 print('-painters', '-dpng', '-r650', 'za_str_94--03_r650.png')
613
614 % plot and print bar(U)
615 load zonalu
616 surf(hmid,-R,zonalu'), view(2), shading interp, colorbar
617 contour(hmid,-R,mu'), colorbar
618 ac = 25;
619 ac = [-0.3:.005:.3];
620 [c,h] = contourf(hmid,-R,mu',ac); colorbar
621 hold on, contour(hmid,-R,mu',ac), hold off
622 title('Zonally Averaged U for 1994--2003 [cube5]')
623 xlabel('Latitude [deg]')
624 zlabel('Depth [m]')
625 axis([ -90 90 -6000 200 ])
626 print('-painters', '-dpng', '-r150', 'Ull_94--03_r150.png')
627 print('-painters', '-dpng', '-r650', 'Ull_94--03_r650.png')
628 %------- UNUSED -----------------------
629
630
631 %=======================================================
632 % Put it all in NetCDF
633
634 clear all ; close all
635 load allR
636 % load zonalu
637 load zvpbpdbdz
638 load stress
639 load zonalB
640 % load dzaTdz
641 load zvpbp
642
643 % id0 = 'U';
644 id1 = 'zvpbpdbdz';
645 id2 = 'stress';
646 id3 = 'B';
647 % id4 = 'dzaTdz';
648 id5 = 'zvpbp';
649 % units0 = 'm/s';
650 units1 = 'm^2/s';
651 units2 = 'N/m^2';
652 units3 = 'kg/m^3';
653 % units4 = 'deg C/m';
654 units5 = 'm*kg/m^3';
655
656 !rm -f Zonal_ave_92-03.nc
657 nc = netcdf('Zonal_ave_92-03.nc', 'clobber');
658 nc.reference = 'Zonal averages from Dimitris "cube 5" integrations';
659 nc.author = 'Ed Hill <eh3@mit.edu>';
660 nc.date = 'Aug 11, 2004';
661
662 nc('X') = length(hmid);
663 nc('Y') = length(R);
664 nc('Ym1') = length(R) - 1;
665 nc{'X'} = 'X';
666 nc{'Y'} = 'Y';
667 nc{'Ym1'} = 'Ym1';
668 % nc{ id0 } = { 'Y', 'X' };
669 nc{ id1 } = { 'Ym1', 'X' };
670 nc{ id2 } = { 'Ym1', 'X' };
671 nc{ id3 } = { 'Y', 'X' };
672 % nc{ id4 } = { 'Ym1', 'X' };
673 nc{ id5 } = { 'Y', 'X' };
674 nc{'X'}.uniquename = 'X';
675 nc{'X'}.long_name = 'latitude';
676 nc{'X'}.gridtype = ncint(0);
677 nc{'X'}.units = 'degree_north';
678 nc{'Y'}.uniquename = 'Y';
679 nc{'Y'}.long_name = 'depth';
680 nc{'Y'}.gridtype = ncint(1);
681 nc{'Y'}.units = 'm';
682 nc{'Ym1'}.uniquename = 'Ym1';
683 nc{'Ym1'}.long_name = 'depth';
684 nc{'Ym1'}.gridtype = ncint(1);
685 nc{'Ym1'}.units = 'm';
686 % nc{ id0 }.units = units0;
687 % nc{ id0 }.long_name = id0;
688 % nc{ id0 }.missing_value = ncdouble(NaN);
689 % nc{ id0 }.FillValue_ = ncdouble(0.);
690 nc{ id1 }.units = units1;
691 nc{ id1 }.long_name = id1;
692 nc{ id1 }.missing_value = ncdouble(NaN);
693 nc{ id1 }.FillValue_ = ncdouble(0.);
694 nc{ id2 }.units = units2;
695 nc{ id2 }.long_name = id2;
696 nc{ id2 }.missing_value = ncdouble(NaN);
697 nc{ id2 }.FillValue_ = ncdouble(0.);
698 nc{ id3 }.units = units3;
699 nc{ id3 }.long_name = id3;
700 nc{ id3 }.missing_value = ncdouble(NaN);
701 nc{ id3 }.FillValue_ = ncdouble(0.);
702 % nc{ id4 }.units = units4;
703 % nc{ id4 }.long_name = id4;
704 % nc{ id4 }.missing_value = ncdouble(NaN);
705 % nc{ id4 }.FillValue_ = ncdouble(0.);
706 nc{ id5 }.units = units5;
707 nc{ id5 }.long_name = id5;
708 nc{ id5 }.missing_value = ncdouble(NaN);
709 nc{ id5 }.FillValue_ = ncdouble(0.);
710 nc{'X'}(:) = hmid;
711 nc{'Y'}(:) = -R;
712 nc{'Ym1'}(:) = -Rmid;
713 % nc{ id0 }(:) = permute(zonalu,[ 2 1 ]);
714 nc{ id1 }(:) = permute(zvpbpdbdz,[ 2 1 ]);
715 nc{ id2 }(:) = permute(stress,[ 2 1 ]);
716 nc{ id3 }(:) = permute(zonalB,[ 2 1 ]);
717 % nc{ id4 }(:) = permute(dzaTdz,[ 2 1 ]);
718 nc{ id5 }(:) = permute(zvpbp,[ 2 1 ]);
719 nc = close(nc);
720
721 % !scp Zonal_ave_92-03.nc ingrid.mit.edu:INGRID_PEOPLE/EH3/eddy_flux/cube_5/

  ViewVC Help
Powered by ViewVC 1.1.22