1 |
edhill |
1.1 |
%======================================================= |
2 |
|
|
% |
3 |
edhill |
1.4 |
% $Id: plot_c22.m,v 1.3 2005/03/29 21:47:29 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_22" or "c22" integration. |
12 |
|
|
|
13 |
|
|
% ssh eddy |
14 |
edhill |
1.4 |
% cd /r/r0/edhill/eddy_stats/c22 |
15 |
edhill |
1.1 |
|
16 |
|
|
% matlab -nojvm |
17 |
|
|
% matlab -nojvm -nodisplay |
18 |
|
|
|
19 |
|
|
clear all |
20 |
|
|
close all |
21 |
|
|
|
22 |
|
|
|
23 |
|
|
%================================================================== |
24 |
|
|
% Read the tile00?.mitgrid files |
25 |
|
|
gvars = { 'XC','YC','DXF','DYF','RA','XG','YG','DXV', ... |
26 |
|
|
'DYU','RAZ','DXC','DYC','RAW','RAS','DXG','DYG' }; |
27 |
|
|
|
28 |
|
|
ne = 510; |
29 |
|
|
nep1 = ne + 1; |
30 |
|
|
iface = 1; |
31 |
|
|
for iface = 1:6 |
32 |
|
|
fname = sprintf('grid/tile%03d.mitgrid', iface); |
33 |
|
|
gid = fopen(fname, 'r', 'ieee-be'); |
34 |
|
|
tmp = reshape(fread(gid,inf,'real*8',0,'ieee-be'),[nep1,nep1,16]); |
35 |
|
|
fclose(gid); |
36 |
|
|
% surf(tmp(:,:,1)), view(2), shading interp |
37 |
|
|
% for jj = 1:length(gvars) |
38 |
|
|
for jj = 1:7 |
39 |
|
|
comm = sprintf('%s(:,:,%d) = tmp(:,:,%d);', ... |
40 |
|
|
[gvars{jj}], iface, jj); |
41 |
|
|
eval(comm); |
42 |
|
|
end |
43 |
|
|
end |
44 |
|
|
% surf(XC(:,:,1)), view(2), shading interp |
45 |
|
|
% subplot(2,1,1), a = [1:10]; surf(XC(a,a,1)), view(2) |
46 |
|
|
% subplot(2,1,2), a = [(nep1-10):nep1]; surf(XC(a,a,1)), view(2) |
47 |
|
|
% surf(YC(:,:,1)), view(2), shading interp |
48 |
|
|
% surf(XG(:,:,1)), view(2), shading interp |
49 |
|
|
% surf(YG(:,:,1)), view(2), shading interp |
50 |
|
|
is = [1:ne]; |
51 |
|
|
vs = { 'XC','YC','DXF','DYF','RA' }; |
52 |
|
|
for i = 1:length(vs) |
53 |
|
|
eval(sprintf('%s = %s(is,is,:);',vs{i},vs{i})); |
54 |
|
|
end |
55 |
|
|
|
56 |
|
|
delR = [ ... |
57 |
|
|
10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.01, ... |
58 |
|
|
10.03, 10.11, 10.32, 10.80, 11.76, 13.42, 16.04 , 19.82, 24.85, ... |
59 |
|
|
31.10, 38.42, 46.50, 55.00, 63.50, 71.58, 78.90, 85.15, 90.18, ... |
60 |
|
|
93.96, 96.58, 98.25, 99.25,100.01,101.33,104.56,111.33,122.83, ... |
61 |
|
|
139.09,158.94,180.83,203.55,226.50,249.50,272.50,295.50,318.50, ... |
62 |
|
|
341.50,364.50,387.50,410.50,433.50,456.50 ]; |
63 |
|
|
R = cumsum(delR) - 0.5*delR; |
64 |
|
|
|
65 |
|
|
%================================================================== |
66 |
|
|
% Project fields to lower-res 1-degree Lat-Lon and write |
67 |
|
|
% as NetCDF for viewing with Ingrid |
68 |
|
|
% |
69 |
|
|
fields_3d = { ... |
70 |
|
|
'DRHODR', 'RHOANOSQ', 'RHOAnoma', 'SALT', 'SALTSQ', ... |
71 |
|
|
'THETA', 'THETASQ', 'URHOMASS', ... |
72 |
|
|
'USLTMASS', 'UTHMASS', 'UVEL', 'UVELMASS', 'UVELSQ', ... |
73 |
|
|
'UV_VEL_Z', 'VRHOMASS', 'VSLTMASS', 'VTHMASS', ... |
74 |
|
|
'VVEL', 'VVELMASS', 'VVELSQ', 'WRHOMASS', 'WSLTMASS', ... |
75 |
|
|
'WTHMASS', 'WU_VEL', 'WVELMASS', 'WVELSQ', 'WV_VEL' }; |
76 |
|
|
fields_2d = { ... |
77 |
|
|
'ETAN', 'ETANSQ', 'EmPmRtave', 'PHIBOT', 'SFLUX', 'SRELAX', ... |
78 |
|
|
'TAUX', 'TAUY', 'TFLUX', ... |
79 |
|
|
'TICE', 'TRELAX', 'UICEtave', 'VICEtave' }; |
80 |
|
|
|
81 |
|
|
ne = 510; |
82 |
|
|
nf = 6; |
83 |
|
|
nz = 50; |
84 |
|
|
nslab = ne*ne*nf; |
85 |
|
|
adir = 'ave_1992-2004'; |
86 |
|
|
lat = [-90:90]; |
87 |
|
|
lon = [0:360]; |
88 |
|
|
ir = [ 1 2 3 5 10 15 20 25 30 35 40 50 ]; |
89 |
|
|
|
90 |
|
|
% ! rm -f cube_22_at1deg.nc |
91 |
|
|
nc = netcdf(['cube_22_at1deg.nc'], 'clobber'); |
92 |
|
|
nc.reference = [ 'The cube_22 averages from Dimitris Menemenlis' ... |
93 |
|
|
' regridded to 1-deg Lat-Lon' ]; |
94 |
|
|
nc.author = 'Ed Hill <eh3@mit.edu>'; |
95 |
|
|
nc.date = 'Mar 27, 2005'; |
96 |
|
|
nc('X') = length(lon); |
97 |
|
|
nc('Y') = length(lat); |
98 |
|
|
nc('Z') = length(ir); |
99 |
|
|
nc{'X'} = 'X'; |
100 |
|
|
nc{'Y'} = 'Y'; |
101 |
|
|
nc{'Z'} = 'Z'; |
102 |
|
|
nc{'X'}.uniquename = 'X'; |
103 |
|
|
nc{'X'}.long_name = 'longitude'; |
104 |
|
|
nc{'X'}.gridtype = ncint(1); |
105 |
|
|
nc{'X'}.units = 'degree_east'; |
106 |
|
|
nc{'Y'}.uniquename = 'Y'; |
107 |
|
|
nc{'Y'}.long_name = 'latitude'; |
108 |
|
|
nc{'Y'}.gridtype = ncint(0); |
109 |
|
|
nc{'Y'}.units = 'degree_north'; |
110 |
|
|
nc{'Z'}.uniquename = 'Z'; |
111 |
|
|
nc{'Z'}.long_name = 'depth'; |
112 |
|
|
nc{'Z'}.gridtype = ncint(0); |
113 |
|
|
nc{'Z'}.units = 'm'; |
114 |
|
|
nc{'X'}(:) = lon; |
115 |
|
|
nc{'Y'}(:) = lat; |
116 |
|
|
nc{'Z'}(:) = R(ir); |
117 |
|
|
|
118 |
|
|
ifld = 5; |
119 |
|
|
fields = union(fields_2d, fields_3d); |
120 |
|
|
for ifld = 1:length(fields) |
121 |
|
|
|
122 |
|
|
id = fields{ifld}; |
123 |
|
|
if ismember(fields{ifld},fields_3d) |
124 |
|
|
ir = [ 1 2 3 5 10 15 20 25 30 35 40 50 ]; |
125 |
|
|
nc{ id } = { 'Z' 'Y' 'X' }; |
126 |
|
|
else |
127 |
|
|
ir = [ 1 ]; |
128 |
|
|
nc{ id } = { 'Y' 'X' }; |
129 |
|
|
end |
130 |
|
|
nc{ id }.missing_value = ncdouble(NaN); |
131 |
|
|
nc{ id }.FillValue_ = ncdouble(0.0); |
132 |
|
|
|
133 |
|
|
disp([ ' ' fields{ifld} ' :' ]); |
134 |
|
|
|
135 |
|
|
fname = sprintf('%s/%s.ave',adir,fields{ifld}); |
136 |
|
|
fid = fopen(fname,'r','ieee-be'); |
137 |
|
|
|
138 |
|
|
ii = 1; |
139 |
|
|
for ii = 1:length(ir) |
140 |
|
|
|
141 |
|
|
iz = ir(ii); |
142 |
|
|
disp(sprintf(' iz = %g',iz)); |
143 |
|
|
|
144 |
|
|
fseek(fid,nslab*4*(iz-1),'bof'); |
145 |
|
|
tmp = fread(fid,nslab,'real*4',0,'ieee-be'); |
146 |
|
|
tr = permute(reshape(tmp,[ 510 6 510 ]),[1 3 2]); |
147 |
|
|
% surf(tr(:,:,1)), view(2), shading interp |
148 |
|
|
xc360 = XC + 180; |
149 |
|
|
trn = tr; |
150 |
|
|
trn(find(tr == 0.0)) = NaN; |
151 |
|
|
clear tmp tr |
152 |
|
|
% v = sdac_regrid(xc360,YC,trn,lonm,latm); |
153 |
|
|
v = ll_regrid(xc360,YC,trn,lon,lat); |
154 |
|
|
% surf(lon,lat,v'), caxis([25 40]), view(2), shading interp, colorbar |
155 |
|
|
|
156 |
|
|
if length(ir) == 1 |
157 |
|
|
nc{ id }(:,:) = permute(v,[2 1]); |
158 |
|
|
else |
159 |
|
|
nc{ id }(ii,:,:) = permute(v,[2 1]); |
160 |
|
|
end |
161 |
|
|
|
162 |
|
|
end |
163 |
|
|
|
164 |
|
|
fclose(fid); |
165 |
|
|
|
166 |
|
|
end |
167 |
|
|
|
168 |
|
|
nc = close(nc); |
169 |
|
|
|
170 |
|
|
|
171 |
|
|
% ! ncdump cube_22_at1deg.nc | more |
172 |
|
|
% ! scp cube_22_at1deg.nc channel.mit.edu:/home/edhill/INGRID_PEOPLE/EH3/eddy_flux/cube_22/ |
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
%======================================================= |
178 |
|
|
% Compute [uvw]'[tsb]' |
179 |
|
|
|
180 |
|
|
clear all |
181 |
|
|
close all |
182 |
|
|
|
183 |
|
|
gvars = { 'XC','YC','DXF','DYF','RA','XG','YG','DXV', ... |
184 |
|
|
'DYU','RAZ','DXC','DYC','RAW','RAS','DXG','DYG' }; |
185 |
|
|
ne = 510; |
186 |
|
|
nep1 = ne + 1; |
187 |
|
|
iface = 1; |
188 |
|
|
for iface = 1:6 |
189 |
|
|
fname = sprintf('grid/tile%03d.mitgrid', iface); |
190 |
|
|
gid = fopen(fname, 'r', 'ieee-be'); |
191 |
|
|
tmp = reshape(fread(gid,inf,'real*8',0,'ieee-be'),[nep1,nep1,16]); |
192 |
|
|
fclose(gid); |
193 |
|
|
% surf(tmp(:,:,1)), view(2), shading interp |
194 |
|
|
% for jj = 1:length(gvars) |
195 |
|
|
for jj = 1:7 |
196 |
|
|
comm = sprintf('%s(:,:,%d) = tmp(:,:,%d);', ... |
197 |
|
|
[gvars{jj}], iface, jj); |
198 |
|
|
eval(comm); |
199 |
|
|
end |
200 |
|
|
end |
201 |
|
|
% surf(XC(:,:,1)), view(2), shading interp |
202 |
|
|
% subplot(2,1,1), a = [1:10]; surf(XC(a,a,1)), view(2) |
203 |
|
|
% subplot(2,1,2), a = [(nep1-10):nep1]; surf(XC(a,a,1)), view(2) |
204 |
|
|
% surf(YC(:,:,1)), view(2), shading interp |
205 |
|
|
% surf(XG(:,:,1)), view(2), shading interp |
206 |
|
|
% surf(YG(:,:,1)), view(2), shading interp |
207 |
|
|
is = [1:ne]; |
208 |
|
|
vs = { 'XC','YC','DXF','DYF','RA' }; |
209 |
|
|
for i = 1:length(vs) |
210 |
|
|
eval(sprintf('%s = %s(is,is,:);',vs{i},vs{i})); |
211 |
|
|
end |
212 |
|
|
|
213 |
|
|
delR = [ ... |
214 |
|
|
10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.01, ... |
215 |
|
|
10.03, 10.11, 10.32, 10.80, 11.76, 13.42, 16.04 , 19.82, 24.85, ... |
216 |
|
|
31.10, 38.42, 46.50, 55.00, 63.50, 71.58, 78.90, 85.15, 90.18, ... |
217 |
|
|
93.96, 96.58, 98.25, 99.25,100.01,101.33,104.56,111.33,122.83, ... |
218 |
|
|
139.09,158.94,180.83,203.55,226.50,249.50,272.50,295.50,318.50, ... |
219 |
|
|
341.50,364.50,387.50,410.50,433.50,456.50 ]; |
220 |
|
|
R = cumsum(delR) - 0.5*delR; |
221 |
|
|
|
222 |
|
|
n1 = ne - 1; |
223 |
|
|
dux = zeros(size(XC)); |
224 |
|
|
duy = zeros(size(XC)); |
225 |
|
|
dvx = zeros(size(XC)); |
226 |
|
|
dvy = zeros(size(XC)); |
227 |
|
|
dux(:,:,:) = diff(XG(:,1:ne,:),1,1); |
228 |
|
|
dvx(:,:,:) = diff(XG(1:ne,:,:),1,2); |
229 |
|
|
duy(:,:,:) = diff(YG(:,1:ne,:),1,1); |
230 |
|
|
dvy(:,:,:) = diff(YG(1:ne,:,:),1,2); |
231 |
|
|
dux = dux + 360*double(dux < 180); |
232 |
|
|
dux = dux - 360*double(dux > 180); % [ min(min(dux)) max(max(dux)) ] |
233 |
|
|
duy = duy + 360*double(duy < 180); |
234 |
|
|
duy = duy - 360*double(duy > 180); % [ min(min(duy)) max(max(duy)) ] |
235 |
|
|
dvx = dvx + 360*double(dvx < 180); |
236 |
|
|
dvx = dvx - 360*double(dvx > 180); % [ min(min(dvx)) max(max(dvx)) ] |
237 |
|
|
dvy = dvy + 360*double(dvy < 180); |
238 |
|
|
dvy = dvy - 360*double(dvy > 180); % [ min(min(dvy)) max(max(dvy)) ] |
239 |
|
|
llux = dux ./ sqrt(dux.^2 + duy.^2); |
240 |
|
|
lluy = duy ./ sqrt(dux.^2 + duy.^2); |
241 |
|
|
llvx = dvx ./ sqrt(dvx.^2 + dvy.^2); |
242 |
|
|
llvy = dvy ./ sqrt(dvx.^2 + dvy.^2); |
243 |
|
|
|
244 |
edhill |
1.2 |
lpath = 'ave_1992-2004/'; |
245 |
edhill |
1.1 |
u__id = fopen( [lpath 'UVEL.ave'], 'r', 'ieee-be'); % 1 |
246 |
|
|
v__id = fopen( [lpath 'VVEL.ave'], 'r', 'ieee-be'); % 2 |
247 |
|
|
%w__id = fopen( [lpath 'WVEL.ave'], 'r', 'ieee-be'); |
248 |
|
|
u2_id = fopen( [lpath 'UVELSQ.ave'], 'r', 'ieee-be'); % 3 |
249 |
|
|
v2_id = fopen( [lpath 'VVELSQ.ave'], 'r', 'ieee-be'); % 4 |
250 |
|
|
w2_id = fopen( [lpath 'WVELSQ.ave'], 'r', 'ieee-be'); % 5 |
251 |
|
|
um_id = fopen( [lpath 'UVELMASS.ave'], 'r', 'ieee-be'); % 6 |
252 |
|
|
vm_id = fopen( [lpath 'VVELMASS.ave'], 'r', 'ieee-be'); % 7 |
253 |
|
|
wm_id = fopen( [lpath 'WVELMASS.ave'], 'r', 'ieee-be'); % 8 |
254 |
|
|
t__id = fopen( [lpath 'THETA.ave'], 'r', 'ieee-be'); % 9 |
255 |
|
|
t2_id = fopen( [lpath 'THETASQ.ave'], 'r', 'ieee-be'); % 10 |
256 |
|
|
s__id = fopen( [lpath 'SALT.ave'], 'r', 'ieee-be'); % 11 |
257 |
|
|
s2_id = fopen( [lpath 'SALTSQ.ave'], 'r', 'ieee-be'); % 12 |
258 |
|
|
b__id = fopen( [lpath 'RHOAnoma.ave'], 'r', 'ieee-be'); % 13 |
259 |
|
|
b2_id = fopen( [lpath 'RHOANOSQ.ave'], 'r', 'ieee-be'); % 14 |
260 |
|
|
ut_id = fopen( [lpath 'UTHMASS.ave'], 'r', 'ieee-be'); % 15 |
261 |
|
|
vt_id = fopen( [lpath 'VTHMASS.ave'], 'r', 'ieee-be'); % 16 |
262 |
|
|
wt_id = fopen( [lpath 'WTHMASS.ave'], 'r', 'ieee-be'); % 17 |
263 |
|
|
us_id = fopen( [lpath 'USLTMASS.ave'], 'r', 'ieee-be'); % 18 |
264 |
|
|
vs_id = fopen( [lpath 'VSLTMASS.ave'], 'r', 'ieee-be'); % 19 |
265 |
|
|
ws_id = fopen( [lpath 'WSLTMASS.ave'], 'r', 'ieee-be'); % 20 |
266 |
|
|
ub_id = fopen( [lpath 'URHOMASS.ave'], 'r', 'ieee-be'); % 21 |
267 |
|
|
vb_id = fopen( [lpath 'VRHOMASS.ave'], 'r', 'ieee-be'); % 22 |
268 |
|
|
wb_id = fopen( [lpath 'WRHOMASS.ave'], 'r', 'ieee-be'); % 23 |
269 |
|
|
dr_id = fopen( [lpath 'DRHODR.ave'], 'r', 'ieee-be'); % 24 |
270 |
|
|
iids = [ u__id v__id u2_id v2_id w2_id um_id vm_id wm_id ... |
271 |
|
|
t__id t2_id s__id s2_id b__id b2_id ... |
272 |
|
|
ut_id vt_id wt_id us_id vs_id ws_id ... |
273 |
|
|
ub_id vb_id wb_id dr_id ]; |
274 |
|
|
|
275 |
|
|
% ! rm -rf primes_92_04 ; mkdir primes_92_04 |
276 |
|
|
opath = 'primes_92_04/'; |
277 |
|
|
up2___id = fopen([opath 'up2'], 'wb', 'ieee-be'); |
278 |
|
|
vp2___id = fopen([opath 'vp2'], 'wb', 'ieee-be'); |
279 |
|
|
wp2___id = fopen([opath 'wp2'], 'wb', 'ieee-be'); |
280 |
|
|
tp2___id = fopen([opath 'tp2'], 'wb', 'ieee-be'); |
281 |
|
|
sp2___id = fopen([opath 'sp2'], 'wb', 'ieee-be'); |
282 |
|
|
bp2___id = fopen([opath 'bp2'], 'wb', 'ieee-be'); |
283 |
|
|
uptp__id = fopen([opath 'uptp'], 'wb', 'ieee-be'); |
284 |
|
|
vptp__id = fopen([opath 'vptp'], 'wb', 'ieee-be'); |
285 |
|
|
wptp__id = fopen([opath 'wptp'], 'wb', 'ieee-be'); |
286 |
|
|
upsp__id = fopen([opath 'upsp'], 'wb', 'ieee-be'); |
287 |
|
|
vpsp__id = fopen([opath 'vpsp'], 'wb', 'ieee-be'); |
288 |
|
|
wpsp__id = fopen([opath 'wpsp'], 'wb', 'ieee-be'); |
289 |
|
|
upbp__id = fopen([opath 'upbp'], 'wb', 'ieee-be'); |
290 |
|
|
vpbp__id = fopen([opath 'vpbp'], 'wb', 'ieee-be'); |
291 |
|
|
wpbp__id = fopen([opath 'wpbp'], 'wb', 'ieee-be'); |
292 |
|
|
vpbpdzid = fopen([opath 'vpbp_dbdz'], 'wb', 'ieee-be'); |
293 |
|
|
str___id = fopen([opath 'stress'], 'wb', 'ieee-be'); |
294 |
|
|
|
295 |
|
|
comm = [ 'permute(reshape(fread( id ,nslab,''real*4'',0,' ... |
296 |
|
|
'''ieee-be''),[ne 6 ne]),[1 3 2]);' ]; |
297 |
|
|
readslab = inline(comm,'id','nslab','ne'); |
298 |
|
|
|
299 |
|
|
ne = 510; |
300 |
|
|
nslab = 6 * ne * ne; |
301 |
|
|
nztot = 50; |
302 |
|
|
iz = 1; |
303 |
|
|
for iz = 1:nztot |
304 |
|
|
|
305 |
|
|
disp(sprintf(' iz = %d',iz)); |
306 |
|
|
offset = (iz - 1)*nslab*4; |
307 |
|
|
for iid = 1:length(iids) |
308 |
|
|
fseek(iids(iid), offset, 'bof'); |
309 |
|
|
end |
310 |
|
|
u = readslab(u__id,nslab,ne); u2 = readslab(u2_id,nslab,ne); |
311 |
|
|
v = readslab(v__id,nslab,ne); v2 = readslab(v2_id,nslab,ne); |
312 |
|
|
um = readslab(um_id,nslab,ne); |
313 |
|
|
vm = readslab(vm_id,nslab,ne); |
314 |
|
|
wm = readslab(wm_id,nslab,ne); |
315 |
|
|
% surf(v2(:,:,1)), view(2), shading interp |
316 |
|
|
if (iz < nztot) |
317 |
|
|
wmp1 = readslab(wm_id,nslab,ne); |
318 |
|
|
else |
319 |
|
|
wmp1 = zeros(size(wm)); |
320 |
|
|
end |
321 |
|
|
wmp05 = (wm + wmp1)/2.0; |
322 |
|
|
w2 = readslab(w2_id,nslab,ne); |
323 |
|
|
t = readslab(t__id,nslab,ne); t2 = readslab(t2_id,nslab,ne); |
324 |
|
|
s = readslab(s__id,nslab,ne); s2 = readslab(s2_id,nslab,ne); |
325 |
|
|
b = readslab(b__id,nslab,ne); b2 = readslab(b2_id,nslab,ne); |
326 |
|
|
|
327 |
|
|
% "simple squared" quantities |
328 |
|
|
up2 = u2 - u.^2; |
329 |
|
|
vp2 = v2 - v.^2; |
330 |
|
|
wp2 = w2 - wm.^2; |
331 |
|
|
fwrite(up2___id, up2, 'real*4'); |
332 |
|
|
fwrite(vp2___id, vp2, 'real*4'); |
333 |
|
|
fwrite(wp2___id, wp2, 'real*4'); |
334 |
|
|
clear up2 vp2 wp2 u2 v2 w2 |
335 |
|
|
tp2 = t2 - t.^2; |
336 |
|
|
sp2 = s2 - s.^2; |
337 |
|
|
bp2 = b2 - b.^2; |
338 |
|
|
fwrite(tp2___id, tp2, 'real*4'); |
339 |
|
|
fwrite(sp2___id, sp2, 'real*4'); |
340 |
|
|
fwrite(bp2___id, bp2, 'real*4'); |
341 |
|
|
clear tp2 sp2 bp2 t2 s2 b2 |
342 |
|
|
ut = readslab(ut_id,nslab,ne); vt = readslab(vt_id,nslab,ne); |
343 |
|
|
us = readslab(us_id,nslab,ne); vs = readslab(vs_id,nslab,ne); |
344 |
|
|
ub = readslab(ub_id,nslab,ne); vb = readslab(vb_id,nslab,ne); |
345 |
|
|
drhodr = readslab(dr_id,nslab,ne); |
346 |
|
|
[ tonu, tonv ] = mass_on_u_v(t); |
347 |
|
|
[ sonu, sonv ] = mass_on_u_v(s); |
348 |
|
|
[ bonu, bonv ] = mass_on_u_v(b); |
349 |
|
|
uptp = ut - u .* tonu; vptp = vt - v .* tonv; |
350 |
|
|
upsp = us - u .* sonu; vpsp = vs - v .* sonv; |
351 |
|
|
upbp = ub - u .* bonu; vpbp = vb - v .* bonv; |
352 |
|
|
|
353 |
|
|
% llupbp = upbp .* llux + vpbp .* llvx; |
354 |
|
|
llvpbp = upbp .* lluy + vpbp .* llvy; |
355 |
|
|
if iz > 1 |
356 |
|
|
% ave_llupbp = (llupbp + old_llupbp)/2.0; |
357 |
|
|
ave_llvpbp = (llvpbp + old_llvpbp)/2.0; |
358 |
|
|
tmp = drhodr; |
359 |
|
|
tmp(find(tmp == 0.0)) = 1.0; |
360 |
|
|
vpbpdbdz = ave_llvpbp ./ tmp; |
361 |
|
|
fwrite(vpbpdzid, vpbpdbdz, 'real*4'); |
362 |
|
|
fac = 1000 * 2*pi/(24*3600); |
363 |
|
|
stress = fac * sin(pi*YC/180) .* vpbpdbdz; |
364 |
|
|
fwrite(str___id, stress, 'real*4'); |
365 |
|
|
end |
366 |
|
|
% old_llupbp = llupbp; |
367 |
|
|
old_llvpbp = llvpbp; |
368 |
|
|
|
369 |
|
|
fwrite(uptp__id, uptp, 'real*4'); |
370 |
|
|
fwrite(vptp__id, vptp, 'real*4'); |
371 |
|
|
fwrite(upsp__id, upsp, 'real*4'); |
372 |
|
|
fwrite(vpsp__id, vpsp, 'real*4'); |
373 |
|
|
fwrite(upbp__id, upbp, 'real*4'); |
374 |
|
|
fwrite(vpbp__id, vpbp, 'real*4'); |
375 |
|
|
clear uptp vptp upsp vpsp upbp vpbp vpbpdbdz |
376 |
|
|
wt = readslab(wt_id,nslab,ne); wptp = wt - wmp05 .* t; |
377 |
|
|
ws = readslab(ws_id,nslab,ne); wpsp = ws - wmp05 .* s; |
378 |
|
|
wb = readslab(wb_id,nslab,ne); wpbp = wb - wmp05 .* b; |
379 |
|
|
fwrite(wptp__id, wptp, 'real*4'); |
380 |
|
|
fwrite(wpsp__id, wpsp, 'real*4'); |
381 |
|
|
fwrite(wpbp__id, wpbp, 'real*4'); |
382 |
|
|
end |
383 |
|
|
|
384 |
|
|
ne = 510; |
385 |
|
|
nz = 1; |
386 |
|
|
nr = 50; |
387 |
|
|
nrm1 = nr - 1; |
388 |
|
|
nlat = 181; nlatm1 = nlat - 1; |
389 |
|
|
% save indicies for zonal averages |
390 |
|
|
hvals = linspace(-90,90,nlat); |
391 |
|
|
i = 2; |
392 |
|
|
for i = 2:nlat |
393 |
|
|
inds = find(hvals(i-1)<YC & YC<hvals(i)); |
394 |
|
|
comm = sprintf('inds%04d = uint32(inds);',i-1); |
395 |
|
|
eval(comm); |
396 |
|
|
end |
397 |
|
|
|
398 |
|
|
comm = [ 'reshape(fread( id ,nslab,''real*4'',0,' ... |
399 |
|
|
'''ieee-be''),[ne ne 6]);' ]; |
400 |
|
|
readcubelev = inline(comm,'id','nslab','ne'); |
401 |
|
|
|
402 |
|
|
% Zonally average the ll_vpbp |
403 |
|
|
acc = zeros(nlatm1, nrm1); |
404 |
|
|
num = zeros(size(acc)); |
405 |
|
|
zidu = fopen('primes_92_04/upbp', 'r', 'ieee-be'); |
406 |
|
|
zidv = fopen('primes_92_04/vpbp', 'r', 'ieee-be'); |
407 |
|
|
for iz = 1:50, |
408 |
|
|
disp(sprintf('iz = %d',iz)); |
409 |
|
|
fseek(zidu, (iz - 1)*(ne*ne*6)*4, 'bof'); |
410 |
|
|
fseek(zidv, (iz - 1)*(ne*ne*6)*4, 'bof'); |
411 |
|
|
upbp = readcubelev(zidu,nslab,ne); |
412 |
edhill |
1.2 |
vpbp = readcubelev(zidv,nslab,ne); |
413 |
|
|
llupbp = upbp .* llux + vpbp .* llvx; |
414 |
edhill |
1.1 |
llvpbp = upbp .* lluy + vpbp .* llvy; |
415 |
|
|
% surf(llvpbp(:,:,1)), view(2), shading interp, caxis([-.1 .1]) |
416 |
|
|
for jj = 1:nlatm1 |
417 |
|
|
eval( sprintf('clear inds; inds = inds%04d;',jj) ); |
418 |
|
|
tmp = llvpbp(inds); |
419 |
|
|
nzinds = find(tmp ~= 0.0); |
420 |
|
|
num(jj,iz) = length(nzinds); |
421 |
|
|
acc(jj,iz) = sum(tmp(nzinds)); |
422 |
|
|
end |
423 |
|
|
end |
424 |
|
|
fclose(zidu); |
425 |
|
|
fclose(zidv); |
426 |
|
|
llzvpbp = acc ./ num; |
427 |
edhill |
1.2 |
% surf(llupbp(:,:,1)'), view(2), shading interp, caxis([-.1 .1]) |
428 |
|
|
% surf(llvpbp(:,:,1)'), view(2), shading interp, caxis([-.1 .1]) |
429 |
|
|
% surf(llzvpbp'), view(2), shading interp, caxis([-.1 .1]) |
430 |
edhill |
1.4 |
% ! rm -f primes_92_04/za_llvpbp.mat |
431 |
|
|
% save primes_92_04/za_llvpbp.mat llzvpbp |
432 |
edhill |
1.1 |
|
433 |
|
|
% zonally average ll_vpbp_dbdz |
434 |
|
|
acc = zeros(nlatm1, nrm1); |
435 |
|
|
num = zeros(size(acc)); |
436 |
|
|
zid = fopen('primes_92_04/vpbp_dbdz', 'r', 'ieee-be'); |
437 |
|
|
iz = 1; |
438 |
|
|
for iz = 1:49, |
439 |
|
|
disp(sprintf('iz = %d',iz)); |
440 |
|
|
fseek(zid, (iz - 1)*(ne*ne*6)*4, 'bof'); |
441 |
|
|
vpbpdbdz = readcubelev(zid,nslab,ne); |
442 |
|
|
% surf(vpbpdbdz(:,:,1)), view(2), shading interp, caxis([-50 50]) |
443 |
|
|
for jj = 1:nlatm1 |
444 |
|
|
eval( sprintf('clear inds; inds = inds%04d;',jj) ); |
445 |
|
|
tmp = vpbpdbdz(inds); |
446 |
|
|
nzinds = find(tmp ~= 0.0); |
447 |
|
|
num(jj,iz) = length(nzinds); |
448 |
|
|
acc(jj,iz) = sum(tmp(nzinds)); |
449 |
|
|
end |
450 |
|
|
end |
451 |
|
|
fclose(zid); |
452 |
|
|
za_ll_vpbp_dbdz = acc ./ num; |
453 |
edhill |
1.4 |
% ! rm -f primes_92_04/za_ll_vpbp_dbdz.mat |
454 |
edhill |
1.1 |
% save primes_92_04/za_ll_vpbp_dbdz.mat za_ll_vpbp_dbdz |
455 |
|
|
|
456 |
|
|
% zonally average stress |
457 |
|
|
acc = zeros(nlatm1, nrm1); |
458 |
|
|
num = zeros(size(acc)); |
459 |
|
|
zid = fopen('primes_92_04/stress', 'r', 'ieee-be'); |
460 |
|
|
iz = 1; |
461 |
|
|
for iz = 1:49, |
462 |
|
|
disp(sprintf('iz = %d',iz)); |
463 |
|
|
fseek(zid, (iz - 1)*(ne*ne*6)*4, 'bof'); |
464 |
|
|
stress = readcubelev(zid,nslab,ne); |
465 |
|
|
for jj = 1:nlatm1 |
466 |
|
|
eval( sprintf('clear inds; inds = inds%04d;',jj) ); |
467 |
|
|
tmp = stress(inds); |
468 |
|
|
nzinds = find(tmp ~= 0.0); |
469 |
|
|
num(jj,iz) = length(nzinds); |
470 |
|
|
acc(jj,iz) = sum(tmp(nzinds)); |
471 |
|
|
end |
472 |
|
|
end |
473 |
|
|
fclose(zid); |
474 |
edhill |
1.3 |
za_stress = acc ./ num; |
475 |
edhill |
1.4 |
% ! rm -f primes_92_04/stress.mat |
476 |
edhill |
1.3 |
% save primes_92_04/stress.mat za_stress |
477 |
edhill |
1.1 |
|
478 |
edhill |
1.3 |
% Average the stress over SSH-contours (streamlines) |
479 |
|
|
eta_id = fopen('ave_1992-2004/ETAN.ave', 'r', 'ieee-be'); |
480 |
|
|
comm = [ 'permute(reshape(fread( id ,nslab,''real*4'',0,' ... |
481 |
|
|
'''ieee-be''),[ne 6 ne]),[1 3 2]);' ]; |
482 |
|
|
readslab = inline(comm,'id','nslab','ne'); |
483 |
|
|
etan = readslab(eta_id,nslab,ne); |
484 |
|
|
fclose(eta_id); |
485 |
|
|
% surf(YC(:,:,1)'), view(2),shading interp,colorbar |
486 |
|
|
% surf(etan(:,:,1)'), view(2),shading interp,colorbar |
487 |
|
|
nssh = 50; |
488 |
|
|
sshvals = linspace(-2.3,1.2,nssh); |
489 |
|
|
i = 2; |
490 |
|
|
for i = 2:nssh |
491 |
|
|
inds = find(sshvals(i-1)<etan & etan<sshvals(i) & YC<-20); |
492 |
|
|
comm = sprintf('sshinds%04d = uint32(inds);',i-1); |
493 |
|
|
eval(comm); |
494 |
|
|
end |
495 |
|
|
zid = fopen('primes_92_04/stress', 'r', 'ieee-be'); |
496 |
|
|
iz = 1; |
497 |
|
|
for iz = 1:49, |
498 |
|
|
disp(sprintf('iz = %d',iz)); |
499 |
|
|
fseek(zid, (iz - 1)*(ne*ne*6)*4, 'bof'); |
500 |
|
|
stress = readcubelev(zid,nslab,ne); |
501 |
|
|
for jj = 1:(nssh-1) |
502 |
|
|
eval( sprintf('clear inds; inds = sshinds%04d;',jj) ); |
503 |
|
|
tmp = stress(inds); |
504 |
|
|
nzinds = find(tmp ~= 0.0); |
505 |
|
|
num(jj,iz) = length(nzinds); |
506 |
|
|
acc(jj,iz) = sum(tmp(nzinds)); |
507 |
|
|
end |
508 |
|
|
end |
509 |
|
|
fclose(zid); |
510 |
|
|
ssha_stress = acc ./ num; |
511 |
|
|
% surf(log(ssha_stress')), view(2),shading interp,colorbar |
512 |
edhill |
1.4 |
% ! rm -f primes_92_04/ssha_stress.mat |
513 |
|
|
% save primes_92_04/ssha_stress.mat ssha_stress sshvals |
514 |
edhill |
1.2 |
|
515 |
edhill |
1.1 |
|
516 |
|
|
clear all |
517 |
|
|
close all |
518 |
|
|
|
519 |
|
|
%================================================================== |
520 |
|
|
% Read the tile00?.mitgrid files |
521 |
|
|
gvars = { 'XC','YC','DXF','DYF','RA','XG','YG','DXV', ... |
522 |
|
|
'DYU','RAZ','DXC','DYC','RAW','RAS','DXG','DYG' }; |
523 |
|
|
|
524 |
|
|
ne = 510; |
525 |
|
|
nep1 = ne + 1; |
526 |
|
|
iface = 1; |
527 |
|
|
for iface = 1:6 |
528 |
|
|
fname = sprintf('grid/tile%03d.mitgrid', iface); |
529 |
|
|
gid = fopen(fname, 'r', 'ieee-be'); |
530 |
|
|
tmp = reshape(fread(gid,inf,'real*8',0,'ieee-be'),[nep1,nep1,16]); |
531 |
|
|
fclose(gid); |
532 |
|
|
% surf(tmp(:,:,1)), view(2), shading interp |
533 |
|
|
% for jj = 1:length(gvars) |
534 |
|
|
for jj = 1:7 |
535 |
|
|
comm = sprintf('%s(:,:,%d) = tmp(:,:,%d);', ... |
536 |
|
|
[gvars{jj}], iface, jj); |
537 |
|
|
eval(comm); |
538 |
|
|
end |
539 |
|
|
end |
540 |
|
|
% surf(XC(:,:,1)), view(2), shading interp |
541 |
|
|
% subplot(2,1,1), a = [1:10]; surf(XC(a,a,1)), view(2) |
542 |
|
|
% subplot(2,1,2), a = [(nep1-10):nep1]; surf(XC(a,a,1)), view(2) |
543 |
|
|
% surf(YC(:,:,1)), view(2), shading interp |
544 |
|
|
% surf(XG(:,:,1)), view(2), shading interp |
545 |
|
|
% surf(YG(:,:,1)), view(2), shading interp |
546 |
|
|
is = [1:ne]; |
547 |
|
|
vs = { 'XC','YC','DXF','DYF','RA' }; |
548 |
|
|
for i = 1:length(vs) |
549 |
|
|
eval(sprintf('%s = %s(is,is,:);',vs{i},vs{i})); |
550 |
|
|
end |
551 |
|
|
|
552 |
|
|
delR = [ ... |
553 |
|
|
10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.01, ... |
554 |
|
|
10.03, 10.11, 10.32, 10.80, 11.76, 13.42, 16.04 , 19.82, 24.85, ... |
555 |
|
|
31.10, 38.42, 46.50, 55.00, 63.50, 71.58, 78.90, 85.15, 90.18, ... |
556 |
|
|
93.96, 96.58, 98.25, 99.25,100.01,101.33,104.56,111.33,122.83, ... |
557 |
|
|
139.09,158.94,180.83,203.55,226.50,249.50,272.50,295.50,318.50, ... |
558 |
|
|
341.50,364.50,387.50,410.50,433.50,456.50 ]; |
559 |
|
|
R = cumsum(delR) - 0.5*delR; |
560 |
edhill |
1.4 |
Ri = R(1:(length(R)-1)) ... |
561 |
|
|
+ 0.25*delR(1:(length(R)-1)) + 0.25*delR(2:(length(R))); |
562 |
|
|
|
563 |
edhill |
1.1 |
n1 = ne - 1; |
564 |
|
|
dux = zeros(size(XC)); |
565 |
|
|
duy = zeros(size(XC)); |
566 |
|
|
dvx = zeros(size(XC)); |
567 |
|
|
dvy = zeros(size(XC)); |
568 |
|
|
dux(:,:,:) = diff(XG(:,1:ne,:),1,1); |
569 |
|
|
dvx(:,:,:) = diff(XG(1:ne,:,:),1,2); |
570 |
|
|
duy(:,:,:) = diff(YG(:,1:ne,:),1,1); |
571 |
|
|
dvy(:,:,:) = diff(YG(1:ne,:,:),1,2); |
572 |
|
|
dux = dux + 360*double(dux < 180); |
573 |
|
|
dux = dux - 360*double(dux > 180); % [ min(min(dux)) max(max(dux)) ] |
574 |
|
|
duy = duy + 360*double(duy < 180); |
575 |
|
|
duy = duy - 360*double(duy > 180); % [ min(min(duy)) max(max(duy)) ] |
576 |
|
|
dvx = dvx + 360*double(dvx < 180); |
577 |
|
|
dvx = dvx - 360*double(dvx > 180); % [ min(min(dvx)) max(max(dvx)) ] |
578 |
|
|
dvy = dvy + 360*double(dvy < 180); |
579 |
|
|
dvy = dvy - 360*double(dvy > 180); % [ min(min(dvy)) max(max(dvy)) ] |
580 |
|
|
llux = dux ./ sqrt(dux.^2 + duy.^2); |
581 |
|
|
lluy = duy ./ sqrt(dux.^2 + duy.^2); |
582 |
|
|
llvx = dvx ./ sqrt(dvx.^2 + dvy.^2); |
583 |
|
|
llvy = dvy ./ sqrt(dvx.^2 + dvy.^2); |
584 |
|
|
|
585 |
|
|
%================================================================== |
586 |
|
|
% Project fields to lower-res 1-degree Lat-Lon and write |
587 |
|
|
% as NetCDF for viewing with Ingrid |
588 |
|
|
% |
589 |
|
|
ne = 510; |
590 |
|
|
nf = 6; |
591 |
|
|
nz = 50; |
592 |
|
|
nslab = ne*ne*nf; |
593 |
|
|
adir = 'primes_92_04'; |
594 |
|
|
lat = [-90:90]; |
595 |
|
|
lon = [0:360]; |
596 |
edhill |
1.2 |
ir = [ 1 2 3 5 10 15 20 25 30 35 40 ]; |
597 |
edhill |
1.1 |
xc360 = XC + 180; |
598 |
|
|
|
599 |
edhill |
1.2 |
% ! rm -f cube_22_primes_at1deg.nc |
600 |
|
|
nc = netcdf(['cube_22_primes_at1deg.nc'], 'clobber'); |
601 |
|
|
nc.reference = [ 'The cube_22 primes from Dimitris Menemenlis' ... |
602 |
|
|
' regridded to 1-deg Lat-Lon' ]; |
603 |
edhill |
1.1 |
nc.author = 'Ed Hill <eh3@mit.edu>'; |
604 |
edhill |
1.2 |
nc.date = 'March 27, 2005'; |
605 |
edhill |
1.1 |
nc('X') = length(lon); |
606 |
|
|
nc('Y') = length(lat); |
607 |
|
|
nc('Z') = length(ir); |
608 |
edhill |
1.4 |
nc('Zc') = length(R); |
609 |
|
|
nc('Zi') = length(Ri); |
610 |
edhill |
1.1 |
nc{'X'} = 'X'; |
611 |
|
|
nc{'Y'} = 'Y'; |
612 |
|
|
nc{'Z'} = 'Z'; |
613 |
edhill |
1.4 |
nc{'Zc'} = 'Zc'; |
614 |
|
|
nc{'Zi'} = 'Zi'; |
615 |
edhill |
1.1 |
nc{'X'}.uniquename = 'X'; |
616 |
|
|
nc{'X'}.long_name = 'longitude'; |
617 |
|
|
nc{'X'}.gridtype = ncint(1); |
618 |
|
|
nc{'X'}.units = 'degree_east'; |
619 |
|
|
nc{'Y'}.uniquename = 'Y'; |
620 |
|
|
nc{'Y'}.long_name = 'latitude'; |
621 |
|
|
nc{'Y'}.gridtype = ncint(0); |
622 |
|
|
nc{'Y'}.units = 'degree_north'; |
623 |
|
|
nc{'Z'}.uniquename = 'Z'; |
624 |
|
|
nc{'Z'}.long_name = 'depth'; |
625 |
|
|
nc{'Z'}.gridtype = ncint(0); |
626 |
|
|
nc{'Z'}.units = 'm'; |
627 |
edhill |
1.4 |
nc{'Zc'}.uniquename = 'Zc'; |
628 |
|
|
nc{'Zc'}.long_name = 'depth_at_center'; |
629 |
|
|
nc{'Zc'}.gridtype = ncint(0); |
630 |
|
|
nc{'Zc'}.units = 'm'; |
631 |
|
|
nc{'Zi'}.uniquename = 'Zi'; |
632 |
|
|
nc{'Zi'}.long_name = 'depth_at_interface'; |
633 |
|
|
nc{'Zi'}.gridtype = ncint(0); |
634 |
|
|
nc{'Zi'}.units = 'm'; |
635 |
edhill |
1.1 |
nc{'X'}(:) = lon; |
636 |
|
|
nc{'Y'}(:) = lat; |
637 |
|
|
nc{'Z'}(:) = R(ir); |
638 |
edhill |
1.4 |
nc{'Zc'}(:) = R; |
639 |
|
|
nc{'Zi'}(:) = Ri; |
640 |
|
|
|
641 |
|
|
f_s_3d = { {'tp2'}, {'sp2'}, {'bp2'}, {'vpbp_dbdz'}, {'stress'} }; |
642 |
edhill |
1.1 |
|
643 |
|
|
ifg = 1; |
644 |
|
|
for ifg = 1:length(f_s_3d) |
645 |
|
|
|
646 |
|
|
acell = f_s_3d{ifg}; |
647 |
|
|
tname = acell{1}; |
648 |
|
|
disp([ ' ' tname ' :' ]); |
649 |
|
|
|
650 |
|
|
fname = sprintf('%s/%s',adir,tname); |
651 |
|
|
fid = fopen(fname,'r','ieee-be'); |
652 |
|
|
|
653 |
|
|
id = tname; |
654 |
|
|
nc{ id } = { 'Z' 'Y' 'X' }; |
655 |
|
|
nc{ id }.missing_value = ncdouble(NaN); |
656 |
|
|
nc{ id }.FillValue_ = ncdouble(0.0); |
657 |
|
|
|
658 |
|
|
ii = 1; |
659 |
|
|
for ii = 1:length(ir) |
660 |
|
|
|
661 |
|
|
iz = ir(ii); |
662 |
|
|
disp(sprintf(' iz = %3d R(iz) = %g',iz,R(iz))); |
663 |
|
|
|
664 |
|
|
fseek(fid,nslab*4*(iz-1),'bof'); |
665 |
|
|
tmp = fread(fid,nslab,'real*4',0,'ieee-be'); |
666 |
|
|
tr = reshape(tmp,[ 510 510 6 ]); |
667 |
|
|
% surf(tr(:,:,1)), view(2), shading interp |
668 |
|
|
trn = tr; |
669 |
|
|
trn(find(tr == 0.0)) = NaN; |
670 |
|
|
clear tmp tr |
671 |
|
|
% v = sdac_regrid(xc360,YC,trn,lonm,latm); |
672 |
|
|
v = ll_regrid(xc360,YC,trn,lon,lat); |
673 |
|
|
% surf(lon,lat,v'), caxis([25 40]), view(2), shading interp, colorbar |
674 |
|
|
|
675 |
|
|
nc{ id }(ii,:,:) = permute(v,[2 1]); |
676 |
|
|
|
677 |
|
|
end |
678 |
|
|
|
679 |
|
|
fclose(fid); |
680 |
|
|
|
681 |
|
|
end |
682 |
|
|
|
683 |
|
|
id = 'sum_up2_vp2'; |
684 |
|
|
nc{ id } = { 'Z' 'Y' 'X' }; |
685 |
|
|
nc{ id }.missing_value = ncdouble(NaN); |
686 |
|
|
nc{ id }.FillValue_ = ncdouble(0.0); |
687 |
|
|
fidu = fopen(sprintf('%s/%s',adir,'up2'),'r','ieee-be'); |
688 |
|
|
fidv = fopen(sprintf('%s/%s',adir,'vp2'),'r','ieee-be'); |
689 |
|
|
for ii = 1:length(ir) |
690 |
|
|
iz = ir(ii); |
691 |
|
|
disp(sprintf(' iz = %3d R(iz) = %g',iz,R(iz))); |
692 |
|
|
fseek(fidu,nslab*4*(iz-1),'bof'); |
693 |
|
|
fseek(fidv,nslab*4*(iz-1),'bof'); |
694 |
|
|
tru = reshape(fread(fidu,nslab,'real*4',0,'ieee-be'),[510 510 6]); |
695 |
|
|
trv = reshape(fread(fidv,nslab,'real*4',0,'ieee-be'),[510 510 6]); |
696 |
|
|
trnu = tru; trnu(find(tru == 0.0)) = NaN; |
697 |
|
|
trnv = trv; trnv(find(trv == 0.0)) = NaN; |
698 |
|
|
clear tmp tru trv |
699 |
|
|
lluv = ll_regrid(xc360,YC,trnu+trnv,lon,lat); |
700 |
|
|
nc{ id }(ii,:,:) = permute(lluv,[2 1]); |
701 |
|
|
end |
702 |
|
|
fclose(fidu); |
703 |
|
|
fclose(fidv); |
704 |
|
|
|
705 |
|
|
f_v_3d = { {'up2','vp2'}, ... |
706 |
|
|
{'uptp','vptp'}, {'upsp','vpsp'}, {'upbp','vpbp'} }; |
707 |
|
|
for ip = 1:length(f_v_3d) |
708 |
|
|
cell = f_v_3d{ip}; |
709 |
|
|
idu = cell{1}; |
710 |
|
|
idv = cell{2}; |
711 |
|
|
disp([' ' idu ' ' idv]); |
712 |
|
|
nc{ idu } = { 'Z' 'Y' 'X' }; |
713 |
|
|
nc{ idu }.missing_value = ncdouble(NaN); |
714 |
|
|
nc{ idu }.FillValue_ = ncdouble(0.0); |
715 |
|
|
nc{ idv } = { 'Z' 'Y' 'X' }; |
716 |
|
|
nc{ idv }.missing_value = ncdouble(NaN); |
717 |
|
|
nc{ idv }.FillValue_ = ncdouble(0.0); |
718 |
|
|
fidu = fopen(sprintf('%s/%s',adir,idu),'r','ieee-be'); |
719 |
|
|
fidv = fopen(sprintf('%s/%s',adir,idv),'r','ieee-be'); |
720 |
|
|
for ii = 1:length(ir) |
721 |
|
|
iz = ir(ii); |
722 |
|
|
disp(sprintf(' iz = %3d R(iz) = %g',iz,R(iz))); |
723 |
|
|
fseek(fidu,nslab*4*(iz-1),'bof'); |
724 |
|
|
fseek(fidv,nslab*4*(iz-1),'bof'); |
725 |
|
|
tru = reshape(fread(fidu,nslab,'real*4',0,'ieee-be'),[510 510 6]); |
726 |
|
|
trv = reshape(fread(fidv,nslab,'real*4',0,'ieee-be'),[510 510 6]); |
727 |
|
|
trnu = tru; trnu(find(tru == 0.0)) = NaN; |
728 |
|
|
trnv = trv; trnv(find(trv == 0.0)) = NaN; |
729 |
|
|
clear tmp tru trv |
730 |
|
|
llru = trnu .* llux + trnv .* llvx; |
731 |
|
|
llrv = trnu .* lluy + trnv .* llvy; |
732 |
|
|
llu = ll_regrid(xc360,YC,llru,lon,lat); |
733 |
|
|
llv = ll_regrid(xc360,YC,llrv,lon,lat); |
734 |
|
|
nc{ idu }(ii,:,:) = permute(llu,[2 1]); |
735 |
|
|
nc{ idv }(ii,:,:) = permute(llv,[2 1]); |
736 |
|
|
end |
737 |
|
|
end |
738 |
|
|
fclose(fidu); |
739 |
|
|
fclose(fidv); |
740 |
|
|
nc = close(nc); |
741 |
|
|
|
742 |
edhill |
1.4 |
% === zonal and stream-wise averages === |
743 |
|
|
% save primes_92_04/za_llvpbp.mat llzvpbp |
744 |
|
|
% save primes_92_04/za_ll_vpbp_dbdz.mat za_ll_vpbp_dbdz |
745 |
|
|
% save primes_92_04/stress.mat za_stress |
746 |
|
|
% save primes_92_04/ssha_stress.mat ssha_stress sshvals |
747 |
|
|
load primes_92_04/za_llvpbp.mat |
748 |
|
|
load primes_92_04/za_ll_vpbp_dbdz.mat |
749 |
|
|
load primes_92_04/stress.mat |
750 |
|
|
load primes_92_04/ssha_stress.mat |
751 |
edhill |
1.1 |
|
752 |
edhill |
1.4 |
lat = [-90:90]; |
753 |
|
|
latm = lat(1:(length(lat)-1)) + 0.5*diff(lat); |
754 |
edhill |
1.1 |
|
755 |
edhill |
1.4 |
% ! rm -f cube_22_zsa.nc |
756 |
|
|
nc = netcdf(['cube_22_zsa.nc'], 'clobber'); |
757 |
|
|
nc.reference = [ 'The cube_22 zonal and stream-wise averages.' ]; |
758 |
|
|
nc.author = 'Ed Hill <eh3@mit.edu>'; |
759 |
|
|
nc.date = 'March 27, 2005'; |
760 |
|
|
nc('Y') = length(latm); |
761 |
|
|
nc('Zc') = length(R); |
762 |
|
|
nc('Zi') = length(Ri); |
763 |
|
|
nc{'Y'} = 'Y'; |
764 |
|
|
nc{'Zc'} = 'Zc'; |
765 |
|
|
nc{'Zi'} = 'Zi'; |
766 |
|
|
nc{'Y'}.uniquename = 'Y'; |
767 |
|
|
nc{'Y'}.long_name = 'latitude'; |
768 |
|
|
nc{'Y'}.gridtype = ncint(0); |
769 |
|
|
nc{'Y'}.units = 'degree_north'; |
770 |
|
|
nc{'Zc'}.uniquename = 'Zc'; |
771 |
|
|
nc{'Zc'}.long_name = 'depth_at_center'; |
772 |
|
|
nc{'Zc'}.gridtype = ncint(0); |
773 |
|
|
nc{'Zc'}.units = 'm'; |
774 |
|
|
nc{'Zi'}.uniquename = 'Zi'; |
775 |
|
|
nc{'Zi'}.long_name = 'depth_at_interface'; |
776 |
|
|
nc{'Zi'}.gridtype = ncint(0); |
777 |
|
|
nc{'Zi'}.units = 'm'; |
778 |
|
|
nc{'Y'}(:) = latm; |
779 |
|
|
nc{'Zc'}(:) = R; |
780 |
|
|
nc{'Zi'}(:) = Ri; |
781 |
edhill |
1.1 |
|
782 |
edhill |
1.4 |
id = 'llzvpbp'; |
783 |
|
|
nc{ id } = { 'Zc' 'Y' }; |
784 |
|
|
nc{ id }.missing_value = ncdouble(NaN); |
785 |
|
|
nc{ id }.FillValue_ = ncdouble(0.0); |
786 |
|
|
nc{ id }(:) = permute(llzvpbp,[2 1]); |
787 |
edhill |
1.1 |
|
788 |
edhill |
1.4 |
f_i = { {'ssha_stress'}, {'za_ll_vpbp_dbdz'}, {'za_stress'} }; |
789 |
|
|
for ip = 1:length(f_i) |
790 |
|
|
cell = f_i{ip}; |
791 |
|
|
id = cell{1}; |
792 |
|
|
disp([' ' id]); |
793 |
|
|
nc{ id } = { 'Zi' 'Y' }; |
794 |
|
|
nc{ id }.missing_value = ncdouble(NaN); |
795 |
|
|
nc{ id }.FillValue_ = ncdouble(0.0); |
796 |
|
|
eval(sprintf('tmp = %s;', id)); |
797 |
|
|
nc{ id }(:) = permute(tmp,[2 1]); |
798 |
edhill |
1.1 |
end |
799 |
edhill |
1.4 |
nc = close(nc); |
800 |
edhill |
1.1 |
|
801 |
edhill |
1.4 |
% ! scp cube_22_zsa.nc cube_22_primes_at1deg.nc channel.mit.edu:/home/edhill/INGRID_PEOPLE/EH3/eddy_flux/cube_22/ |
802 |
|
|
% ! mv cube_22_primes_at1deg.nc primes_92_04 |
803 |
edhill |
1.1 |
|
804 |
|
|
|
805 |
|
|
|
806 |
|
|
|