/[MITgcm]/MITgcm_contrib/jmc_script/grph_StD.m
ViewVC logotype

Contents of /MITgcm_contrib/jmc_script/grph_StD.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Thu May 29 23:47:13 2008 UTC (15 years, 10 months ago) by jmc
Branch: MAIN
improve scripts to read & plot Stat-Diags (ascii) output files

1 Nexp=3;
2 Nc=4; nc=Nc*ones(1,Nexp); prefix='stDiag';
3 namA(1,1:Nc)='r06a';
4 namA(2,1:Nc)='r07a';
5 namA(3,1:Nc)='r07b';
6 %-
7
8 % $Header: $
9 % $Name: $
10
11
12 nItMx=1e10*ones(1,Nexp); %nItMx(3)=11;
13 %nItMx=360*ones(1,Nexp);
14 namLg=namA ; for n=1:Nexp, namLg(n,find(namLg(n,:)=='_'))='-'; end
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 %- or take all them:
29 clear listV ; listV='all_flds';
30 %-----------
31
32 %- start to read the longest record:
33 n=1; rf=-1; if strcmp(char(listV),'all_flds'), rf=0; end
34 [ntA(n),rList,tim,vv1,listV] = ...
35 read_StD(prefix,namA(n,1:nc(n)),listV);
36 nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3);
37 %- set global dims: & load vvA --> vvB
38 nbV=size(listV,2);
39 nrec=nIt; n3d=nk; nReg=nRg;
40 vvA=zeros(n3d,nrec,nReg,5,nbV,Nexp); tiA=zeros(nrec,2,Nexp);
41 vvA(1:nk,1:nIt,1:nRg,:,:,n)=vv1; tiA(1:nIt,:,n)=tim;
42 %----
43 for n=2:Nexp,
44 [ntA(n),rList,tim,vv1,listV] = ...
45 read_StD(prefix,namA(n,1:nc(n)),listV);
46 nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3);
47 if (nrec < nIt),
48 fprintf('\n');
49 error([' Nb of records=',int2str(nIt),' exceeds nrec=',int2str(nrec)]);
50 end
51 if (n3d < nk),
52 fprintf('\n');
53 error([' Nb of Levels=',int2str(nk),' exceeds n3d=',int2str(n3d)]);
54 end
55 vvA(1:nk,1:nIt,1:nRg,:,:,n)=vv1; tiA(1:nIt,:,n)=tim;
56 end;
57 if krd == 2,
58 fprintf('save to "sav_StD.mat" file ...');
59 save('sav_StD.mat','vvA','tiA','ntA','rList','listV');
60 fprintf(' done\n')
61 end
62 elseif krd < 0,
63 fprintf('load from "sav_StD.mat" file ...');
64 load sav_StD
65 fprintf(' done\n'); nbV=size(listV,2);
66 end
67 if krd ~= 0,
68 ttA=squeeze(tiA(:,2,:));
69 ttA=ttA/86400; titT='days'; ttA=ttA/30 ; titT='month'; ttA=ttA/12 ; titT='year';
70 end
71 %=========================================================
72
73 ttax1=0 ; ttax2=0 ; ttay=zeros(nbV,2);
74 %-- fixed time axis bound :
75 % ttax1=3; ttax2=3.3;
76 %-- fixed Y axis bound :
77 % ttay(4,:)=[0 0.6];
78 %-----------
79 fprintf('Total length: ntA=');fprintf(' %i ,',ntA); fprintf(' \n');
80 for n=1:Nexp,
81 fprintf(' exp %i : time(d):%10.2f ->%10.2f \n', n,ttA(1,n),ttA(ntA(n),n) );
82 end;
83 %--
84
85 list_on=zeros(1,nbV);
86 nbG=8;
87 nbG=min(nbG,nbV); list_on(1:nbG)=1 ;
88 %list_on(1:6)=[1 1 1 1 1 1];
89
90 isA=ones(1,Nexp); ieA=ntA;
91 %- limit the length : for search of isA <->1500y: find(ttA(:,2) == 1500)
92 %isA=isA*31 ; % drop the 1rst mnth (1 Monitor/d)
93 %isA=isA*36 ; % drop the 1rst year (1 Monitor/10d)
94 %isA(1)=31 ; isA(2)=4 ; % drop the 1rst mnth
95 %ieA(:)=360; isA(:)=1;
96
97 linA(1,:)='k-'; % ieA(1)=60 ; % ieA(1)=1152 ;
98 linA(2,:)='b-';
99 linA(3,:)='r-';
100 linA(4,:)='g-';
101 linA(5,:)='m-';
102 linA(6,:)='c-';
103
104 ieA=min(ieA,nItMx);
105 %titall='AIM , Cubic-G (32x32) , cpl-FM Forcing' ;
106 titall='Global Ocean, Cubic-G (32x32) , NCEP Forc (2)' ;
107
108 %=========================================================
109
110 for ng=1:nbV,
111 %-------------------
112 flag=list_on(ng); kl=0;
113 vv1=vvA(:,:,:,:,ng,:); namV=char(listV(ng));
114 titv=strrep(namV,'_','\_');
115 %if strcmp(namV,'Eta'), vv1=vv1/100; titv='Eta [mb]'; end
116 %if strcmp(namV,'T'), kl=1; end
117 %if ng == 1, flag=2*list_on(1) ; end
118 if kl > 0, titv=[titv,'\_',int2str(kl)];
119 fprintf([' var= ',namV,' at level k= %i \n'],kl);
120 end
121
122 if flag == 1
123 %--
124 figure(ng); set(ng,'position',[100+100*ng 60+40*ng 500 700]);clf;
125 % if ng == 2, var=squeeze(vv1(2,:,1,:,:)); end % to get surf.Temp
126 var=squeeze(vv1(1+kl,:,1,:,:));
127 dd=squeeze(max(var)-min(var)); av=squeeze(mean(var));
128 if Nexp == 1, av=av'; dd=dd'; end ;
129 for nv=1:4,
130 subplot(410+nv); ttmn=' Mx-mn:'; ttav=' Av:';
131 for n=1:Nexp,
132 plot(ttA(isA(n):ieA(n),n),var(isA(n):ieA(n),nv,n),linA(n,:));
133 if n == 1, hold on ; end ;
134 ttmn=sprintf([ttmn,' %2.1e ;'],dd(nv,n));
135 ttav=sprintf([ttav,' %3.2e ;'],av(nv,n));
136 end ; hold off ;
137 if ttax1 < ttax2, AA=axis; axis([ttax1 ttax2 AA(3:4)]); end;
138 AA=axis ; dAA=AA(4)-AA(3);
139 if AA(3)*AA(4) <= 0, AA(3)=min(AA(3),-dAA/10); AA(4)=max(AA(4),dAA/10); end
140 axis(AA); grid ;
141 %AA=axis; text(AA(1)*.9+AA(2)*.1,AA(3)*0.1+AA(4)*0.9,ttmn);
142 if nv == 1, title(['Avr ',titv,' ',ttmn]); end
143 if nv == 2, title(['Std-Dev ',titv,' ',ttav]); end
144 if nv == 3, title(['min ',titv,' ',ttav]); legend(namLg(1:Nexp,:),0); end
145 if nv == 4, title(['Max ',titv,' ',ttav]); end
146 %if nv == 2, title(['Del-2 ',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 %=========================================================

  ViewVC Help
Powered by ViewVC 1.1.22