1 |
prefix='stDiag'; |
2 |
namA={'mG_2','vmUpW'}; |
3 |
%namA=char{'r525','r526','r527','r528'}; |
4 |
Nexp=size(namA,2); |
5 |
%- |
6 |
%namA(2)={'r528'}; |
7 |
|
8 |
% $Header: /u/gcmpack/MITgcm_contrib/jmc_script/grph_StD.m,v 1.1 2008/05/29 23:47:13 jmc Exp $ |
9 |
% $Name: $ |
10 |
|
11 |
|
12 |
nItMx=1e10*ones(1,Nexp); %nItMx(3)=11; |
13 |
%nItMx=60*ones(1,Nexp); |
14 |
namLg=namA ; namLg=strrep(namLg,'_','\_'); |
15 |
%----------- |
16 |
%- ngEn = Nb of Energy plot: = 2 or = 4 ; |
17 |
ngEn=2; |
18 |
%- test if the variable krd is define : |
19 |
if size(who('krd'),1) > 0, |
20 |
fprintf('krd is defined and = %i \n',krd); |
21 |
else |
22 |
fprintf('krd undefined ; set to 1 \n'); krd=1 ; |
23 |
end |
24 |
if krd > 0, |
25 |
%- define list of fields to read in: |
26 |
%listV={'Eta','U','V','W','T','S','DETADT2','RELHUM','Phi'}; |
27 |
%listV={'Eta','U','V','W','T','S','CONVADJ','DETADT2'}; |
28 |
%listV={'Eta','UE_VEL_C','VN_VEL_C','W','T','DETADT2','Phi'}; |
29 |
%- or take all them: |
30 |
clear listV ; listV='all_flds'; |
31 |
%----------- |
32 |
|
33 |
%- start to read the longest record: |
34 |
n=1; rf=-1; if strcmp(char(listV),'all_flds'), rf=0; end |
35 |
[ntA(n),rList,tim,vv1,listV] = ... |
36 |
read_StD(prefix,namA(n),listV); |
37 |
nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3); |
38 |
%- set global dims: & load vvA --> vvB |
39 |
nbV=size(listV,2); |
40 |
nrec=nIt; n3d=nk; nReg=nRg; |
41 |
vvA=zeros(n3d,nrec,nReg,5,nbV,Nexp); tiA=zeros(nrec,2,Nexp); |
42 |
vvA(1:nk,1:nIt,1:nRg,:,:,n)=vv1; tiA(1:nIt,:,n)=tim; |
43 |
%---- |
44 |
for n=2:Nexp, |
45 |
[ntA(n),rList,tim,vv1,listV] = ... |
46 |
read_StD(prefix,namA(n),listV); |
47 |
nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3); |
48 |
if (nrec < nIt), |
49 |
fprintf('\n'); |
50 |
error([' Nb of records=',int2str(nIt),' exceeds nrec=',int2str(nrec)]); |
51 |
end |
52 |
if (n3d < nk), |
53 |
fprintf('\n'); |
54 |
error([' Nb of Levels=',int2str(nk),' exceeds n3d=',int2str(n3d)]); |
55 |
end |
56 |
vvA(1:nk,1:nIt,1:nRg,:,:,n)=vv1; tiA(1:nIt,:,n)=tim; |
57 |
end; |
58 |
if krd == 2, |
59 |
fprintf('save to "sav_StD.mat" file ...'); |
60 |
save('sav_StD.mat','vvA','tiA','ntA','rList','listV'); |
61 |
fprintf(' done\n') |
62 |
end |
63 |
elseif krd < 0, |
64 |
fprintf('load from "sav_StD.mat" file ...'); |
65 |
load sav_StD |
66 |
fprintf(' done\n'); nbV=size(listV,2); |
67 |
end |
68 |
if krd ~= 0, |
69 |
ttA=squeeze(tiA(:,2,:)); |
70 |
ttA=ttA/86400; titT='days'; %ttA=ttA/30 ; titT='month'; ttA=ttA/12 ; titT='year'; |
71 |
end |
72 |
%========================================================= |
73 |
|
74 |
ttax1=0 ; ttax2=0 ; ttay=zeros(nbV,2); |
75 |
%-- fixed time axis bound : |
76 |
% ttax1=15.; ttax2=20.; |
77 |
%-- fixed Y axis bound : |
78 |
% ttay(4,:)=[0 0.6]; |
79 |
%----------- |
80 |
fprintf('Total length: ntA=');fprintf(' %i ,',ntA); fprintf(' \n'); |
81 |
for n=1:Nexp, |
82 |
fprintf(' exp %i : time(d):%10.2f ->%10.2f \n', n,ttA(1,n),ttA(ntA(n),n) ); |
83 |
end; |
84 |
%-- |
85 |
|
86 |
list_on=zeros(1,nbV); |
87 |
nbG=8; |
88 |
nbG=min(nbG,nbV); list_on(1:nbG)=1 ; |
89 |
%list_on(1:6)=[1 1 1 1 1 1]; |
90 |
|
91 |
isA=ones(1,Nexp); ieA=ntA; |
92 |
%- limit the length : for search of isA <->1500y: find(ttA(:,2) == 1500) |
93 |
%isA=isA*31 ; % drop the 1rst mnth (1 Monitor/d) |
94 |
%isA=isA*36 ; % drop the 1rst year (1 Monitor/10d) |
95 |
%isA(1)=31 ; isA(2)=4 ; % drop the 1rst mnth |
96 |
%ieA(:)=360; isA(:)=1; |
97 |
|
98 |
linA(1,:)='k-'; % ieA(1)=60 ; % ieA(1)=1152 ; |
99 |
linA(2,:)='b-'; |
100 |
linA(3,:)='r-'; |
101 |
linA(4,:)='g-'; |
102 |
linA(5,:)='m-'; |
103 |
linA(6,:)='c-'; |
104 |
|
105 |
ieA=min(ieA,nItMx); |
106 |
%titall='AIM , Cubic-G (32x32) , cpl-FM Forcing' ; |
107 |
titall='Global Ocean, Cubic-G (32x32) , NCEP Forc (2)' ; |
108 |
%titall='Dyncore test-case 5 (cs-32)' ; |
109 |
|
110 |
%========================================================= |
111 |
|
112 |
for ng=1:nbV, |
113 |
%------------------- |
114 |
flag=list_on(ng); kl=0; |
115 |
vv1=vvA(:,:,:,:,ng,:); namV=char(listV(ng)); |
116 |
titv=strrep(namV,'_','\_'); |
117 |
%if strcmp(namV,'Eta'), vv1=vv1/100; titv='Eta [mb]'; end |
118 |
%if strcmp(namV,'T'), kl=1; end |
119 |
%if ng == 1, flag=2*list_on(1) ; end |
120 |
if kl > 0, titv=[titv,'\_',int2str(kl)]; |
121 |
fprintf([' var= ',namV,' at level k= %i \n'],kl); |
122 |
end |
123 |
|
124 |
if flag == 1 |
125 |
%-- |
126 |
figure(ng); set(ng,'position',[100+100*ng 60+40*ng 500 700]);clf; |
127 |
% if ng == 2, var=squeeze(vv1(2,:,1,:,:)); end % to get surf.Temp |
128 |
var=squeeze(vv1(1+kl,:,1,:,:)); |
129 |
dd=squeeze(max(var)-min(var)); av=squeeze(mean(var)); |
130 |
if Nexp == 1, av=av'; dd=dd'; end ; |
131 |
for nv=1:4, |
132 |
subplot(410+nv); ttmn=' Mx-mn:'; ttav=' Av:'; |
133 |
for n=1:Nexp, |
134 |
plot(ttA(isA(n):ieA(n),n),var(isA(n):ieA(n),nv,n),linA(n,:)); |
135 |
if n == 1, hold on ; end ; |
136 |
ttmn=sprintf([ttmn,' %2.1e ;'],dd(nv,n)); |
137 |
ttav=sprintf([ttav,' %3.2e ;'],av(nv,n)); |
138 |
end ; hold off ; |
139 |
AA=axis ; dAA=AA(4)-AA(3); |
140 |
if AA(3)*AA(4) <= 0, AA(3)=min(AA(3),-dAA/10); AA(4)=max(AA(4),dAA/10); end |
141 |
if ttax1 < ttax2, AA(1)=ttax1; AA(2)=ttax2; end; |
142 |
axis(AA); grid ; |
143 |
if nv == 1, title(['Avr ',titv,' ',ttmn]); end |
144 |
if nv == 2, title(['Std-Dev ',titv,' ',ttav]); end |
145 |
if nv == 3, title(['min ',titv,' ',ttav]); legend(namLg,0); end |
146 |
if nv == 4, title(['Max ',titv,' ',ttav]); end |
147 |
end ; xlabel(titT); |
148 |
%-- |
149 |
axes('position',[.01,.01,.99,.99],'Visible','off'); |
150 |
T=text(0.5,0.97,titall); |
151 |
set(T,'HorizontalAlignment','center','FontSize',12); |
152 |
Td=text(0.99,0.01,date); |
153 |
set(Td,'HorizontalAlignment','right','FontSize',6); |
154 |
%--- |
155 |
end |
156 |
|
157 |
%------------------- |
158 |
end |
159 |
|
160 |
%========================================================= |