1 |
edhill |
1.1 |
%======================================================= |
2 |
|
|
% |
3 |
edhill |
1.3 |
% $Header: /u/gcmpack/MITgcm_contrib/high_res_cube/eddy_flux/c20a/plot_c20a.m,v 1.2 2005/02/25 19:21:30 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 |
|
|
ir = [ 1 2 3 5 10 15 20 35 30 35 40 50 ]; |
111 |
|
|
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 |
|
|
llval = zeros(length(lon),length(lat),50); |
145 |
|
|
fname = sprintf('%s/%s.ave',adir,fields{ifld}); |
146 |
|
|
fid = fopen(fname,'r','ieee-be'); |
147 |
|
|
|
148 |
|
|
id = fields{ifld}; |
149 |
|
|
nc{ id } = { 'Z' 'Y' 'X' }; |
150 |
|
|
nc{ id }.missing_value = ncdouble(NaN); |
151 |
|
|
nc{ id }.FillValue_ = ncdouble(0.0); |
152 |
|
|
|
153 |
|
|
ii = 1; |
154 |
|
|
for ii = 1:length(ir) |
155 |
|
|
|
156 |
|
|
iz = ir(ii); |
157 |
|
|
disp(sprintf(' iz = %g',iz)); |
158 |
|
|
|
159 |
|
|
fseek(fid,nslab*4*(iz-1),'bof'); |
160 |
|
|
tmp = fread(fid,nslab,'real*4',0,'ieee-be'); |
161 |
|
|
tr = permute(reshape(tmp,[ 510 6 510 ]),[1 3 2]); |
162 |
|
|
% surf(tr(:,:,1)), view(2), shading interp |
163 |
|
|
xc360 = XC + 180; |
164 |
|
|
trn = tr; |
165 |
|
|
trn(find(tr == 0.0)) = NaN; |
166 |
|
|
clear tmp tr |
167 |
|
|
% v = sdac_regrid(xc360,YC,trn,lonm,latm); |
168 |
|
|
v = ll_regrid(xc360,YC,trn,lon,lat); |
169 |
|
|
% surf(lon,lat,v'), caxis([25 40]), view(2), shading interp, colorbar |
170 |
|
|
|
171 |
|
|
nc{ id }(ii,:,:) = permute(v,[2 1]); |
172 |
|
|
|
173 |
|
|
end |
174 |
|
|
|
175 |
|
|
fclose(fid); |
176 |
|
|
nc = close(nc); |
177 |
edhill |
1.1 |
|
178 |
edhill |
1.2 |
end |
179 |
edhill |
1.1 |
|
180 |
edhill |
1.3 |
% ! ncdump cube_20a.nc | more |
181 |
|
|
% ! rm -rf output_netCDF ; mkdir output_netCDF |
182 |
|
|
% ! scp output_netCDF/*.nc channel.mit.edu:/home/edhill/INGRID_PEOPLE/EH3/eddy_flux/cube_20a/ |
183 |
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
%======================================================= |
188 |
|
|
% Compute [uvw]'[tsb]' |
189 |
edhill |
1.1 |
|
190 |
edhill |
1.3 |
clear all ; close all |
191 |
edhill |
1.1 |
|
192 |
edhill |
1.3 |
lpath = 'ave__92_04/'; |
193 |
|
|
u__id = fopen( [lpath 'UVEL.ave'], 'r', 'ieee-be'); % 1 |
194 |
|
|
v__id = fopen( [lpath 'VVEL.ave'], 'r', 'ieee-be'); % 2 |
195 |
|
|
%w__id = fopen( [lpath 'WVEL.ave'], 'r', 'ieee-be'); |
196 |
|
|
u2_id = fopen( [lpath 'UVELSQ.ave'], 'r', 'ieee-be'); % 3 |
197 |
|
|
v2_id = fopen( [lpath 'VVELSQ.ave'], 'r', 'ieee-be'); % 4 |
198 |
|
|
w2_id = fopen( [lpath 'WVELSQ.ave'], 'r', 'ieee-be'); % 5 |
199 |
|
|
um_id = fopen( [lpath 'UVELMASS.ave'], 'r', 'ieee-be'); % 6 |
200 |
|
|
vm_id = fopen( [lpath 'VVELMASS.ave'], 'r', 'ieee-be'); % 7 |
201 |
|
|
wm_id = fopen( [lpath 'WVELMASS.ave'], 'r', 'ieee-be'); % 8 |
202 |
|
|
t__id = fopen( [lpath 'THETA.ave'], 'r', 'ieee-be'); % 9 |
203 |
|
|
t2_id = fopen( [lpath 'THETASQ.ave'], 'r', 'ieee-be'); % 10 |
204 |
|
|
s__id = fopen( [lpath 'SALT.ave'], 'r', 'ieee-be'); % 11 |
205 |
|
|
s2_id = fopen( [lpath 'SALTSQ.ave'], 'r', 'ieee-be'); % 12 |
206 |
|
|
b__id = fopen( [lpath 'RHOAnoma.ave'], 'r', 'ieee-be'); % 13 |
207 |
|
|
b2_id = fopen( [lpath 'RHOANOSQ.ave'], 'r', 'ieee-be'); % 14 |
208 |
|
|
ut_id = fopen( [lpath 'UTHMASS.ave'], 'r', 'ieee-be'); % 15 |
209 |
|
|
vt_id = fopen( [lpath 'VTHMASS.ave'], 'r', 'ieee-be'); % 16 |
210 |
|
|
wt_id = fopen( [lpath 'WTHMASS.ave'], 'r', 'ieee-be'); % 17 |
211 |
|
|
us_id = fopen( [lpath 'USLTMASS.ave'], 'r', 'ieee-be'); % 18 |
212 |
|
|
vs_id = fopen( [lpath 'VSLTMASS.ave'], 'r', 'ieee-be'); % 19 |
213 |
|
|
ws_id = fopen( [lpath 'WSLTMASS.ave'], 'r', 'ieee-be'); % 20 |
214 |
|
|
ub_id = fopen( [lpath 'URHOMASS.ave'], 'r', 'ieee-be'); % 21 |
215 |
|
|
vb_id = fopen( [lpath 'VRHOMASS.ave'], 'r', 'ieee-be'); % 22 |
216 |
|
|
wb_id = fopen( [lpath 'WRHOMASS.ave'], 'r', 'ieee-be'); % 23 |
217 |
|
|
dr_id = fopen( [lpath 'DRHODR.ave'], 'r', 'ieee-be'); % 24 |
218 |
|
|
%_id = fopen( [lpath '.ave'], 'r', 'ieee-be'); % |
219 |
|
|
|
220 |
|
|
iids = [ u__id v__id u2_id v2_id w2_id um_id vm_id wm_id ... |
221 |
|
|
t__id t2_id s__id s2_id b__id b2_id ... |
222 |
|
|
ut_id vt_id wt_id us_id vs_id ws_id ... |
223 |
|
|
ub_id vb_id wb_id dr_id ]; |
224 |
|
|
% !mkdir primes_92_04 |
225 |
|
|
opath = 'primes_92_04/'; |
226 |
|
|
up2___id = fopen([opath 'up2'], 'wb', 'ieee-be'); |
227 |
|
|
vp2___id = fopen([opath 'vp2'], 'wb', 'ieee-be'); |
228 |
|
|
wp2___id = fopen([opath 'wp2'], 'wb', 'ieee-be'); |
229 |
|
|
tp2___id = fopen([opath 'tp2'], 'wb', 'ieee-be'); |
230 |
|
|
sp2___id = fopen([opath 'sp2'], 'wb', 'ieee-be'); |
231 |
|
|
bp2___id = fopen([opath 'bp2'], 'wb', 'ieee-be'); |
232 |
|
|
uptp__id = fopen([opath 'uptp'], 'wb', 'ieee-be'); |
233 |
|
|
vptp__id = fopen([opath 'vptp'], 'wb', 'ieee-be'); |
234 |
|
|
wptp__id = fopen([opath 'wptp'], 'wb', 'ieee-be'); |
235 |
|
|
upsp__id = fopen([opath 'upsp'], 'wb', 'ieee-be'); |
236 |
|
|
vpsp__id = fopen([opath 'vpsp'], 'wb', 'ieee-be'); |
237 |
|
|
wpsp__id = fopen([opath 'wpsp'], 'wb', 'ieee-be'); |
238 |
|
|
upbp__id = fopen([opath 'upbp'], 'wb', 'ieee-be'); |
239 |
|
|
vpbp__id = fopen([opath 'vpbp'], 'wb', 'ieee-be'); |
240 |
|
|
wpbp__id = fopen([opath 'wpbp'], 'wb', 'ieee-be'); |
241 |
|
|
|
242 |
|
|
comm = [ 'permute(reshape(fread( id ,nslab,''real*4'',0,' ... |
243 |
|
|
'''ieee-be''),[ne 6 ne]),[1 3 2]);' ]; |
244 |
|
|
readslab = inline(comm,'id','nslab','ne'); |
245 |
|
|
|
246 |
|
|
ne = 510; |
247 |
|
|
nslab = 6 * ne * ne; |
248 |
|
|
nztot = 50; |
249 |
|
|
iz = 1; |
250 |
|
|
for iz = 1:nztot |
251 |
edhill |
1.1 |
|
252 |
edhill |
1.3 |
disp(sprintf(' iz = %d',iz)); |
253 |
|
|
|
254 |
|
|
offset = (iz - 1)*nslab*4; |
255 |
|
|
for iid = 1:length(iids) |
256 |
|
|
fseek(iids(iid), offset, 'bof'); |
257 |
|
|
end |
258 |
|
|
|
259 |
|
|
u = readslab(u__id,nslab,ne); u2 = readslab(u2_id,nslab,ne); |
260 |
|
|
v = readslab(v__id,nslab,ne); v2 = readslab(v2_id,nslab,ne); |
261 |
|
|
um = readslab(um_id,nslab,ne); |
262 |
|
|
vm = readslab(vm_id,nslab,ne); |
263 |
|
|
wm = readslab(wm_id,nslab,ne); w2 = readslab(w2_id,nslab,ne); |
264 |
|
|
t = readslab(t__id,nslab,ne); t2 = readslab(t2_id,nslab,ne); |
265 |
|
|
s = readslab(s__id,nslab,ne); s2 = readslab(s2_id,nslab,ne); |
266 |
|
|
b = readslab(b__id,nslab,ne); b2 = readslab(b2_id,nslab,ne); |
267 |
|
|
|
268 |
|
|
% "simple squared" quantities |
269 |
|
|
up2 = u2 - u.^2; |
270 |
|
|
vp2 = v2 - v.^2; |
271 |
|
|
wp2 = w2 - wm.^2; |
272 |
|
|
fwrite(up2___id, up2, 'real*4'); |
273 |
|
|
fwrite(vp2___id, vp2, 'real*4'); |
274 |
|
|
fwrite(wp2___id, wp2, 'real*4'); |
275 |
|
|
clear up2 vp2 wp2 u2 v2 w2 |
276 |
|
|
tp2 = t2 - t.^2; |
277 |
|
|
sp2 = s2 - s.^2; |
278 |
|
|
bp2 = b2 - b.^2; |
279 |
|
|
fwrite(tp2___id, tp2, 'real*4'); |
280 |
|
|
fwrite(sp2___id, sp2, 'real*4'); |
281 |
|
|
fwrite(bp2___id, bp2, 'real*4'); |
282 |
|
|
clear tp2 sp2 bp2 t2 s2 b2 |
283 |
|
|
|
284 |
|
|
ut = readslab(ut_id,nslab,ne); vt = readslab(vt_id,nslab,ne); |
285 |
|
|
us = readslab(us_id,nslab,ne); vs = readslab(vs_id,nslab,ne); |
286 |
|
|
ub = readslab(ub_id,nslab,ne); vb = readslab(vb_id,nslab,ne); |
287 |
|
|
|
288 |
|
|
[ tonu, tonv ] = mass_on_u_v(t); |
289 |
|
|
[ sonu, sonv ] = mass_on_u_v(s); |
290 |
|
|
[ bonu, bonv ] = mass_on_u_v(b); |
291 |
|
|
uptp = ut - u .* tonu; vptp = vt - v .* tonv; |
292 |
|
|
upsp = us - u .* sonu; vpsp = vs - v .* sonv; |
293 |
|
|
upbp = ub - u .* bonu; vpbp = vb - v .* bonv; |
294 |
|
|
fwrite(uptp__id, uptp, 'real*4'); |
295 |
|
|
fwrite(vptp__id, vptp, 'real*4'); |
296 |
|
|
fwrite(upsp__id, upsp, 'real*4'); |
297 |
|
|
fwrite(vpsp__id, vpsp, 'real*4'); |
298 |
|
|
fwrite(upbp__id, upbp, 'real*4'); |
299 |
|
|
fwrite(vpbp__id, vpbp, 'real*4'); |
300 |
|
|
clear uptp vptp upsp vpsp upbp vpbp |
301 |
edhill |
1.1 |
|
302 |
edhill |
1.3 |
end |
303 |
|
|
|
304 |
|
|
|
305 |
edhill |
1.1 |
%------- UNUSED ----------------------- |
306 |
|
|
|
307 |
|
|
|
308 |
|
|
%======================================================= |
309 |
|
|
% Compute u'b' and v'b' |
310 |
|
|
|
311 |
|
|
clear all; close all |
312 |
|
|
|
313 |
|
|
bfid = fopen( 'b-ave-1992-2003', 'r', 'ieee-be'); |
314 |
|
|
ufid = fopen( 'U_ave_1992-2003', 'r', 'ieee-be'); |
315 |
|
|
vfid = fopen( 'V_ave_1992-2003', 'r', 'ieee-be'); |
316 |
|
|
ubfid = fopen('ub-ave-1992-2003', 'r', 'ieee-be'); |
317 |
|
|
vbfid = fopen('vb-ave-1992-2003', 'r', 'ieee-be'); |
318 |
|
|
|
319 |
|
|
afid = [ ufid vfid ]; |
320 |
|
|
av = [ 'ua'; 'va' ]; |
321 |
|
|
|
322 |
|
|
nztot = 50; |
323 |
|
|
ne = 510; |
324 |
|
|
nps = 6 * ne * ne; |
325 |
|
|
iz = 1; |
326 |
|
|
for iz = 1:nztot |
327 |
|
|
|
328 |
|
|
disp(sprintf('iz = %d', iz)); |
329 |
|
|
|
330 |
|
|
offset = (iz - 1)*nps*4; |
331 |
|
|
id = 1; |
332 |
|
|
for id = 1:length(afid) |
333 |
|
|
fseek(afid(id), offset, 'bof'); |
334 |
|
|
% Convert the horrible JPL mdsio layout to six saner faces |
335 |
|
|
ne = 510; tx = 85; ty = 85; nt = 216; |
336 |
|
|
phi = unmangleJPL1( reshape(fread(afid(id), nps, 'real*4'), ... |
337 |
|
|
tx*nt,ty), ne, tx ); |
338 |
|
|
comm = [ av(id,:) ' = phi;' ]; |
339 |
|
|
% disp(comm); |
340 |
|
|
eval(comm); |
341 |
|
|
end |
342 |
|
|
clear phi |
343 |
|
|
% surf(ua(:,:,1)), view(2), shading interp, axis equal |
344 |
|
|
% surf(va(:,:,1)), view(2), shading interp, axis equal |
345 |
|
|
|
346 |
|
|
fseek(bfid, offset, 'bof'); |
347 |
|
|
b = reshape(fread(bfid, nps, 'real*4'),ne,ne,6); |
348 |
|
|
% surf(b(:,:,1)), view(2), shading interp, axis equal |
349 |
|
|
fseek(ubfid, offset, 'bof'); |
350 |
|
|
ub = reshape(fread(ubfid, nps, 'real*4'),ne,ne,6); |
351 |
|
|
% surf(ub(:,:,1)), view(2), shading interp, axis equal |
352 |
|
|
fseek(vbfid, offset, 'bof'); |
353 |
|
|
vb = reshape(fread(vbfid, nps, 'real*4'),ne,ne,6); |
354 |
|
|
% surf(vb(:,:,1)), view(2), shading interp, axis equal |
355 |
|
|
|
356 |
|
|
% Fill the (ne+1)*(ne+1) grid with B values |
357 |
|
|
ni = ne; nip1 = ni + 1; |
358 |
|
|
nj = ne; njp1 = nj + 1; |
359 |
|
|
bcubep1 = zeros( [ nip1 njp1 6 ] ); |
360 |
|
|
for icf = 1:6 |
361 |
|
|
bcubep1(2:nip1,2:njp1,icf) = b(:,:,icf); |
362 |
|
|
end |
363 |
|
|
|
364 |
|
|
% Do the upwind-edge B exchanges |
365 |
|
|
bcubep1(1,2:njp1,1) = b(ni:-1:1,nj,5); % - |
366 |
|
|
bcubep1(2:nip1,1,1) = b(1:ni,nj,6); % - |
367 |
|
|
bcubep1(1,2:njp1,2) = b(ni,1:nj,1); % - |
368 |
|
|
bcubep1(2:nip1,1,2) = b(ni,nj:-1:1,6); % - |
369 |
|
|
bcubep1(1,2:njp1,3) = b(ni:-1:1,nj,1); % - |
370 |
|
|
bcubep1(2:nip1,1,3) = b(1:ni,nj,2); % - |
371 |
|
|
bcubep1(1,2:njp1,4) = b(ni,1:nj,3); % - |
372 |
|
|
bcubep1(2:nip1,1,4) = b(ni,nj:-1:1,2); % - |
373 |
|
|
bcubep1(1,2:njp1,5) = b(ni:-1:1,nj,3); % - |
374 |
|
|
bcubep1(2:nip1,1,5) = b(1:ni,nj,4); % - |
375 |
|
|
bcubep1(1,2:njp1,6) = b(ni,1:nj,5); % - |
376 |
|
|
bcubep1(2:nip1,1,6) = b(ni,nj:-1:1,4); % - |
377 |
|
|
|
378 |
|
|
% Get B values on the U grid points |
379 |
|
|
masku = 1.0 - abs(diff(double(bcubep1(2:nip1,:,:) == 0.0),1,2)); |
380 |
|
|
diffu = 0.5*diff(bcubep1(2:nip1,:,:),1,2); |
381 |
|
|
bonu = b(:,:,:) + masku.*diffu; |
382 |
|
|
|
383 |
|
|
% Get B values on the V grid points |
384 |
|
|
maskv = 1.0 - abs(diff(double(bcubep1(:,2:nip1,:) == 0.0),1,1)); |
385 |
|
|
diffv = 0.5*diff(bcubep1(:,2:nip1,:),1,1); |
386 |
|
|
bonv = b(:,:,:) + maskv.*diffv; |
387 |
|
|
|
388 |
|
|
% Compute u'B' and v'B' |
389 |
|
|
upbp = ub - ua .* bonu; |
390 |
|
|
vpbp = vb - va .* bonv; |
391 |
|
|
|
392 |
|
|
% Write the results |
393 |
|
|
ubid = fopen('upbp-1992-2003', 'a', 'ieee-be'); |
394 |
|
|
vbid = fopen('vpbp-1992-2003', 'a', 'ieee-be'); |
395 |
|
|
fwrite(ubid, upbp, 'real*4'); |
396 |
|
|
fwrite(vbid, vpbp, 'real*4'); |
397 |
|
|
fclose(ubid); |
398 |
|
|
fclose(vbid); |
399 |
|
|
|
400 |
|
|
end |
401 |
|
|
|
402 |
|
|
%======================================================= |
403 |
|
|
% Plot u'B' and v'B' on a Lat-Lon grid |
404 |
|
|
|
405 |
|
|
clear all, close all |
406 |
|
|
tx = 85; |
407 |
|
|
ty = 85; |
408 |
|
|
nt = 216; |
409 |
|
|
cx = 510; |
410 |
|
|
cy = 510; |
411 |
|
|
nz = 1; |
412 |
|
|
ne = 510; |
413 |
|
|
nps = ne * ne * 6; |
414 |
|
|
|
415 |
|
|
% XCS YCS XGS YGS |
416 |
|
|
fnam = [ 'XC' ; 'YC'; 'XG'; 'YG' ]; |
417 |
|
|
for in = 1:4 |
418 |
|
|
uid = fopen([fnam(in,:) '.data'], 'r', 'ieee-be'); |
419 |
|
|
phi = unmangleJPL1( reshape(fread(uid, nps, 'real*4'), ... |
420 |
|
|
tx*nt,ty), ne, tx ); |
421 |
|
|
fclose(uid); |
422 |
|
|
eval([lower(fnam(in,:)) ' = phi;']); |
423 |
|
|
a = zeros(6*510,510); |
424 |
|
|
for i = 1:6 |
425 |
|
|
xb = (i-1)*510 + 1; xe = xb + 510 - 1; |
426 |
|
|
yb = 1; ye = 510; |
427 |
|
|
a(xb:xe,yb:ye) = phi(:,:,i); |
428 |
|
|
end |
429 |
|
|
eval([lower(fnam(in,:)) 's = a;']) |
430 |
|
|
end |
431 |
|
|
xcs = xcs + -360.0*(xcs > 180.0); |
432 |
|
|
xgs = xgs + -360.0*(xgs > 180.0); |
433 |
|
|
clear phi a |
434 |
|
|
|
435 |
|
|
%======================================================= |
436 |
|
|
% Calculation rotations for Lat-Lon vector alignment |
437 |
|
|
|
438 |
|
|
ne = 510; |
439 |
|
|
n1 = ne - 1; |
440 |
|
|
dux = zeros(size(xg)); |
441 |
|
|
duy = zeros(size(xg)); |
442 |
|
|
dvx = zeros(size(xg)); |
443 |
|
|
dvy = zeros(size(xg)); |
444 |
|
|
dux(1:n1,:,:) = diff(xg,1,1); dux(ne,:,:) = dux(n1,:,:); |
445 |
|
|
dvx(:,1:n1,:) = diff(xg,1,2); dvx(:,ne,:) = dvx(:,n1,:); |
446 |
|
|
duy(1:n1,:,:) = diff(yg,1,1); duy(ne,:,:) = duy(n1,:,:); |
447 |
|
|
dvy(:,1:n1,:) = diff(yg,1,2); dvy(:,ne,:) = dvy(:,n1,:); |
448 |
|
|
dux = dux + 360*double(dux < 180); |
449 |
|
|
dux = dux - 360*double(dux > 180); % [ min(min(dux)) max(max(dux)) ] |
450 |
|
|
duy = duy + 360*double(duy < 180); |
451 |
|
|
duy = duy - 360*double(duy > 180); % [ min(min(duy)) max(max(duy)) ] |
452 |
|
|
dvx = dvx + 360*double(dvx < 180); |
453 |
|
|
dvx = dvx - 360*double(dvx > 180); % [ min(min(dvx)) max(max(dvx)) ] |
454 |
|
|
dvy = dvy + 360*double(dvy < 180); |
455 |
|
|
dvy = dvy - 360*double(dvy > 180); % [ min(min(dvy)) max(max(dvy)) ] |
456 |
|
|
llux = dux ./ sqrt(dux.^2 + duy.^2); |
457 |
|
|
lluy = duy ./ sqrt(dux.^2 + duy.^2); |
458 |
|
|
llvx = dvx ./ sqrt(dvx.^2 + dvy.^2); |
459 |
|
|
llvy = dvy ./ sqrt(dvx.^2 + dvy.^2); |
460 |
|
|
|
461 |
|
|
% surf(xg(:,:,2)), view(2), axis equal, shading interp, colorbar |
462 |
|
|
% surf(dux(:,:,2)), view(2), axis equal, shading interp, colorbar |
463 |
|
|
% surf(duy(:,:,2)), view(2), axis equal, shading interp, colorbar |
464 |
|
|
|
465 |
|
|
delR = [ |
466 |
|
|
10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.01, ... |
467 |
|
|
10.03, 10.11, 10.32, 10.80, 11.76, 13.42, 16.04 , 19.82, 24.85, ... |
468 |
|
|
31.10, 38.42, 46.50, 55.00, 63.50, 71.58, 78.90, 85.15, 90.18, ... |
469 |
|
|
93.96, 96.58, 98.25, 99.25,100.01,101.33,104.56,111.33,122.83, ... |
470 |
|
|
139.09,158.94,180.83,203.55,226.50,249.50,272.50,295.50,318.50, ... |
471 |
|
|
341.50,364.50,387.50,410.50,433.50,456.50 ]; |
472 |
|
|
R = cumsum(delR) - 0.5*delR; |
473 |
|
|
Rmid = R(1:(length(R)-1)) + 0.5*diff(R); |
474 |
|
|
|
475 |
|
|
ne = 510; |
476 |
|
|
nps = ne * ne * 6; |
477 |
|
|
|
478 |
|
|
% u'T' and v'T' |
479 |
|
|
upbpid = fopen('upbp-1992-2003', 'r', 'ieee-be'); |
480 |
|
|
vpbpid = fopen('vpbp-1992-2003', 'r', 'ieee-be'); |
481 |
|
|
|
482 |
|
|
clow = [ -1.0 ]; % -0.2; |
483 |
|
|
chigh = [ 1.0 ]; % 0.2; |
484 |
|
|
|
485 |
|
|
iz = 1; |
486 |
|
|
iz = 15; |
487 |
|
|
iz = 25; |
488 |
|
|
for iz = [ 1:50 ] |
489 |
|
|
disp(sprintf('iz = %d',iz)); |
490 |
|
|
% iz = 21; |
491 |
|
|
offset = (iz - 1)*nps*4; |
492 |
|
|
fseek(upbpid, offset, 'bof'); |
493 |
|
|
fseek(vpbpid, offset, 'bof'); |
494 |
|
|
upbp = reshape(fread(upbpid, nps, 'real*4'),ne,ne,6); |
495 |
|
|
vpbp = reshape(fread(vpbpid, nps, 'real*4'),ne,ne,6); |
496 |
|
|
|
497 |
|
|
|
498 |
|
|
% Look at u'b' and v'b' on ll coords |
499 |
|
|
% surf(xg(:,:,2), yg(:,:,2), upbp(:,:,2)), view(2), shading interp, colorbar |
500 |
|
|
% surf(xg(:,:,3), yg(:,:,3), upbp(:,:,3)), view(2), shading interp, colorbar |
501 |
|
|
% surf(xg(:,:,4), yg(:,:,4), upbp(:,:,4)), view(2), shading interp, colorbar |
502 |
|
|
llupbp = upbp .* llux + vpbp .* llvx; |
503 |
|
|
llvpbp = upbp .* lluy + vpbp .* llvy; |
504 |
|
|
% surf(xg(:,:,2), yg(:,:,2), lluptp(:,:,2)), view(2), shading interp, colorbar |
505 |
|
|
% surf(xg(:,:,2), yg(:,:,2), llvptp(:,:,2)), view(2), shading |
506 |
|
|
% interp, colorbar |
507 |
|
|
|
508 |
|
|
% save for later use |
509 |
|
|
upbpllid = fopen('upbpll-1992-2003', 'a', 'ieee-be'); |
510 |
|
|
vpbpllid = fopen('vpbpll-1992-2003', 'a', 'ieee-be'); |
511 |
|
|
fwrite(upbpllid, llupbp, 'real*4'); |
512 |
|
|
fwrite(vpbpllid, llvpbp, 'real*4'); |
513 |
|
|
fclose(upbpllid); |
514 |
|
|
fclose(vpbpllid); |
515 |
|
|
|
516 |
|
|
% Look at lat-lon projections of u'T' and v'T' |
517 |
|
|
pllupbp = zeros(6*510,510); |
518 |
|
|
pllvpbp = zeros(6*510,510); |
519 |
|
|
for i = 1:6 |
520 |
|
|
xb = (i-1)*510 + 1; xe = xb + 510 - 1; |
521 |
|
|
yb = 1; ye = 510; |
522 |
|
|
pllupbp(xb:xe,yb:ye) = llupbp(:,:,i); |
523 |
|
|
pllvpbp(xb:xe,yb:ye) = llvpbp(:,:,i); |
524 |
|
|
end |
525 |
|
|
shift=-1; |
526 |
|
|
grph_CS(sq(pllupbp),xcs,ycs,xgs,ygs,[clow],[chigh],shift); |
527 |
|
|
title([ 'u''B'' at ' ... |
528 |
|
|
sprintf('%g',R(iz)) ... |
529 |
|
|
'm depth on the 510x510x6 cubesphere for 1992--2003 ["cube5"]']); |
530 |
|
|
% print('-painters', '-dpng', '-r650', ... |
531 |
|
|
% ['upTp_' sprintf('%02d_%07.1f',iz,R(iz)) 'm_650.png']) |
532 |
|
|
print('-painters', '-dpng', '-r150', ... |
533 |
|
|
['upBp_' sprintf('%02d_%07.1f',iz,R(iz)) 'm_150.png']) |
534 |
|
|
|
535 |
|
|
grph_CS(sq(pllvpbp),xcs,ycs,xgs,ygs,[clow],[chigh],shift); |
536 |
|
|
title([ 'v''B'' at ' ... |
537 |
|
|
sprintf('%g',R(iz)) ... |
538 |
|
|
'm depth on the 510x510x6 cubesphere for 1992--2003 ["cube5"]']); |
539 |
|
|
% print('-painters', '-dpng', '-r650', ... |
540 |
|
|
% ['vpTp_' sprintf('%02d_%07.1f',iz,R(iz)) 'm_650.png']) |
541 |
|
|
print('-painters', '-dpng', '-r150', ... |
542 |
|
|
['vpBp_' sprintf('%02d_%07.1f',iz,R(iz)) 'm_150.png']) |
543 |
|
|
|
544 |
|
|
end |
545 |
|
|
|
546 |
|
|
|
547 |
|
|
%======================================================= |
548 |
|
|
% Calculate : (v'B')/(dB/dz) |
549 |
|
|
|
550 |
|
|
bid = fopen( 'b-ave-1992-2003', 'r', 'ieee-be'); |
551 |
|
|
bm1id = fopen('bm1-ave-1992-2003', 'r', 'ieee-be'); |
552 |
|
|
|
553 |
|
|
iz = 1; |
554 |
|
|
offset = (iz - 1)*nps*4; |
555 |
|
|
fseek(upbpid, offset, 'bof'); |
556 |
|
|
fseek(vpbpid, offset, 'bof'); |
557 |
|
|
upbp = reshape(fread(upbpid, nps, 'real*4'),ne,ne,6); |
558 |
|
|
vpbp = reshape(fread(vpbpid, nps, 'real*4'),ne,ne,6); |
559 |
|
|
llvpbp = upbp .* lluy + vpbp .* llvy; |
560 |
|
|
llvpbpm1 = llvpbp; |
561 |
|
|
ne = 510; tx = 85; ty = 85; nt = 216; |
562 |
|
|
|
563 |
|
|
iz = 2; |
564 |
|
|
iz = 15; |
565 |
|
|
iz = 16; |
566 |
|
|
for iz = 2:50, |
567 |
|
|
izm1 = iz - 1; |
568 |
|
|
disp(sprintf('iz = %d',iz)); |
569 |
|
|
% iz = 21; |
570 |
|
|
offset = (iz - 1)*nps*4; |
571 |
|
|
fseek(upbpid, offset, 'bof'); |
572 |
|
|
fseek(vpbpid, offset, 'bof'); |
573 |
|
|
upbp = reshape(fread(upbpid, nps, 'real*4'),ne,ne,6); |
574 |
|
|
vpbp = reshape(fread(vpbpid, nps, 'real*4'),ne,ne,6); |
575 |
|
|
|
576 |
|
|
% v'B' on ll coords |
577 |
|
|
llvpbp = upbp .* lluy + vpbp .* llvy; |
578 |
|
|
|
579 |
|
|
% B and Bm1 |
580 |
|
|
fseek(bid, offset, 'bof'); |
581 |
|
|
b = reshape(fread(bid, nps, 'real*4'),ne,ne,6); |
582 |
|
|
offm1 = (iz - 2)*nps*4; |
583 |
|
|
fseek(bm1id, offm1, 'bof'); |
584 |
|
|
bm1 =reshape(fread(bm1id, nps, 'real*4'),ne,ne,6); |
585 |
|
|
|
586 |
|
|
% ( v'B' )/( dB/dz ) |
587 |
|
|
dbdz = (b - bm1)/(R(iz) - R(izm1)); |
588 |
|
|
ind0 = find(dbdz==0.0); |
589 |
|
|
dbdz(ind0) = 1.0; |
590 |
|
|
rdbdz = 1.0 / (dbdz); |
591 |
|
|
rdbdz(ind0) = 0.0; |
592 |
|
|
vpbpdbdz = 0.5*(llvpbp + llvpbpm1) .* rdbdz; |
593 |
|
|
|
594 |
|
|
% Write the results |
595 |
|
|
mid = fopen('vpbpdbdz-1992-2003', 'a', 'ieee-be'); |
596 |
|
|
fwrite(mid, vpbpdbdz, 'real*4'); |
597 |
|
|
fclose(mid); |
598 |
|
|
|
599 |
|
|
% Plot results |
600 |
|
|
clow = [ -10 ]; % -20; |
601 |
|
|
chigh = [ 10 ]; % 20; |
602 |
|
|
ll = zeros(6*510,510); |
603 |
|
|
for i = 1:6 |
604 |
|
|
xb = (i-1)*510 + 1; xe = xb + 510 - 1; |
605 |
|
|
yb = 1; ye = 510; |
606 |
|
|
ll(xb:xe,yb:ye) = vpbpdbdz(:,:,i); |
607 |
|
|
end |
608 |
|
|
shift=-1; |
609 |
|
|
grph_CS(sq(ll),xcs,ycs,xgs,ygs,[clow],[chigh],shift); |
610 |
|
|
title([ '(v''B'')/(dB/dz) at ' ... |
611 |
|
|
sprintf('%g',Rmid(iz)) ... |
612 |
|
|
'm depth on the 510x510x6 cubesphere for 1992--2003 ["cube5"]']); |
613 |
|
|
% print('-painters', '-dpng', '-r650', ... |
614 |
|
|
% ['vpTpdTdz_' sprintf('%02d_%07.1f',iz,Rmid(iz)) 'm_650.png']) |
615 |
|
|
print('-painters', '-dpng', '-r150', ... |
616 |
|
|
['vpBpdBdz_' sprintf('%02d_%07.1f',iz,Rmid(iz)) 'm_150.png']) |
617 |
|
|
|
618 |
|
|
|
619 |
|
|
% Stress: calc, write, and plot |
620 |
|
|
stress = 1000 * (2*pi/(24*3600)*sin(pi*yc/180)); |
621 |
|
|
stress = stress .* vpbpdbdz; |
622 |
|
|
sid = fopen('stress-b-1992-2003', 'a', 'ieee-be'); |
623 |
|
|
fwrite(sid, stress, 'real*4'); |
624 |
|
|
fclose(sid); |
625 |
|
|
clow = []; % [ -1 ]; |
626 |
|
|
chigh = []; % [ 1 ]; |
627 |
|
|
ll = zeros(6*510,510); |
628 |
|
|
for i = 1:6 |
629 |
|
|
xb = (i-1)*510 + 1; xe = xb + 510 - 1; |
630 |
|
|
yb = 1; ye = 510; |
631 |
|
|
ll(xb:xe,yb:ye) = stress(:,:,i); |
632 |
|
|
end |
633 |
|
|
shift=-1; |
634 |
|
|
grph_CS(sq(ll),xcs,ycs,xgs,ygs,[clow],[chigh],shift); |
635 |
|
|
title([ 'Stress at ' ... |
636 |
|
|
sprintf('%g',Rmid(iz)) ... |
637 |
|
|
'm depth on the 510x510x6 cubesphere for 1994--2003 ["cube5"]']); |
638 |
|
|
% print('-painters', '-dpng', '-r650', ... |
639 |
|
|
% ['stress_' sprintf('%02d_%07.1f',iz,Rmid(iz)) 'm_650.png']) |
640 |
|
|
print('-painters', '-dpng', '-r150', ... |
641 |
|
|
['stress_' sprintf('%02d_%07.1f',iz,Rmid(iz)) 'm_150.png']) |
642 |
|
|
|
643 |
|
|
|
644 |
|
|
% Next level |
645 |
|
|
llvpbpm1 = llvpbp; |
646 |
|
|
|
647 |
|
|
end |
648 |
|
|
|
649 |
|
|
|
650 |
|
|
%======================================================= |
651 |
|
|
% Zonally average vpbpdbdz and stress |
652 |
|
|
|
653 |
|
|
clear all ; close all |
654 |
|
|
tx = 85; |
655 |
|
|
ty = 85; |
656 |
|
|
nt = 216; |
657 |
|
|
cx = 510; |
658 |
|
|
cy = 510; |
659 |
|
|
nz = 1; |
660 |
|
|
ne = 510; |
661 |
|
|
nps = ne * ne * 6; |
662 |
|
|
|
663 |
|
|
% XCS YCS XGS YGS |
664 |
|
|
fnam = [ 'XC' ; 'YC'; 'XG'; 'YG' ]; |
665 |
|
|
for in = 1:4 |
666 |
|
|
uid = fopen([fnam(in,:) '.data'], 'r', 'ieee-be'); |
667 |
|
|
phi = unmangleJPL1( reshape(fread(uid, nps, 'real*4'), ... |
668 |
|
|
tx*nt,ty), ne, tx ); |
669 |
|
|
fclose(uid); |
670 |
|
|
eval([lower(fnam(in,:)) ' = phi;']); |
671 |
|
|
a = zeros(6*510,510); |
672 |
|
|
for i = 1:6 |
673 |
|
|
xb = (i-1)*510 + 1; xe = xb + 510 - 1; |
674 |
|
|
yb = 1; ye = 510; |
675 |
|
|
a(xb:xe,yb:ye) = phi(:,:,i); |
676 |
|
|
end |
677 |
|
|
eval([lower(fnam(in,:)) 's = a;']) |
678 |
|
|
end |
679 |
|
|
xcs = xcs + -360.0*(xcs > 180.0); |
680 |
|
|
xgs = xgs + -360.0*(xgs > 180.0); |
681 |
|
|
clear phi a |
682 |
|
|
|
683 |
|
|
nz = 1; |
684 |
|
|
nr = 50; |
685 |
|
|
nrm1 = nr - 1; |
686 |
|
|
nlat = 181; nlatm1 = nlat - 1; |
687 |
|
|
|
688 |
|
|
hvals = linspace(-90,90,nlat); |
689 |
|
|
% save indicies for zonal averages |
690 |
|
|
i = 2; |
691 |
|
|
for i = 2:nlat |
692 |
|
|
inds = find(hvals(i-1)<yg & yg<hvals(i)); |
693 |
|
|
comm = sprintf('inds%04d = uint32(inds);',i-1); |
694 |
|
|
eval(comm); |
695 |
|
|
end |
696 |
|
|
|
697 |
|
|
% Zonally average vpbp |
698 |
|
|
acc = zeros(nlatm1, nrm1); |
699 |
|
|
num = zeros(size(acc)); |
700 |
|
|
ne = 510; |
701 |
|
|
nps = ne * ne * 6; |
702 |
|
|
zid = fopen('vpbpll-1992-2003', 'r', 'ieee-be'); |
703 |
|
|
iz = 1; |
704 |
|
|
for iz = 1:50, |
705 |
|
|
disp(sprintf('iz = %d',iz)); |
706 |
|
|
offset = (iz - 1)*nps*4; |
707 |
|
|
fseek(zid, offset, 'bof'); |
708 |
|
|
vpbp = reshape(fread(zid, nps, 'real*4'),ne,ne,6); |
709 |
|
|
|
710 |
|
|
for jj = 1:nlatm1 |
711 |
|
|
eval( sprintf('clear inds; inds = inds%04d;',jj) ); |
712 |
|
|
tmp = vpbp(inds); |
713 |
|
|
nzinds = find(tmp ~= 0.0); |
714 |
|
|
num(jj,iz) = length(nzinds); |
715 |
|
|
acc(jj,iz) = sum(tmp(nzinds)); |
716 |
|
|
end |
717 |
|
|
end |
718 |
|
|
fclose(zid); |
719 |
|
|
zvpbp = acc ./ num; |
720 |
|
|
% save zvpbp zvpbp |
721 |
|
|
|
722 |
|
|
% zonally average vpbpdbdz |
723 |
|
|
acc = zeros(nlatm1, nrm1); |
724 |
|
|
num = zeros(size(acc)); |
725 |
|
|
ne = 510; |
726 |
|
|
nps = ne * ne * 6; |
727 |
|
|
zid = fopen('vpbpdbdz-1992-2003', 'r', 'ieee-be'); |
728 |
|
|
iz = 1; |
729 |
|
|
for iz = 1:49, |
730 |
|
|
disp(sprintf('iz = %d',iz)); |
731 |
|
|
offset = (iz - 1)*nps*4; |
732 |
|
|
fseek(zid, offset, 'bof'); |
733 |
|
|
vpbpdbdz = reshape(fread(zid, nps, 'real*4'),ne,ne,6); |
734 |
|
|
|
735 |
|
|
for jj = 1:nlatm1 |
736 |
|
|
eval( sprintf('clear inds; inds = inds%04d;',jj) ); |
737 |
|
|
tmp = vpbpdbdz(inds); |
738 |
|
|
nzinds = find(tmp ~= 0.0); |
739 |
|
|
num(jj,iz) = length(nzinds); |
740 |
|
|
acc(jj,iz) = sum(tmp(nzinds)); |
741 |
|
|
end |
742 |
|
|
end |
743 |
|
|
fclose(zid); |
744 |
|
|
zvpbpdbdz = acc ./ num; |
745 |
|
|
% save zvpbpdbdz zvpbpdbdz |
746 |
|
|
|
747 |
|
|
% zonally average stress |
748 |
|
|
acc = zeros(nlatm1, nrm1); |
749 |
|
|
num = zeros(size(acc)); |
750 |
|
|
ne = 510; |
751 |
|
|
nps = ne * ne * 6; |
752 |
|
|
zid = fopen('stress-b-1992-2003', 'r', 'ieee-be'); |
753 |
|
|
iz = 1; |
754 |
|
|
for iz = 1:49, |
755 |
|
|
disp(sprintf('iz = %d',iz)); |
756 |
|
|
offset = (iz - 1)*nps*4; |
757 |
|
|
fseek(zid, offset, 'bof'); |
758 |
|
|
stress = reshape(fread(zid, nps, 'real*4'),ne,ne,6); |
759 |
|
|
jj = 22; |
760 |
|
|
for jj = 1:nlatm1 |
761 |
|
|
eval( sprintf('clear inds; inds = inds%04d;',jj) ); |
762 |
|
|
tmp = stress(inds); |
763 |
|
|
nzinds = find(tmp ~= 0.0); |
764 |
|
|
num(jj,iz) = length(nzinds); |
765 |
|
|
acc(jj,iz) = sum(tmp(nzinds)); |
766 |
|
|
end |
767 |
|
|
end |
768 |
|
|
fclose(zid); |
769 |
|
|
stress = acc ./ num; |
770 |
|
|
% save stress stress |
771 |
|
|
|
772 |
|
|
%------- UNUSED ----------------------- |
773 |
|
|
% zonally average u |
774 |
|
|
acc = zeros(nlatm1, 50); |
775 |
|
|
num = zeros(size(acc)); |
776 |
|
|
ne = 510; |
777 |
|
|
nps = ne * ne * 6; |
778 |
|
|
zid = fopen('Ull_ave_1994--2003', 'r', 'ieee-be'); |
779 |
|
|
iz = 1; |
780 |
|
|
for iz = 1:50, |
781 |
|
|
disp(sprintf('iz = %d',iz)); |
782 |
|
|
offset = (iz - 1)*nps*4; |
783 |
|
|
fseek(zid, offset, 'bof'); |
784 |
|
|
U = reshape(fread(zid, nps, 'real*4'),ne,ne,6); |
785 |
|
|
jj = 22; |
786 |
|
|
for jj = 1:nlatm1 |
787 |
|
|
eval( sprintf('clear inds; inds = inds%04d;',jj) ); |
788 |
|
|
tmp = U(inds); |
789 |
|
|
nzinds = find(tmp ~= 0.0); |
790 |
|
|
num(jj,iz) = length(nzinds); |
791 |
|
|
acc(jj,iz) = sum(tmp(nzinds)); |
792 |
|
|
end |
793 |
|
|
end |
794 |
|
|
fclose(zid); |
795 |
|
|
zonalu = acc ./ num; |
796 |
|
|
% save zonalu zonalu |
797 |
|
|
%------- UNUSED ----------------------- |
798 |
|
|
|
799 |
|
|
% zonally average B |
800 |
|
|
acc = zeros(nlatm1, 50); |
801 |
|
|
num = zeros(size(acc)); |
802 |
|
|
ne = 510; |
803 |
|
|
nps = ne * ne * 6; |
804 |
|
|
zid = fopen('b-ave-1992-2003', 'r', 'ieee-be'); |
805 |
|
|
iz = 1; |
806 |
|
|
for iz = 1:50, |
807 |
|
|
disp(sprintf('iz = %d',iz)); |
808 |
|
|
offset = (iz - 1)*nps*4; |
809 |
|
|
fseek(zid, offset, 'bof'); |
810 |
|
|
B = reshape(fread(zid, nps, 'real*4'),ne,ne,6); |
811 |
|
|
jj = 22; |
812 |
|
|
for jj = 1:nlatm1 |
813 |
|
|
eval( sprintf('clear inds; inds = inds%04d;',jj) ); |
814 |
|
|
tmp = B(inds); |
815 |
|
|
nzinds = find(tmp ~= 0.0); |
816 |
|
|
num(jj,iz) = length(nzinds); |
817 |
|
|
acc(jj,iz) = sum(tmp(nzinds)); |
818 |
|
|
end |
819 |
|
|
end |
820 |
|
|
fclose(zid); |
821 |
|
|
zonalB = acc ./ num; |
822 |
|
|
% save zonalB zonalB |
823 |
|
|
|
824 |
|
|
%------- UNUSED ----------------------- |
825 |
|
|
% Vertical gradient of zonally averaged B (dB/dz) |
826 |
|
|
load zonalT |
827 |
|
|
load allR |
828 |
|
|
nz = size(zonalT,1); |
829 |
|
|
dzaTdz = zeros(nz,size(zonalT,2)-1); |
830 |
|
|
for iz = 2:50 |
831 |
|
|
dzaTdz(:,iz-1) = (zonalT(:,iz) - zonalT(:,iz-1)) ./ (R(iz) - R(iz-1)); |
832 |
|
|
end |
833 |
|
|
% save dzaTdz dzaTdz |
834 |
|
|
%------- UNUSED ----------------------- |
835 |
|
|
|
836 |
|
|
|
837 |
|
|
delR = [ |
838 |
|
|
10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.01, ... |
839 |
|
|
10.03, 10.11, 10.32, 10.80, 11.76, 13.42, 16.04 , 19.82, 24.85, ... |
840 |
|
|
31.10, 38.42, 46.50, 55.00, 63.50, 71.58, 78.90, 85.15, 90.18, ... |
841 |
|
|
93.96, 96.58, 98.25, 99.25,100.01,101.33,104.56,111.33,122.83, ... |
842 |
|
|
139.09,158.94,180.83,203.55,226.50,249.50,272.50,295.50,318.50, ... |
843 |
|
|
341.50,364.50,387.50,410.50,433.50,456.50 ]; |
844 |
|
|
R = cumsum(delR) - 0.5*delR; |
845 |
|
|
Rmid = R(1:(length(R)-1)) + 0.5*diff(R); |
846 |
|
|
hmid = [ -89.5:1:89.5 ]; |
847 |
|
|
% save allR delR R Rmid hmid |
848 |
|
|
|
849 |
|
|
%------- UNUSED ----------------------- |
850 |
|
|
surf(hmid,-Rmid,num'), view(2), shading interp, colorbar |
851 |
|
|
caxis([ -1 1 ]) |
852 |
|
|
caxis('manual') |
853 |
|
|
surf(hmid,-Rmid,mu'), view(2), shading interp, colorbar |
854 |
|
|
title('Zonally Averaged Stress for 1994--2003 [cube5]') |
855 |
|
|
xlabel('Latitude [deg]') |
856 |
|
|
zlabel('Depth [m]') |
857 |
|
|
axis([ -90 90 -5500 200 ]) |
858 |
|
|
|
859 |
|
|
% print -dps -painters t_001.ps |
860 |
|
|
print('-painters', '-dpng', '-r150', 'za_str_94--03_r150.png') |
861 |
|
|
print('-painters', '-dpng', '-r650', 'za_str_94--03_r650.png') |
862 |
|
|
|
863 |
|
|
% plot and print bar(U) |
864 |
|
|
load zonalu |
865 |
|
|
surf(hmid,-R,zonalu'), view(2), shading interp, colorbar |
866 |
|
|
contour(hmid,-R,mu'), colorbar |
867 |
|
|
ac = 25; |
868 |
|
|
ac = [-0.3:.005:.3]; |
869 |
|
|
[c,h] = contourf(hmid,-R,mu',ac); colorbar |
870 |
|
|
hold on, contour(hmid,-R,mu',ac), hold off |
871 |
|
|
title('Zonally Averaged U for 1994--2003 [cube5]') |
872 |
|
|
xlabel('Latitude [deg]') |
873 |
|
|
zlabel('Depth [m]') |
874 |
|
|
axis([ -90 90 -6000 200 ]) |
875 |
|
|
print('-painters', '-dpng', '-r150', 'Ull_94--03_r150.png') |
876 |
|
|
print('-painters', '-dpng', '-r650', 'Ull_94--03_r650.png') |
877 |
|
|
%------- UNUSED ----------------------- |
878 |
|
|
|
879 |
|
|
|
880 |
|
|
%======================================================= |
881 |
|
|
% Put it all in NetCDF |
882 |
|
|
|
883 |
|
|
clear all ; close all |
884 |
|
|
load allR |
885 |
|
|
% load zonalu |
886 |
|
|
load zvpbpdbdz |
887 |
|
|
load stress |
888 |
|
|
load zonalB |
889 |
|
|
% load dzaTdz |
890 |
|
|
load zvpbp |
891 |
|
|
|
892 |
|
|
% id0 = 'U'; |
893 |
|
|
id1 = 'zvpbpdbdz'; |
894 |
|
|
id2 = 'stress'; |
895 |
|
|
id3 = 'B'; |
896 |
|
|
% id4 = 'dzaTdz'; |
897 |
|
|
id5 = 'zvpbp'; |
898 |
|
|
% units0 = 'm/s'; |
899 |
|
|
units1 = 'm^2/s'; |
900 |
|
|
units2 = 'N/m^2'; |
901 |
|
|
units3 = 'kg/m^3'; |
902 |
|
|
% units4 = 'deg C/m'; |
903 |
|
|
units5 = 'm*kg/m^3'; |
904 |
|
|
|
905 |
|
|
!rm -f Zonal_ave_92-03.nc |
906 |
|
|
nc = netcdf('Zonal_ave_92-03.nc', 'clobber'); |
907 |
|
|
nc.reference = 'Zonal averages from Dimitris "cube 5" integrations'; |
908 |
|
|
nc.author = 'Ed Hill <eh3@mit.edu>'; |
909 |
|
|
nc.date = 'Aug 11, 2004'; |
910 |
|
|
|
911 |
|
|
nc('X') = length(hmid); |
912 |
|
|
nc('Y') = length(R); |
913 |
|
|
nc('Ym1') = length(R) - 1; |
914 |
|
|
nc{'X'} = 'X'; |
915 |
|
|
nc{'Y'} = 'Y'; |
916 |
|
|
nc{'Ym1'} = 'Ym1'; |
917 |
|
|
% nc{ id0 } = { 'Y', 'X' }; |
918 |
|
|
nc{ id1 } = { 'Ym1', 'X' }; |
919 |
|
|
nc{ id2 } = { 'Ym1', 'X' }; |
920 |
|
|
nc{ id3 } = { 'Y', 'X' }; |
921 |
|
|
% nc{ id4 } = { 'Ym1', 'X' }; |
922 |
|
|
nc{ id5 } = { 'Y', 'X' }; |
923 |
|
|
nc{'X'}.uniquename = 'X'; |
924 |
|
|
nc{'X'}.long_name = 'latitude'; |
925 |
|
|
nc{'X'}.gridtype = ncint(0); |
926 |
|
|
nc{'X'}.units = 'degree_north'; |
927 |
|
|
nc{'Y'}.uniquename = 'Y'; |
928 |
|
|
nc{'Y'}.long_name = 'depth'; |
929 |
|
|
nc{'Y'}.gridtype = ncint(1); |
930 |
|
|
nc{'Y'}.units = 'm'; |
931 |
|
|
nc{'Ym1'}.uniquename = 'Ym1'; |
932 |
|
|
nc{'Ym1'}.long_name = 'depth'; |
933 |
|
|
nc{'Ym1'}.gridtype = ncint(1); |
934 |
|
|
nc{'Ym1'}.units = 'm'; |
935 |
|
|
% nc{ id0 }.units = units0; |
936 |
|
|
% nc{ id0 }.long_name = id0; |
937 |
|
|
% nc{ id0 }.missing_value = ncdouble(NaN); |
938 |
|
|
% nc{ id0 }.FillValue_ = ncdouble(0.); |
939 |
|
|
nc{ id1 }.units = units1; |
940 |
|
|
nc{ id1 }.long_name = id1; |
941 |
|
|
nc{ id1 }.missing_value = ncdouble(NaN); |
942 |
|
|
nc{ id1 }.FillValue_ = ncdouble(0.); |
943 |
|
|
nc{ id2 }.units = units2; |
944 |
|
|
nc{ id2 }.long_name = id2; |
945 |
|
|
nc{ id2 }.missing_value = ncdouble(NaN); |
946 |
|
|
nc{ id2 }.FillValue_ = ncdouble(0.); |
947 |
|
|
nc{ id3 }.units = units3; |
948 |
|
|
nc{ id3 }.long_name = id3; |
949 |
|
|
nc{ id3 }.missing_value = ncdouble(NaN); |
950 |
|
|
nc{ id3 }.FillValue_ = ncdouble(0.); |
951 |
|
|
% nc{ id4 }.units = units4; |
952 |
|
|
% nc{ id4 }.long_name = id4; |
953 |
|
|
% nc{ id4 }.missing_value = ncdouble(NaN); |
954 |
|
|
% nc{ id4 }.FillValue_ = ncdouble(0.); |
955 |
|
|
nc{ id5 }.units = units5; |
956 |
|
|
nc{ id5 }.long_name = id5; |
957 |
|
|
nc{ id5 }.missing_value = ncdouble(NaN); |
958 |
|
|
nc{ id5 }.FillValue_ = ncdouble(0.); |
959 |
|
|
nc{'X'}(:) = hmid; |
960 |
|
|
nc{'Y'}(:) = -R; |
961 |
|
|
nc{'Ym1'}(:) = -Rmid; |
962 |
|
|
% nc{ id0 }(:) = permute(zonalu,[ 2 1 ]); |
963 |
|
|
nc{ id1 }(:) = permute(zvpbpdbdz,[ 2 1 ]); |
964 |
|
|
nc{ id2 }(:) = permute(stress,[ 2 1 ]); |
965 |
|
|
nc{ id3 }(:) = permute(zonalB,[ 2 1 ]); |
966 |
|
|
% nc{ id4 }(:) = permute(dzaTdz,[ 2 1 ]); |
967 |
|
|
nc{ id5 }(:) = permute(zvpbp,[ 2 1 ]); |
968 |
|
|
nc = close(nc); |
969 |
|
|
|
970 |
|
|
% !scp Zonal_ave_92-03.nc ingrid.mit.edu:INGRID_PEOPLE/EH3/eddy_flux/cube_5/ |