/[MITgcm]/MITgcm_contrib/high_res_cube/eddy_flux/c20a/plot_c20a.m
ViewVC logotype

Annotation of /MITgcm_contrib/high_res_cube/eddy_flux/c20a/plot_c20a.m

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


Revision 1.1 - (hide annotations) (download)
Thu Feb 24 15:38:35 2005 UTC (20 years, 5 months ago) by edhill
Branch: MAIN
 o initial check-in

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

  ViewVC Help
Powered by ViewVC 1.1.22