/[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.8 - (hide annotations) (download)
Wed Mar 23 21:46:02 2005 UTC (20 years, 4 months ago) by edhill
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +20 -14 lines
 o add Altix job files

1 edhill 1.1 %=======================================================
2     %
3 edhill 1.8 % $Header: /u/gcmpack/MITgcm_contrib/high_res_cube/eddy_flux/c20a/plot_c20a.m,v 1.7 2005/03/04 03:21:58 edhill Exp $
4 edhill 1.1 %
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 edhill 1.2 %==================================================================
34     % Read the tile00?.mitgrid files
35 edhill 1.1 gvars = { 'XC','YC','DXF','DYF','RA','XG','YG','DXV', ...
36     'DYU','RAZ','DXC','DYC','RAW','RAS','DXG','DYG' };
37    
38 edhill 1.2 ne = 510;
39     nep1 = ne + 1;
40 edhill 1.1 iface = 1;
41     for iface = 1:6
42     fname = sprintf('grid/tile%03d.mitgrid', iface);
43     gid = fopen(fname, 'r', 'ieee-be');
44 edhill 1.2 tmp = reshape(fread(gid,inf,'real*8',0,'ieee-be'),[nep1,nep1,16]);
45 edhill 1.1 fclose(gid);
46     % surf(tmp(:,:,1)), view(2), shading interp
47     % for jj = 1:length(gvars)
48     for jj = 1:7
49     comm = sprintf('%s(:,:,%d) = tmp(:,:,%d);', ...
50     [gvars{jj}], iface, jj);
51     eval(comm);
52     end
53     end
54     % surf(XC(:,:,1)), view(2), shading interp
55     % subplot(2,1,1), a = [1:10]; surf(XC(a,a,1)), view(2)
56 edhill 1.2 % subplot(2,1,2), a = [(nep1-10):nep1]; surf(XC(a,a,1)), view(2)
57 edhill 1.1 % surf(YC(:,:,1)), view(2), shading interp
58     % surf(XG(:,:,1)), view(2), shading interp
59     % surf(YG(:,:,1)), view(2), shading interp
60 edhill 1.2 is = [1:ne];
61     vs = { 'XC','YC','DXF','DYF','RA' };
62     for i = 1:length(vs)
63     eval(sprintf('%s = %s(is,is,:);',vs{i},vs{i}));
64 edhill 1.1 end
65    
66 edhill 1.2 delR = [ ...
67     10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.01, ...
68     10.03, 10.11, 10.32, 10.80, 11.76, 13.42, 16.04 , 19.82, 24.85, ...
69     31.10, 38.42, 46.50, 55.00, 63.50, 71.58, 78.90, 85.15, 90.18, ...
70     93.96, 96.58, 98.25, 99.25,100.01,101.33,104.56,111.33,122.83, ...
71     139.09,158.94,180.83,203.55,226.50,249.50,272.50,295.50,318.50, ...
72     341.50,364.50,387.50,410.50,433.50,456.50 ];
73     R = cumsum(delR) - 0.5*delR;
74    
75     %==================================================================
76     % Project fields to lower-res 1-degree Lat-Lon and write
77     % as NetCDF for viewing with Ingrid
78     %
79 edhill 1.1 % !echo `ls -1 ave__92_99 | sed -e 's|\.ave||g' \
80     % | sed -e "s|^|'|g" | sed -e "s|$|',|g"`
81 edhill 1.2 fields_3d = { ...
82     'DRHODR', 'RHOANOSQ', 'RHOAnoma', 'SALT', ...
83     'SALTSQ', ...
84     'THETA', 'THETASQ', 'URHOMASS', ...
85 edhill 1.1 'USLTMASS', 'UTHMASS', 'UVEL', 'UVELMASS', 'UVELSQ', ...
86     'UV_VEL_Z', 'VRHOMASS', 'VSLTMASS', 'VTHMASS', ...
87     'VVEL', 'VVELMASS', 'VVELSQ', 'WRHOMASS', 'WSLTMASS', ...
88     'WTHMASS', 'WU_VEL', 'WVELMASS', 'WVELSQ', 'WV_VEL' };
89 edhill 1.2 fields_2d = { ...
90     'ETANSQ', 'SFLUX', 'SRELAX', 'TAUX', 'TAUY', 'TFLUX', ...
91     'TICE', 'TRELAX' };
92     % fid = fopen('ave__92_99/DRHODR.ave','r','ieee-be');
93     % tmp = fread(gid,inf,'real*4',0,'ieee-be');
94     % fclose(fid);
95    
96     ne = 510;
97     nf = 6;
98     nz = 50;
99     nslab = ne*ne*nf;
100     adir = 'ave__92_99';
101     lat = [-90:90];
102     lon = [0:360];
103    
104     % ! rm -f cube_20a_*.nc
105    
106     ifld = 5;
107     fields = union(fields_2d, fields_3d);
108     for ifld = 1:length(fields)
109    
110 edhill 1.4 ir = [ 1 2 3 5 10 15 20 25 30 35 40 50 ];
111 edhill 1.2 if ismember(fields{ifld},fields_2d)
112     ir = [ 1 ];
113     end
114    
115     disp([ ' ' fields{ifld} ' :' ]);
116    
117     nc = netcdf(['cube_20a_' fields{ifld} '.nc'], 'clobber');
118     nc.reference = [ 'Results from Dimitris Menemenlis''' ...
119     '"cube 20a" integrations' ];
120     nc.author = 'Ed Hill <eh3@mit.edu>';
121     nc.date = 'Feb 24, 2005';
122     nc('X') = length(lon);
123     nc('Y') = length(lat);
124     nc('Z') = length(ir);
125     nc{'X'} = 'X';
126     nc{'Y'} = 'Y';
127     nc{'Z'} = 'Z';
128     nc{'X'}.uniquename = 'X';
129     nc{'X'}.long_name = 'longitude';
130     nc{'X'}.gridtype = ncint(1);
131     nc{'X'}.units = 'degree_east';
132     nc{'Y'}.uniquename = 'Y';
133     nc{'Y'}.long_name = 'latitude';
134     nc{'Y'}.gridtype = ncint(0);
135     nc{'Y'}.units = 'degree_north';
136     nc{'Z'}.uniquename = 'Z';
137     nc{'Z'}.long_name = 'depth';
138     nc{'Z'}.gridtype = ncint(0);
139     nc{'Z'}.units = 'm';
140     nc{'X'}(:) = lon;
141     nc{'Y'}(:) = lat;
142     nc{'Z'}(:) = R(ir);
143    
144     fname = sprintf('%s/%s.ave',adir,fields{ifld});
145     fid = fopen(fname,'r','ieee-be');
146    
147     id = fields{ifld};
148     nc{ id } = { 'Z' 'Y' 'X' };
149     nc{ id }.missing_value = ncdouble(NaN);
150     nc{ id }.FillValue_ = ncdouble(0.0);
151    
152     ii = 1;
153     for ii = 1:length(ir)
154    
155     iz = ir(ii);
156     disp(sprintf(' iz = %g',iz));
157    
158     fseek(fid,nslab*4*(iz-1),'bof');
159     tmp = fread(fid,nslab,'real*4',0,'ieee-be');
160     tr = permute(reshape(tmp,[ 510 6 510 ]),[1 3 2]);
161     % surf(tr(:,:,1)), view(2), shading interp
162     xc360 = XC + 180;
163     trn = tr;
164     trn(find(tr == 0.0)) = NaN;
165     clear tmp tr
166     % v = sdac_regrid(xc360,YC,trn,lonm,latm);
167     v = ll_regrid(xc360,YC,trn,lon,lat);
168     % surf(lon,lat,v'), caxis([25 40]), view(2), shading interp, colorbar
169    
170     nc{ id }(ii,:,:) = permute(v,[2 1]);
171    
172     end
173    
174     fclose(fid);
175     nc = close(nc);
176 edhill 1.4
177 edhill 1.2 end
178 edhill 1.1
179 edhill 1.3 % ! ncdump cube_20a.nc | more
180     % ! rm -rf output_netCDF ; mkdir output_netCDF
181     % ! scp output_netCDF/*.nc channel.mit.edu:/home/edhill/INGRID_PEOPLE/EH3/eddy_flux/cube_20a/
182    
183    
184    
185    
186     %=======================================================
187     % Compute [uvw]'[tsb]'
188 edhill 1.1
189 edhill 1.5 clear all
190     close all
191    
192 edhill 1.6 gvars = { 'XC','YC','DXF','DYF','RA','XG','YG','DXV', ...
193     'DYU','RAZ','DXC','DYC','RAW','RAS','DXG','DYG' };
194 edhill 1.5 ne = 510;
195     nep1 = ne + 1;
196     iface = 1;
197     for iface = 1:6
198     fname = sprintf('grid/tile%03d.mitgrid', iface);
199     gid = fopen(fname, 'r', 'ieee-be');
200     tmp = reshape(fread(gid,inf,'real*8',0,'ieee-be'),[nep1,nep1,16]);
201     fclose(gid);
202     % surf(tmp(:,:,1)), view(2), shading interp
203     % for jj = 1:length(gvars)
204     for jj = 1:7
205     comm = sprintf('%s(:,:,%d) = tmp(:,:,%d);', ...
206     [gvars{jj}], iface, jj);
207     eval(comm);
208     end
209     end
210     % surf(XC(:,:,1)), view(2), shading interp
211     % subplot(2,1,1), a = [1:10]; surf(XC(a,a,1)), view(2)
212     % subplot(2,1,2), a = [(nep1-10):nep1]; surf(XC(a,a,1)), view(2)
213     % surf(YC(:,:,1)), view(2), shading interp
214     % surf(XG(:,:,1)), view(2), shading interp
215     % surf(YG(:,:,1)), view(2), shading interp
216     is = [1:ne];
217     vs = { 'XC','YC','DXF','DYF','RA' };
218     for i = 1:length(vs)
219     eval(sprintf('%s = %s(is,is,:);',vs{i},vs{i}));
220     end
221    
222     delR = [ ...
223     10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.01, ...
224     10.03, 10.11, 10.32, 10.80, 11.76, 13.42, 16.04 , 19.82, 24.85, ...
225     31.10, 38.42, 46.50, 55.00, 63.50, 71.58, 78.90, 85.15, 90.18, ...
226     93.96, 96.58, 98.25, 99.25,100.01,101.33,104.56,111.33,122.83, ...
227     139.09,158.94,180.83,203.55,226.50,249.50,272.50,295.50,318.50, ...
228     341.50,364.50,387.50,410.50,433.50,456.50 ];
229     R = cumsum(delR) - 0.5*delR;
230    
231     n1 = ne - 1;
232     dux = zeros(size(XC));
233     duy = zeros(size(XC));
234     dvx = zeros(size(XC));
235     dvy = zeros(size(XC));
236     dux(:,:,:) = diff(XG(:,1:ne,:),1,1);
237     dvx(:,:,:) = diff(XG(1:ne,:,:),1,2);
238     duy(:,:,:) = diff(YG(:,1:ne,:),1,1);
239     dvy(:,:,:) = diff(YG(1:ne,:,:),1,2);
240     dux = dux + 360*double(dux < 180);
241     dux = dux - 360*double(dux > 180); % [ min(min(dux)) max(max(dux)) ]
242     duy = duy + 360*double(duy < 180);
243     duy = duy - 360*double(duy > 180); % [ min(min(duy)) max(max(duy)) ]
244     dvx = dvx + 360*double(dvx < 180);
245     dvx = dvx - 360*double(dvx > 180); % [ min(min(dvx)) max(max(dvx)) ]
246     dvy = dvy + 360*double(dvy < 180);
247     dvy = dvy - 360*double(dvy > 180); % [ min(min(dvy)) max(max(dvy)) ]
248     llux = dux ./ sqrt(dux.^2 + duy.^2);
249     lluy = duy ./ sqrt(dux.^2 + duy.^2);
250     llvx = dvx ./ sqrt(dvx.^2 + dvy.^2);
251     llvy = dvy ./ sqrt(dvx.^2 + dvy.^2);
252 edhill 1.1
253 edhill 1.3 lpath = 'ave__92_04/';
254     u__id = fopen( [lpath 'UVEL.ave'], 'r', 'ieee-be'); % 1
255     v__id = fopen( [lpath 'VVEL.ave'], 'r', 'ieee-be'); % 2
256     %w__id = fopen( [lpath 'WVEL.ave'], 'r', 'ieee-be');
257     u2_id = fopen( [lpath 'UVELSQ.ave'], 'r', 'ieee-be'); % 3
258     v2_id = fopen( [lpath 'VVELSQ.ave'], 'r', 'ieee-be'); % 4
259     w2_id = fopen( [lpath 'WVELSQ.ave'], 'r', 'ieee-be'); % 5
260     um_id = fopen( [lpath 'UVELMASS.ave'], 'r', 'ieee-be'); % 6
261     vm_id = fopen( [lpath 'VVELMASS.ave'], 'r', 'ieee-be'); % 7
262     wm_id = fopen( [lpath 'WVELMASS.ave'], 'r', 'ieee-be'); % 8
263     t__id = fopen( [lpath 'THETA.ave'], 'r', 'ieee-be'); % 9
264     t2_id = fopen( [lpath 'THETASQ.ave'], 'r', 'ieee-be'); % 10
265     s__id = fopen( [lpath 'SALT.ave'], 'r', 'ieee-be'); % 11
266     s2_id = fopen( [lpath 'SALTSQ.ave'], 'r', 'ieee-be'); % 12
267     b__id = fopen( [lpath 'RHOAnoma.ave'], 'r', 'ieee-be'); % 13
268     b2_id = fopen( [lpath 'RHOANOSQ.ave'], 'r', 'ieee-be'); % 14
269     ut_id = fopen( [lpath 'UTHMASS.ave'], 'r', 'ieee-be'); % 15
270     vt_id = fopen( [lpath 'VTHMASS.ave'], 'r', 'ieee-be'); % 16
271     wt_id = fopen( [lpath 'WTHMASS.ave'], 'r', 'ieee-be'); % 17
272     us_id = fopen( [lpath 'USLTMASS.ave'], 'r', 'ieee-be'); % 18
273     vs_id = fopen( [lpath 'VSLTMASS.ave'], 'r', 'ieee-be'); % 19
274     ws_id = fopen( [lpath 'WSLTMASS.ave'], 'r', 'ieee-be'); % 20
275     ub_id = fopen( [lpath 'URHOMASS.ave'], 'r', 'ieee-be'); % 21
276     vb_id = fopen( [lpath 'VRHOMASS.ave'], 'r', 'ieee-be'); % 22
277     wb_id = fopen( [lpath 'WRHOMASS.ave'], 'r', 'ieee-be'); % 23
278     dr_id = fopen( [lpath 'DRHODR.ave'], 'r', 'ieee-be'); % 24
279     iids = [ u__id v__id u2_id v2_id w2_id um_id vm_id wm_id ...
280     t__id t2_id s__id s2_id b__id b2_id ...
281     ut_id vt_id wt_id us_id vs_id ws_id ...
282     ub_id vb_id wb_id dr_id ];
283 edhill 1.6
284     % ! rm -rf primes_92_04 ; mkdir primes_92_04
285 edhill 1.3 opath = 'primes_92_04/';
286     up2___id = fopen([opath 'up2'], 'wb', 'ieee-be');
287     vp2___id = fopen([opath 'vp2'], 'wb', 'ieee-be');
288     wp2___id = fopen([opath 'wp2'], 'wb', 'ieee-be');
289     tp2___id = fopen([opath 'tp2'], 'wb', 'ieee-be');
290     sp2___id = fopen([opath 'sp2'], 'wb', 'ieee-be');
291     bp2___id = fopen([opath 'bp2'], 'wb', 'ieee-be');
292     uptp__id = fopen([opath 'uptp'], 'wb', 'ieee-be');
293     vptp__id = fopen([opath 'vptp'], 'wb', 'ieee-be');
294     wptp__id = fopen([opath 'wptp'], 'wb', 'ieee-be');
295     upsp__id = fopen([opath 'upsp'], 'wb', 'ieee-be');
296     vpsp__id = fopen([opath 'vpsp'], 'wb', 'ieee-be');
297     wpsp__id = fopen([opath 'wpsp'], 'wb', 'ieee-be');
298     upbp__id = fopen([opath 'upbp'], 'wb', 'ieee-be');
299     vpbp__id = fopen([opath 'vpbp'], 'wb', 'ieee-be');
300     wpbp__id = fopen([opath 'wpbp'], 'wb', 'ieee-be');
301 edhill 1.5 vpbpdzid = fopen([opath 'vpbp_dbdz'], 'wb', 'ieee-be');
302 edhill 1.6 str___id = fopen([opath 'stress'], 'wb', 'ieee-be');
303 edhill 1.5
304 edhill 1.3 comm = [ 'permute(reshape(fread( id ,nslab,''real*4'',0,' ...
305     '''ieee-be''),[ne 6 ne]),[1 3 2]);' ];
306     readslab = inline(comm,'id','nslab','ne');
307    
308     ne = 510;
309     nslab = 6 * ne * ne;
310     nztot = 50;
311     iz = 1;
312     for iz = 1:nztot
313 edhill 1.1
314 edhill 1.6 disp(sprintf(' iz = %d',iz));
315 edhill 1.3 offset = (iz - 1)*nslab*4;
316     for iid = 1:length(iids)
317     fseek(iids(iid), offset, 'bof');
318     end
319     u = readslab(u__id,nslab,ne); u2 = readslab(u2_id,nslab,ne);
320     v = readslab(v__id,nslab,ne); v2 = readslab(v2_id,nslab,ne);
321     um = readslab(um_id,nslab,ne);
322     vm = readslab(vm_id,nslab,ne);
323 edhill 1.4 wm = readslab(wm_id,nslab,ne);
324     % surf(v2(:,:,1)), view(2), shading interp
325     if (iz < nztot)
326     wmp1 = readslab(wm_id,nslab,ne);
327     else
328     wmp1 = zeros(size(wm));
329     end
330     wmp05 = (wm + wmp1)/2.0;
331     w2 = readslab(w2_id,nslab,ne);
332 edhill 1.3 t = readslab(t__id,nslab,ne); t2 = readslab(t2_id,nslab,ne);
333     s = readslab(s__id,nslab,ne); s2 = readslab(s2_id,nslab,ne);
334     b = readslab(b__id,nslab,ne); b2 = readslab(b2_id,nslab,ne);
335    
336     % "simple squared" quantities
337     up2 = u2 - u.^2;
338     vp2 = v2 - v.^2;
339     wp2 = w2 - wm.^2;
340     fwrite(up2___id, up2, 'real*4');
341     fwrite(vp2___id, vp2, 'real*4');
342     fwrite(wp2___id, wp2, 'real*4');
343     clear up2 vp2 wp2 u2 v2 w2
344     tp2 = t2 - t.^2;
345     sp2 = s2 - s.^2;
346     bp2 = b2 - b.^2;
347     fwrite(tp2___id, tp2, 'real*4');
348     fwrite(sp2___id, sp2, 'real*4');
349     fwrite(bp2___id, bp2, 'real*4');
350     clear tp2 sp2 bp2 t2 s2 b2
351     ut = readslab(ut_id,nslab,ne); vt = readslab(vt_id,nslab,ne);
352     us = readslab(us_id,nslab,ne); vs = readslab(vs_id,nslab,ne);
353     ub = readslab(ub_id,nslab,ne); vb = readslab(vb_id,nslab,ne);
354 edhill 1.5 drhodr = readslab(dr_id,nslab,ne);
355 edhill 1.3 [ tonu, tonv ] = mass_on_u_v(t);
356     [ sonu, sonv ] = mass_on_u_v(s);
357     [ bonu, bonv ] = mass_on_u_v(b);
358     uptp = ut - u .* tonu; vptp = vt - v .* tonv;
359     upsp = us - u .* sonu; vpsp = vs - v .* sonv;
360     upbp = ub - u .* bonu; vpbp = vb - v .* bonv;
361 edhill 1.5
362 edhill 1.6 % llupbp = upbp .* llux + vpbp .* llvx;
363 edhill 1.5 llvpbp = upbp .* lluy + vpbp .* llvy;
364 edhill 1.6 if iz > 1
365     % ave_llupbp = (llupbp + old_llupbp)/2.0;
366     ave_llvpbp = (llvpbp + old_llvpbp)/2.0;
367     tmp = drhodr;
368     tmp(find(tmp == 0.0)) = 1.0;
369     vpbpdbdz = ave_llvpbp ./ tmp;
370     fwrite(vpbpdzid, vpbpdbdz, 'real*4');
371     fac = 1000 * 2*pi/(24*3600);
372     stress = fac * sin(pi*YC/180) .* vpbpdbdz;
373     fwrite(str___id, stress, 'real*4');
374     end
375     % old_llupbp = llupbp;
376     old_llvpbp = llvpbp;
377 edhill 1.5
378 edhill 1.3 fwrite(uptp__id, uptp, 'real*4');
379     fwrite(vptp__id, vptp, 'real*4');
380     fwrite(upsp__id, upsp, 'real*4');
381     fwrite(vpsp__id, vpsp, 'real*4');
382     fwrite(upbp__id, upbp, 'real*4');
383     fwrite(vpbp__id, vpbp, 'real*4');
384 edhill 1.5 clear uptp vptp upsp vpsp upbp vpbp vpbpdbdz
385 edhill 1.4 wt = readslab(wt_id,nslab,ne); wptp = wt - wmp05 .* t;
386     ws = readslab(ws_id,nslab,ne); wpsp = ws - wmp05 .* s;
387     wb = readslab(wb_id,nslab,ne); wpbp = wb - wmp05 .* b;
388     fwrite(wptp__id, wptp, 'real*4');
389     fwrite(wpsp__id, wpsp, 'real*4');
390     fwrite(wpbp__id, wpbp, 'real*4');
391 edhill 1.3 end
392 edhill 1.6
393     ne = 510;
394     nz = 1;
395     nr = 50;
396     nrm1 = nr - 1;
397     nlat = 181; nlatm1 = nlat - 1;
398     % save indicies for zonal averages
399     hvals = linspace(-90,90,nlat);
400     i = 2;
401     for i = 2:nlat
402     inds = find(hvals(i-1)<YC & YC<hvals(i));
403     comm = sprintf('inds%04d = uint32(inds);',i-1);
404     eval(comm);
405     end
406    
407     comm = [ 'reshape(fread( id ,nslab,''real*4'',0,' ...
408     '''ieee-be''),[ne ne 6]);' ];
409     readcubelev = inline(comm,'id','nslab','ne');
410    
411 edhill 1.8 % Zonally average the ll_vpbp
412 edhill 1.6 acc = zeros(nlatm1, nrm1);
413     num = zeros(size(acc));
414 edhill 1.8 zidu = fopen('primes_92_04/upbp', 'r', 'ieee-be');
415     zidv = fopen('primes_92_04/vpbp', 'r', 'ieee-be');
416 edhill 1.6 for iz = 1:50,
417     disp(sprintf('iz = %d',iz));
418 edhill 1.8 fseek(zidu, (iz - 1)*(ne*ne*6)*4, 'bof');
419     fseek(zidv, (iz - 1)*(ne*ne*6)*4, 'bof');
420     upbp = readcubelev(zidu,nslab,ne);
421     vpbp = readcubelev(zidu,nslab,ne);
422     llvpbp = upbp .* lluy + vpbp .* llvy;
423     % surf(llvpbp(:,:,1)), view(2), shading interp, caxis([-.1 .1])
424 edhill 1.6 for jj = 1:nlatm1
425     eval( sprintf('clear inds; inds = inds%04d;',jj) );
426 edhill 1.8 tmp = llvpbp(inds);
427 edhill 1.6 nzinds = find(tmp ~= 0.0);
428     num(jj,iz) = length(nzinds);
429     acc(jj,iz) = sum(tmp(nzinds));
430     end
431     end
432 edhill 1.8 fclose(zidu);
433     fclose(zidv);
434     llzvpbp = acc ./ num;
435     % surf(zvpbp'), view(2), shading interp, caxis([-.1 .1])
436     % save primes_92_04/za_llvpbp.mat llzvpbp
437 edhill 1.6
438 edhill 1.8 % zonally average ll_vpbp_dbdz
439 edhill 1.6 acc = zeros(nlatm1, nrm1);
440     num = zeros(size(acc));
441     zid = fopen('primes_92_04/vpbp_dbdz', 'r', 'ieee-be');
442     iz = 1;
443 edhill 1.7 for iz = 1:49,
444 edhill 1.6 disp(sprintf('iz = %d',iz));
445     fseek(zid, (iz - 1)*(ne*ne*6)*4, 'bof');
446     vpbpdbdz = readcubelev(zid,nslab,ne);
447 edhill 1.8 % surf(vpbpdbdz(:,:,1)), view(2), shading interp, caxis([-50 50])
448 edhill 1.6 for jj = 1:nlatm1
449     eval( sprintf('clear inds; inds = inds%04d;',jj) );
450     tmp = vpbpdbdz(inds);
451     nzinds = find(tmp ~= 0.0);
452     num(jj,iz) = length(nzinds);
453     acc(jj,iz) = sum(tmp(nzinds));
454     end
455     end
456     fclose(zid);
457 edhill 1.8 za_ll_vpbp_dbdz = acc ./ num;
458     % save primes_92_04/za_ll_vpbp_dbdz.mat za_ll_vpbp_dbdz
459 edhill 1.3
460 edhill 1.6 % zonally average stress
461     acc = zeros(nlatm1, nrm1);
462     num = zeros(size(acc));
463 edhill 1.7 zid = fopen('primes_92_04/stress', 'r', 'ieee-be');
464 edhill 1.6 iz = 1;
465     for iz = 1:49,
466     disp(sprintf('iz = %d',iz));
467 edhill 1.7 fseek(zid, (iz - 1)*(ne*ne*6)*4, 'bof');
468     stress = readcubelev(zid,nslab,ne);
469 edhill 1.6 for jj = 1:nlatm1
470     eval( sprintf('clear inds; inds = inds%04d;',jj) );
471     tmp = stress(inds);
472     nzinds = find(tmp ~= 0.0);
473     num(jj,iz) = length(nzinds);
474     acc(jj,iz) = sum(tmp(nzinds));
475     end
476     end
477     fclose(zid);
478     stress = acc ./ num;
479 edhill 1.7 % save primes_92_04/stress.mat stress
480    
481    
482 edhill 1.4
483     clear all
484     close all
485 edhill 1.3
486 edhill 1.4 %==================================================================
487     % Read the tile00?.mitgrid files
488     gvars = { 'XC','YC','DXF','DYF','RA','XG','YG','DXV', ...
489     'DYU','RAZ','DXC','DYC','RAW','RAS','DXG','DYG' };
490    
491     ne = 510;
492     nep1 = ne + 1;
493     iface = 1;
494     for iface = 1:6
495     fname = sprintf('grid/tile%03d.mitgrid', iface);
496     gid = fopen(fname, 'r', 'ieee-be');
497     tmp = reshape(fread(gid,inf,'real*8',0,'ieee-be'),[nep1,nep1,16]);
498     fclose(gid);
499     % surf(tmp(:,:,1)), view(2), shading interp
500     % for jj = 1:length(gvars)
501     for jj = 1:7
502     comm = sprintf('%s(:,:,%d) = tmp(:,:,%d);', ...
503     [gvars{jj}], iface, jj);
504     eval(comm);
505     end
506     end
507     % surf(XC(:,:,1)), view(2), shading interp
508     % subplot(2,1,1), a = [1:10]; surf(XC(a,a,1)), view(2)
509     % subplot(2,1,2), a = [(nep1-10):nep1]; surf(XC(a,a,1)), view(2)
510     % surf(YC(:,:,1)), view(2), shading interp
511     % surf(XG(:,:,1)), view(2), shading interp
512     % surf(YG(:,:,1)), view(2), shading interp
513     is = [1:ne];
514     vs = { 'XC','YC','DXF','DYF','RA' };
515     for i = 1:length(vs)
516     eval(sprintf('%s = %s(is,is,:);',vs{i},vs{i}));
517     end
518    
519     delR = [ ...
520     10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.01, ...
521     10.03, 10.11, 10.32, 10.80, 11.76, 13.42, 16.04 , 19.82, 24.85, ...
522     31.10, 38.42, 46.50, 55.00, 63.50, 71.58, 78.90, 85.15, 90.18, ...
523     93.96, 96.58, 98.25, 99.25,100.01,101.33,104.56,111.33,122.83, ...
524     139.09,158.94,180.83,203.55,226.50,249.50,272.50,295.50,318.50, ...
525     341.50,364.50,387.50,410.50,433.50,456.50 ];
526     R = cumsum(delR) - 0.5*delR;
527    
528     n1 = ne - 1;
529     dux = zeros(size(XC));
530     duy = zeros(size(XC));
531     dvx = zeros(size(XC));
532     dvy = zeros(size(XC));
533     dux(:,:,:) = diff(XG(:,1:ne,:),1,1);
534     dvx(:,:,:) = diff(XG(1:ne,:,:),1,2);
535     duy(:,:,:) = diff(YG(:,1:ne,:),1,1);
536     dvy(:,:,:) = diff(YG(1:ne,:,:),1,2);
537     dux = dux + 360*double(dux < 180);
538     dux = dux - 360*double(dux > 180); % [ min(min(dux)) max(max(dux)) ]
539     duy = duy + 360*double(duy < 180);
540     duy = duy - 360*double(duy > 180); % [ min(min(duy)) max(max(duy)) ]
541     dvx = dvx + 360*double(dvx < 180);
542     dvx = dvx - 360*double(dvx > 180); % [ min(min(dvx)) max(max(dvx)) ]
543     dvy = dvy + 360*double(dvy < 180);
544     dvy = dvy - 360*double(dvy > 180); % [ min(min(dvy)) max(max(dvy)) ]
545     llux = dux ./ sqrt(dux.^2 + duy.^2);
546     lluy = duy ./ sqrt(dux.^2 + duy.^2);
547     llvx = dvx ./ sqrt(dvx.^2 + dvy.^2);
548     llvy = dvy ./ sqrt(dvx.^2 + dvy.^2);
549    
550     %==================================================================
551     % Project fields to lower-res 1-degree Lat-Lon and write
552     % as NetCDF for viewing with Ingrid
553     %
554     ne = 510;
555     nf = 6;
556     nz = 50;
557     nslab = ne*ne*nf;
558     adir = 'primes_92_04';
559     lat = [-90:90];
560     lon = [0:360];
561     ir = [ 1 2 3 5 10 15 20 25 30 35 40 50 ];
562     xc360 = XC + 180;
563    
564     % ! rm -f cube_20a_primes.nc
565     nc = netcdf(['cube_20a_primes.nc'], 'clobber');
566     nc.reference = [ 'Results from Dimitris Menemenlis''' ...
567     '"cube 20a" integrations' ];
568     nc.author = 'Ed Hill <eh3@mit.edu>';
569     nc.date = 'Feb 28, 2005';
570     nc('X') = length(lon);
571     nc('Y') = length(lat);
572     nc('Z') = length(ir);
573     nc{'X'} = 'X';
574     nc{'Y'} = 'Y';
575     nc{'Z'} = 'Z';
576     nc{'X'}.uniquename = 'X';
577     nc{'X'}.long_name = 'longitude';
578     nc{'X'}.gridtype = ncint(1);
579     nc{'X'}.units = 'degree_east';
580     nc{'Y'}.uniquename = 'Y';
581     nc{'Y'}.long_name = 'latitude';
582     nc{'Y'}.gridtype = ncint(0);
583     nc{'Y'}.units = 'degree_north';
584     nc{'Z'}.uniquename = 'Z';
585     nc{'Z'}.long_name = 'depth';
586     nc{'Z'}.gridtype = ncint(0);
587     nc{'Z'}.units = 'm';
588     nc{'X'}(:) = lon;
589     nc{'Y'}(:) = lat;
590     nc{'Z'}(:) = R(ir);
591    
592 edhill 1.6 f_s_3d = { {'tp2'}, {'sp2'}, {'bp2'}, {'vpbp_dbdz'} };
593 edhill 1.4
594     ifg = 1;
595     for ifg = 1:length(f_s_3d)
596    
597     acell = f_s_3d{ifg};
598     tname = acell{1};
599     disp([ ' ' tname ' :' ]);
600    
601     fname = sprintf('%s/%s',adir,tname);
602     fid = fopen(fname,'r','ieee-be');
603    
604     id = tname;
605     nc{ id } = { 'Z' 'Y' 'X' };
606     nc{ id }.missing_value = ncdouble(NaN);
607     nc{ id }.FillValue_ = ncdouble(0.0);
608    
609     ii = 1;
610     for ii = 1:length(ir)
611    
612     iz = ir(ii);
613     disp(sprintf(' iz = %3d R(iz) = %g',iz,R(iz)));
614    
615     fseek(fid,nslab*4*(iz-1),'bof');
616     tmp = fread(fid,nslab,'real*4',0,'ieee-be');
617     tr = reshape(tmp,[ 510 510 6 ]);
618     % surf(tr(:,:,1)), view(2), shading interp
619     trn = tr;
620     trn(find(tr == 0.0)) = NaN;
621     clear tmp tr
622     % v = sdac_regrid(xc360,YC,trn,lonm,latm);
623     v = ll_regrid(xc360,YC,trn,lon,lat);
624     % surf(lon,lat,v'), caxis([25 40]), view(2), shading interp, colorbar
625    
626     nc{ id }(ii,:,:) = permute(v,[2 1]);
627    
628     end
629    
630     fclose(fid);
631    
632     end
633    
634     id = 'sum_up2_vp2';
635     nc{ id } = { 'Z' 'Y' 'X' };
636     nc{ id }.missing_value = ncdouble(NaN);
637     nc{ id }.FillValue_ = ncdouble(0.0);
638     fidu = fopen(sprintf('%s/%s',adir,'up2'),'r','ieee-be');
639     fidv = fopen(sprintf('%s/%s',adir,'vp2'),'r','ieee-be');
640     for ii = 1:length(ir)
641     iz = ir(ii);
642     disp(sprintf(' iz = %3d R(iz) = %g',iz,R(iz)));
643     fseek(fidu,nslab*4*(iz-1),'bof');
644     fseek(fidv,nslab*4*(iz-1),'bof');
645     tru = reshape(fread(fidu,nslab,'real*4',0,'ieee-be'),[510 510 6]);
646     trv = reshape(fread(fidv,nslab,'real*4',0,'ieee-be'),[510 510 6]);
647     trnu = tru; trnu(find(tru == 0.0)) = NaN;
648     trnv = trv; trnv(find(trv == 0.0)) = NaN;
649     clear tmp tru trv
650     lluv = ll_regrid(xc360,YC,trnu+trnv,lon,lat);
651     nc{ id }(ii,:,:) = permute(lluv,[2 1]);
652     end
653     fclose(fidu);
654     fclose(fidv);
655    
656 edhill 1.5 f_v_3d = { {'up2','vp2'}, ...
657     {'uptp','vptp'}, {'upsp','vpsp'}, {'upbp','vpbp'} };
658 edhill 1.4 for ip = 1:length(f_v_3d)
659     cell = f_v_3d{ip};
660     idu = cell{1};
661     idv = cell{2};
662 edhill 1.5 disp([' ' idu ' ' idv]);
663 edhill 1.4 nc{ idu } = { 'Z' 'Y' 'X' };
664     nc{ idu }.missing_value = ncdouble(NaN);
665     nc{ idu }.FillValue_ = ncdouble(0.0);
666     nc{ idv } = { 'Z' 'Y' 'X' };
667     nc{ idv }.missing_value = ncdouble(NaN);
668     nc{ idv }.FillValue_ = ncdouble(0.0);
669     fidu = fopen(sprintf('%s/%s',adir,idu),'r','ieee-be');
670     fidv = fopen(sprintf('%s/%s',adir,idv),'r','ieee-be');
671     for ii = 1:length(ir)
672     iz = ir(ii);
673     disp(sprintf(' iz = %3d R(iz) = %g',iz,R(iz)));
674     fseek(fidu,nslab*4*(iz-1),'bof');
675     fseek(fidv,nslab*4*(iz-1),'bof');
676     tru = reshape(fread(fidu,nslab,'real*4',0,'ieee-be'),[510 510 6]);
677     trv = reshape(fread(fidv,nslab,'real*4',0,'ieee-be'),[510 510 6]);
678     trnu = tru; trnu(find(tru == 0.0)) = NaN;
679     trnv = trv; trnv(find(trv == 0.0)) = NaN;
680     clear tmp tru trv
681     llru = trnu .* llux + trnv .* llvx;
682     llrv = trnu .* lluy + trnv .* llvy;
683     llu = ll_regrid(xc360,YC,llru,lon,lat);
684     llv = ll_regrid(xc360,YC,llrv,lon,lat);
685     nc{ idu }(ii,:,:) = permute(llu,[2 1]);
686     nc{ idv }(ii,:,:) = permute(llv,[2 1]);
687     end
688     end
689     fclose(fidu);
690     fclose(fidv);
691 edhill 1.5
692    
693 edhill 1.4
694     nc = close(nc);
695    
696     % ! scp cube_20a_primes.nc channel.mit.edu:/home/edhill/INGRID_PEOPLE/EH3/eddy_flux/cube_20a/primes/
697     % ! mv cube_20a_primes.nc primes_92_04
698    
699 edhill 1.1
700    
701    
702    
703    
704 edhill 1.5 %------- UNUSED -----------------------
705 edhill 1.1
706    
707     %=======================================================
708     % Calculate : (v'B')/(dB/dz)
709    
710     bid = fopen( 'b-ave-1992-2003', 'r', 'ieee-be');
711     bm1id = fopen('bm1-ave-1992-2003', 'r', 'ieee-be');
712    
713     iz = 1;
714     offset = (iz - 1)*nps*4;
715     fseek(upbpid, offset, 'bof');
716     fseek(vpbpid, offset, 'bof');
717     upbp = reshape(fread(upbpid, nps, 'real*4'),ne,ne,6);
718     vpbp = reshape(fread(vpbpid, nps, 'real*4'),ne,ne,6);
719     llvpbp = upbp .* lluy + vpbp .* llvy;
720     llvpbpm1 = llvpbp;
721     ne = 510; tx = 85; ty = 85; nt = 216;
722    
723     iz = 2;
724     iz = 15;
725     iz = 16;
726     for iz = 2:50,
727     izm1 = iz - 1;
728     disp(sprintf('iz = %d',iz));
729     % iz = 21;
730     offset = (iz - 1)*nps*4;
731     fseek(upbpid, offset, 'bof');
732     fseek(vpbpid, offset, 'bof');
733     upbp = reshape(fread(upbpid, nps, 'real*4'),ne,ne,6);
734     vpbp = reshape(fread(vpbpid, nps, 'real*4'),ne,ne,6);
735    
736     % v'B' on ll coords
737     llvpbp = upbp .* lluy + vpbp .* llvy;
738    
739     % B and Bm1
740     fseek(bid, offset, 'bof');
741     b = reshape(fread(bid, nps, 'real*4'),ne,ne,6);
742     offm1 = (iz - 2)*nps*4;
743     fseek(bm1id, offm1, 'bof');
744     bm1 =reshape(fread(bm1id, nps, 'real*4'),ne,ne,6);
745    
746     % ( v'B' )/( dB/dz )
747     dbdz = (b - bm1)/(R(iz) - R(izm1));
748     ind0 = find(dbdz==0.0);
749     dbdz(ind0) = 1.0;
750     rdbdz = 1.0 / (dbdz);
751     rdbdz(ind0) = 0.0;
752     vpbpdbdz = 0.5*(llvpbp + llvpbpm1) .* rdbdz;
753    
754     % Write the results
755     mid = fopen('vpbpdbdz-1992-2003', 'a', 'ieee-be');
756     fwrite(mid, vpbpdbdz, 'real*4');
757     fclose(mid);
758    
759     % Plot results
760     clow = [ -10 ]; % -20;
761     chigh = [ 10 ]; % 20;
762     ll = zeros(6*510,510);
763     for i = 1:6
764     xb = (i-1)*510 + 1; xe = xb + 510 - 1;
765     yb = 1; ye = 510;
766     ll(xb:xe,yb:ye) = vpbpdbdz(:,:,i);
767     end
768     shift=-1;
769     grph_CS(sq(ll),xcs,ycs,xgs,ygs,[clow],[chigh],shift);
770     title([ '(v''B'')/(dB/dz) at ' ...
771     sprintf('%g',Rmid(iz)) ...
772     'm depth on the 510x510x6 cubesphere for 1992--2003 ["cube5"]']);
773     % print('-painters', '-dpng', '-r650', ...
774     % ['vpTpdTdz_' sprintf('%02d_%07.1f',iz,Rmid(iz)) 'm_650.png'])
775     print('-painters', '-dpng', '-r150', ...
776     ['vpBpdBdz_' sprintf('%02d_%07.1f',iz,Rmid(iz)) 'm_150.png'])
777    
778    
779     % Stress: calc, write, and plot
780     stress = 1000 * (2*pi/(24*3600)*sin(pi*yc/180));
781     stress = stress .* vpbpdbdz;
782     sid = fopen('stress-b-1992-2003', 'a', 'ieee-be');
783     fwrite(sid, stress, 'real*4');
784     fclose(sid);
785     clow = []; % [ -1 ];
786     chigh = []; % [ 1 ];
787     ll = zeros(6*510,510);
788     for i = 1:6
789     xb = (i-1)*510 + 1; xe = xb + 510 - 1;
790     yb = 1; ye = 510;
791     ll(xb:xe,yb:ye) = stress(:,:,i);
792     end
793     shift=-1;
794     grph_CS(sq(ll),xcs,ycs,xgs,ygs,[clow],[chigh],shift);
795     title([ 'Stress at ' ...
796     sprintf('%g',Rmid(iz)) ...
797     'm depth on the 510x510x6 cubesphere for 1994--2003 ["cube5"]']);
798     % print('-painters', '-dpng', '-r650', ...
799     % ['stress_' sprintf('%02d_%07.1f',iz,Rmid(iz)) 'm_650.png'])
800     print('-painters', '-dpng', '-r150', ...
801     ['stress_' sprintf('%02d_%07.1f',iz,Rmid(iz)) 'm_150.png'])
802    
803    
804     % Next level
805     llvpbpm1 = llvpbp;
806    
807     end
808    
809    
810     %=======================================================
811     % Zonally average vpbpdbdz and stress
812    
813     clear all ; close all
814     tx = 85;
815     ty = 85;
816     nt = 216;
817     cx = 510;
818     cy = 510;
819     nz = 1;
820     ne = 510;
821     nps = ne * ne * 6;
822    
823     % XCS YCS XGS YGS
824     fnam = [ 'XC' ; 'YC'; 'XG'; 'YG' ];
825     for in = 1:4
826     uid = fopen([fnam(in,:) '.data'], 'r', 'ieee-be');
827     phi = unmangleJPL1( reshape(fread(uid, nps, 'real*4'), ...
828     tx*nt,ty), ne, tx );
829     fclose(uid);
830     eval([lower(fnam(in,:)) ' = phi;']);
831     a = zeros(6*510,510);
832     for i = 1:6
833     xb = (i-1)*510 + 1; xe = xb + 510 - 1;
834     yb = 1; ye = 510;
835     a(xb:xe,yb:ye) = phi(:,:,i);
836     end
837     eval([lower(fnam(in,:)) 's = a;'])
838     end
839     xcs = xcs + -360.0*(xcs > 180.0);
840     xgs = xgs + -360.0*(xgs > 180.0);
841     clear phi a
842    
843     nz = 1;
844     nr = 50;
845     nrm1 = nr - 1;
846     nlat = 181; nlatm1 = nlat - 1;
847    
848     hvals = linspace(-90,90,nlat);
849     % save indicies for zonal averages
850     i = 2;
851     for i = 2:nlat
852     inds = find(hvals(i-1)<yg & yg<hvals(i));
853     comm = sprintf('inds%04d = uint32(inds);',i-1);
854     eval(comm);
855     end
856    
857     % Zonally average vpbp
858     acc = zeros(nlatm1, nrm1);
859     num = zeros(size(acc));
860     ne = 510;
861     nps = ne * ne * 6;
862     zid = fopen('vpbpll-1992-2003', 'r', 'ieee-be');
863     iz = 1;
864     for iz = 1:50,
865     disp(sprintf('iz = %d',iz));
866     offset = (iz - 1)*nps*4;
867     fseek(zid, offset, 'bof');
868     vpbp = reshape(fread(zid, nps, 'real*4'),ne,ne,6);
869    
870     for jj = 1:nlatm1
871     eval( sprintf('clear inds; inds = inds%04d;',jj) );
872     tmp = vpbp(inds);
873     nzinds = find(tmp ~= 0.0);
874     num(jj,iz) = length(nzinds);
875     acc(jj,iz) = sum(tmp(nzinds));
876     end
877     end
878     fclose(zid);
879     zvpbp = acc ./ num;
880     % save zvpbp zvpbp
881    
882     % zonally average vpbpdbdz
883     acc = zeros(nlatm1, nrm1);
884     num = zeros(size(acc));
885     ne = 510;
886     nps = ne * ne * 6;
887     zid = fopen('vpbpdbdz-1992-2003', 'r', 'ieee-be');
888     iz = 1;
889     for iz = 1:49,
890     disp(sprintf('iz = %d',iz));
891     offset = (iz - 1)*nps*4;
892     fseek(zid, offset, 'bof');
893     vpbpdbdz = reshape(fread(zid, nps, 'real*4'),ne,ne,6);
894    
895     for jj = 1:nlatm1
896     eval( sprintf('clear inds; inds = inds%04d;',jj) );
897     tmp = vpbpdbdz(inds);
898     nzinds = find(tmp ~= 0.0);
899     num(jj,iz) = length(nzinds);
900     acc(jj,iz) = sum(tmp(nzinds));
901     end
902     end
903     fclose(zid);
904     zvpbpdbdz = acc ./ num;
905     % save zvpbpdbdz zvpbpdbdz
906    
907     % zonally average stress
908     acc = zeros(nlatm1, nrm1);
909     num = zeros(size(acc));
910     ne = 510;
911     nps = ne * ne * 6;
912     zid = fopen('stress-b-1992-2003', 'r', 'ieee-be');
913     iz = 1;
914     for iz = 1:49,
915     disp(sprintf('iz = %d',iz));
916     offset = (iz - 1)*nps*4;
917     fseek(zid, offset, 'bof');
918     stress = reshape(fread(zid, nps, 'real*4'),ne,ne,6);
919     jj = 22;
920     for jj = 1:nlatm1
921     eval( sprintf('clear inds; inds = inds%04d;',jj) );
922     tmp = stress(inds);
923     nzinds = find(tmp ~= 0.0);
924     num(jj,iz) = length(nzinds);
925     acc(jj,iz) = sum(tmp(nzinds));
926     end
927     end
928     fclose(zid);
929     stress = acc ./ num;
930     % save stress stress
931    
932     %------- UNUSED -----------------------
933     % zonally average u
934     acc = zeros(nlatm1, 50);
935     num = zeros(size(acc));
936     ne = 510;
937     nps = ne * ne * 6;
938     zid = fopen('Ull_ave_1994--2003', 'r', 'ieee-be');
939     iz = 1;
940     for iz = 1:50,
941     disp(sprintf('iz = %d',iz));
942     offset = (iz - 1)*nps*4;
943     fseek(zid, offset, 'bof');
944     U = reshape(fread(zid, nps, 'real*4'),ne,ne,6);
945     jj = 22;
946     for jj = 1:nlatm1
947     eval( sprintf('clear inds; inds = inds%04d;',jj) );
948     tmp = U(inds);
949     nzinds = find(tmp ~= 0.0);
950     num(jj,iz) = length(nzinds);
951     acc(jj,iz) = sum(tmp(nzinds));
952     end
953     end
954     fclose(zid);
955     zonalu = acc ./ num;
956     % save zonalu zonalu
957     %------- UNUSED -----------------------
958    
959     % zonally average B
960     acc = zeros(nlatm1, 50);
961     num = zeros(size(acc));
962     ne = 510;
963     nps = ne * ne * 6;
964     zid = fopen('b-ave-1992-2003', 'r', 'ieee-be');
965     iz = 1;
966     for iz = 1:50,
967     disp(sprintf('iz = %d',iz));
968     offset = (iz - 1)*nps*4;
969     fseek(zid, offset, 'bof');
970     B = reshape(fread(zid, nps, 'real*4'),ne,ne,6);
971     jj = 22;
972     for jj = 1:nlatm1
973     eval( sprintf('clear inds; inds = inds%04d;',jj) );
974     tmp = B(inds);
975     nzinds = find(tmp ~= 0.0);
976     num(jj,iz) = length(nzinds);
977     acc(jj,iz) = sum(tmp(nzinds));
978     end
979     end
980     fclose(zid);
981     zonalB = acc ./ num;
982     % save zonalB zonalB
983    
984     %------- UNUSED -----------------------
985     % Vertical gradient of zonally averaged B (dB/dz)
986     load zonalT
987     load allR
988     nz = size(zonalT,1);
989     dzaTdz = zeros(nz,size(zonalT,2)-1);
990     for iz = 2:50
991     dzaTdz(:,iz-1) = (zonalT(:,iz) - zonalT(:,iz-1)) ./ (R(iz) - R(iz-1));
992     end
993     % save dzaTdz dzaTdz
994     %------- UNUSED -----------------------
995    
996    
997     delR = [
998     10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.01, ...
999     10.03, 10.11, 10.32, 10.80, 11.76, 13.42, 16.04 , 19.82, 24.85, ...
1000     31.10, 38.42, 46.50, 55.00, 63.50, 71.58, 78.90, 85.15, 90.18, ...
1001     93.96, 96.58, 98.25, 99.25,100.01,101.33,104.56,111.33,122.83, ...
1002     139.09,158.94,180.83,203.55,226.50,249.50,272.50,295.50,318.50, ...
1003     341.50,364.50,387.50,410.50,433.50,456.50 ];
1004     R = cumsum(delR) - 0.5*delR;
1005     Rmid = R(1:(length(R)-1)) + 0.5*diff(R);
1006     hmid = [ -89.5:1:89.5 ];
1007     % save allR delR R Rmid hmid
1008    
1009     %------- UNUSED -----------------------
1010     surf(hmid,-Rmid,num'), view(2), shading interp, colorbar
1011     caxis([ -1 1 ])
1012     caxis('manual')
1013     surf(hmid,-Rmid,mu'), view(2), shading interp, colorbar
1014     title('Zonally Averaged Stress for 1994--2003 [cube5]')
1015     xlabel('Latitude [deg]')
1016     zlabel('Depth [m]')
1017     axis([ -90 90 -5500 200 ])
1018    
1019     % print -dps -painters t_001.ps
1020     print('-painters', '-dpng', '-r150', 'za_str_94--03_r150.png')
1021     print('-painters', '-dpng', '-r650', 'za_str_94--03_r650.png')
1022    
1023     % plot and print bar(U)
1024     load zonalu
1025     surf(hmid,-R,zonalu'), view(2), shading interp, colorbar
1026     contour(hmid,-R,mu'), colorbar
1027     ac = 25;
1028     ac = [-0.3:.005:.3];
1029     [c,h] = contourf(hmid,-R,mu',ac); colorbar
1030     hold on, contour(hmid,-R,mu',ac), hold off
1031     title('Zonally Averaged U for 1994--2003 [cube5]')
1032     xlabel('Latitude [deg]')
1033     zlabel('Depth [m]')
1034     axis([ -90 90 -6000 200 ])
1035     print('-painters', '-dpng', '-r150', 'Ull_94--03_r150.png')
1036     print('-painters', '-dpng', '-r650', 'Ull_94--03_r650.png')
1037     %------- UNUSED -----------------------
1038    
1039    

  ViewVC Help
Powered by ViewVC 1.1.22