1 |
heimbach |
1.1 |
% Plot cube fields in six panel layout |
2 |
|
|
function [] = t18_to_global_inputs() |
3 |
|
|
|
4 |
|
|
% "facet" sizes |
5 |
|
|
% Fifteent level llc_cs90x90x360 |
6 |
|
|
nr=90; |
7 |
|
|
ng=90; |
8 |
|
|
nb=360; |
9 |
|
|
nz=15; |
10 |
|
|
|
11 |
|
|
disp('This is version for correct, non-transposed input!') |
12 |
|
|
|
13 |
|
|
% Read in the bathymetry |
14 |
|
|
figure(1);clf |
15 |
|
|
bdir='.'; |
16 |
|
|
bpref='bathy'; |
17 |
|
|
nbx=90; |
18 |
|
|
nby=90; |
19 |
|
|
nbt=0; |
20 |
|
|
bdata=[]; |
21 |
|
|
ploc=[36 29 22 15 37 30 23 16 9 10 11 12 13 3 4 5 6 7]; |
22 |
|
|
fl=dir(bdir); |
23 |
|
|
for f=1:length(fl) |
24 |
|
|
n=fl(f).name; |
25 |
|
|
rpat=sprintf('^%s\\..*',bpref); |
26 |
|
|
a=regexp(n,rpat,'match'); |
27 |
|
|
if length(a) == 1 & nbt <= 17 |
28 |
|
|
nbt=nbt+1; |
29 |
|
|
bfile(nbt)=a; |
30 |
|
|
fn=sprintf('%s/%s',bdir,a{:}); |
31 |
|
|
fid=fopen(fn,'r','ieee-be'); |
32 |
|
|
bdata(nbt,:,:)=fread(fid,[nbx nby],'float64'); |
33 |
|
|
fclose(fid); |
34 |
|
|
phi=flipud(squeeze(bdata(nbt,:,:))); |
35 |
|
|
phi(find(phi==0))=NaN; |
36 |
|
|
subplot(6,7,ploc(nbt));imagesc(phi);axis equal;axis off;axis tight |
37 |
|
|
end |
38 |
|
|
end |
39 |
|
|
|
40 |
|
|
% Read in potential temperature |
41 |
|
|
figure(2);clf |
42 |
|
|
bdir='.'; |
43 |
|
|
bpref='temp_15_lev'; |
44 |
|
|
nbx=90; |
45 |
|
|
nby=90; |
46 |
|
|
npt=0; |
47 |
|
|
ptdata=[]; |
48 |
|
|
ploc=[36 29 22 15 37 30 23 16 9 10 11 12 13 3 4 5 6 7]; |
49 |
|
|
fl=dir(bdir); |
50 |
|
|
for f=1:length(fl) |
51 |
|
|
n=fl(f).name; |
52 |
|
|
rpat=sprintf('^%s\\..*',bpref); |
53 |
|
|
a=regexp(n,rpat,'match'); |
54 |
|
|
if length(a) == 1 & npt <= 17 |
55 |
|
|
npt=npt+1; |
56 |
|
|
ptfile(npt)=a; |
57 |
|
|
fn=sprintf('%s/%s',bdir,a{:}); |
58 |
|
|
fid=fopen(fn,'r','ieee-be'); |
59 |
|
|
ptdata(npt,:,:,:)=reshape(fread(fid,nbx*nby*nz,'float64'),[nbx nby nz]); |
60 |
|
|
fclose(fid); |
61 |
|
|
phi=flipud(squeeze(ptdata(npt,:,:,1))); |
62 |
|
|
phiMsk=flipud(squeeze(bdata(npt,:,:))); |
63 |
|
|
phi(find(phiMsk==0))=NaN; |
64 |
|
|
subplot(6,7,ploc(npt));imagesc(phi);axis equal;axis off;axis tight;caxis([-5 30]); |
65 |
|
|
end |
66 |
|
|
end |
67 |
|
|
|
68 |
|
|
% Read in sailinity |
69 |
|
|
figure(3);clf |
70 |
|
|
bdir='.'; |
71 |
|
|
bpref='salt_15_lev'; |
72 |
|
|
nbx=90; |
73 |
|
|
nby=90; |
74 |
|
|
nsalt=0; |
75 |
|
|
sdata=[]; |
76 |
|
|
ploc=[36 29 22 15 37 30 23 16 9 10 11 12 13 3 4 5 6 7]; |
77 |
|
|
fl=dir(bdir); |
78 |
|
|
for f=1:length(fl) |
79 |
|
|
n=fl(f).name; |
80 |
|
|
rpat=sprintf('^%s\\..*',bpref); |
81 |
|
|
a=regexp(n,rpat,'match'); |
82 |
|
|
if length(a) == 1 & nsalt <= 17 |
83 |
|
|
nsalt=nsalt+1; |
84 |
|
|
sfile(nsalt)=a; |
85 |
|
|
fn=sprintf('%s/%s',bdir,a{:}); |
86 |
|
|
fid=fopen(fn,'r','ieee-be'); |
87 |
|
|
sdata(nsalt,:,:,:)=reshape(fread(fid,nbx*nby*nz,'float64'),[nbx nby nz]); |
88 |
|
|
fclose(fid); |
89 |
|
|
phi=flipud(squeeze(sdata(nsalt,:,:,1))); |
90 |
|
|
phiMsk=flipud(squeeze(bdata(nsalt,:,:))); |
91 |
|
|
phi(find(phiMsk==0))=NaN; |
92 |
|
|
subplot(6,7,ploc(nsalt));imagesc(phi);axis equal;axis off;axis tight;caxis([29 37]); |
93 |
|
|
end |
94 |
|
|
end |
95 |
|
|
|
96 |
|
|
% Make a global file from the 18 (or 17) tile files. |
97 |
|
|
lgx=2*nr+2*ng+2*nb;lgy=nb; |
98 |
|
|
% Fseek offsets for the 18 90x90 tiles (numbers are specific to this setup) |
99 |
|
|
tx=90;ty=90; |
100 |
|
|
% Facet 1 ... |
101 |
|
|
% Facet 2 ... |
102 |
|
|
% etc... |
103 |
|
|
ox=[0 0 0 0 ... |
104 |
|
|
tx tx tx tx ... |
105 |
|
|
2*tx ... |
106 |
|
|
3*tx 4*tx 5*tx 6*tx ... |
107 |
|
|
7*tx 8*tx 9*tx 10*tx ... |
108 |
|
|
11*tx ]; |
109 |
|
|
oy=[0 ty 2*ty 3*ty ... |
110 |
|
|
0 ty 2*ty 3*ty ... |
111 |
|
|
0 ... |
112 |
|
|
0 0 0 0 ... |
113 |
|
|
0 0 0 0 ... |
114 |
|
|
0]; |
115 |
|
|
|
116 |
|
|
% Bathymetry |
117 |
|
|
foo=zeros(lgx,lgy); |
118 |
|
|
for f=1:size(bdata,1) |
119 |
|
|
phi=squeeze(bdata(f,:,:)); |
120 |
|
|
if f == 18 |
121 |
|
|
phi=0; |
122 |
|
|
end |
123 |
|
|
|
124 |
|
|
%With transposed input |
125 |
|
|
%for c=1:size(phi,1) |
126 |
|
|
%With correct input |
127 |
|
|
%ph( |
128 |
|
|
for c=1:size(phi,2) |
129 |
|
|
%ph) |
130 |
|
|
|
131 |
|
|
ry=oy(f)+c-1; |
132 |
|
|
fsloc=ry*lgx+ox(f); |
133 |
|
|
|
134 |
|
|
% With transposed input |
135 |
|
|
% foo(fsloc+1:fsloc+90)=phi(c,:); |
136 |
|
|
% With correct input |
137 |
|
|
foo(fsloc+1:fsloc+90)=phi(:,c); |
138 |
|
|
|
139 |
|
|
end |
140 |
|
|
end |
141 |
|
|
figure(4);clf |
142 |
|
|
imagesc(foo);axis equal; colorbar |
143 |
|
|
print -djpeg100 bathy.jpeg |
144 |
|
|
fid=fopen('llc90x90x360_bathy.bin','w','ieee-be'); |
145 |
|
|
fwrite(fid,foo,'float64'); |
146 |
|
|
fclose(fid); |
147 |
|
|
|
148 |
|
|
% Potential temperature (adds face 6 too) |
149 |
|
|
foo=zeros(lgx,lgy,nz); |
150 |
|
|
for f=1:size(ptdata,1) |
151 |
|
|
phi=squeeze(ptdata(f,:,:,:)); |
152 |
|
|
phiMsk=squeeze(bdata(f,:,:)); |
153 |
|
|
phiMsk(find(phiMsk~=0))=1.; |
154 |
|
|
|
155 |
|
|
for k=1:nz |
156 |
|
|
phi(:,:,k)=phi(:,:,k).*phiMsk; |
157 |
|
|
|
158 |
|
|
% With transposed input |
159 |
|
|
% for c=1:size(phi,1) |
160 |
|
|
% With correct input |
161 |
|
|
for c=1:size(phi,2) |
162 |
|
|
|
163 |
|
|
ry=oy(f)+c-1; |
164 |
|
|
fsloc=(k-1)*lgx*lgy+ry*lgx+ox(f); |
165 |
|
|
% With transposed input |
166 |
|
|
% foo(fsloc+1:fsloc+90)=phi(c,:,k); |
167 |
|
|
% With correct input |
168 |
|
|
foo(fsloc+1:fsloc+90)=phi(:,c,k); |
169 |
|
|
|
170 |
|
|
end |
171 |
|
|
end |
172 |
|
|
end |
173 |
|
|
figure(5);clf |
174 |
|
|
imagesc(squeeze(foo(:,:,1)));axis equal; colorbar |
175 |
|
|
print -djpeg100 ptemp.jpeg |
176 |
|
|
fid=fopen('llc90x90x360_15l1v_ptemp.bin','w','ieee-be'); |
177 |
|
|
fwrite(fid,foo,'float64'); |
178 |
|
|
fclose(fid); |
179 |
|
|
|
180 |
|
|
% Salinity (adds face 6 too) |
181 |
|
|
foo=zeros(lgx,lgy,nz); |
182 |
|
|
for f=1:size(sdata,1) |
183 |
|
|
phi=squeeze(sdata(f,:,:,:)); |
184 |
|
|
phiMsk=squeeze(bdata(f,:,:)); |
185 |
|
|
phiMsk(find(phiMsk~=0))=1.; |
186 |
|
|
|
187 |
|
|
for k=1:nz |
188 |
|
|
phi(:,:,k)=phi(:,:,k).*phiMsk; |
189 |
|
|
|
190 |
|
|
% With transposed input |
191 |
|
|
% for c=1:size(phi,1) |
192 |
|
|
% With correct input |
193 |
|
|
for c=1:size(phi,2) |
194 |
|
|
|
195 |
|
|
ry=oy(f)+c-1; |
196 |
|
|
fsloc=(k-1)*lgx*lgy+ry*lgx+ox(f); |
197 |
|
|
% With transposed input |
198 |
|
|
% foo(fsloc+1:fsloc+90)=phi(c,:,k); |
199 |
|
|
% With correct input |
200 |
|
|
foo(fsloc+1:fsloc+90)=phi(:,c,k); |
201 |
|
|
|
202 |
|
|
end |
203 |
|
|
end |
204 |
|
|
end |
205 |
|
|
figure(6);clf |
206 |
|
|
imagesc(squeeze(foo(:,:,1)));axis equal; colorbar |
207 |
|
|
print -djpeg100 salt.jpeg |
208 |
|
|
fid=fopen('llc90x90x360_15l1v_salt.bin','w','ieee-be'); |
209 |
|
|
fwrite(fid,foo,'float64'); |
210 |
|
|
fclose(fid); |
211 |
|
|
|
212 |
|
|
end |
213 |
|
|
|
214 |
|
|
function [] = mkcubeplot(ptit,temp,sf) |
215 |
|
|
ploc=[9 10 6 7 3 4]; |
216 |
|
|
phil=[]; |
217 |
|
|
for g=1:length(temp) |
218 |
|
|
phi=temp{g}*sf; |
219 |
|
|
phil=[ phil phi(:)']; |
220 |
|
|
end |
221 |
|
|
for g=1:length(temp) |
222 |
|
|
phi=temp{g}*sf; |
223 |
|
|
phi=flipud(phi'); |
224 |
|
|
subplot(3,4,ploc(g)); |
225 |
|
|
imagesc(phi);caxis([min(phil) max(phil)]); |
226 |
|
|
end |
227 |
|
|
subplot(3,4,1); |
228 |
|
|
axis off |
229 |
|
|
caxis([min(phil) max(phil)]);colorbar; |
230 |
|
|
title(ptit); |
231 |
|
|
drawnow |
232 |
|
|
|
233 |
|
|
pnam=sprintf('%s.jpeg',ptit); |
234 |
|
|
print('-djpeg100',pnam); |
235 |
|
|
|
236 |
|
|
end |