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

Diff of /MITgcm_contrib/jmc_script/plot_StD.m

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

revision 1.2 by jmc, Fri Sep 27 23:11:26 2013 UTC revision 1.5 by jmc, Sun Sep 6 18:15:09 2015 UTC
# Line 1  Line 1 
1   prefix='dynStD';   prefix='dynStD';
2   namA='r527';  %prefix='oceStD';
3     pCoords=0;
4     namA='c06';
5   Nexp=1; Nc=size(namA,2);   Nexp=1; Nc=size(namA,2);
6     nAvr=1;
7    %- to plot annual mean instead of 10.d aver:
8    %nAvr=36;
9  %--  %--
10    
11  % $Header$  % $Header$
# Line 9  Line 14 
14  nItMx=1e10*ones(1,Nexp); %nItMx(3)=11;  nItMx=1e10*ones(1,Nexp); %nItMx(3)=11;
15  %nItMx=60*ones(1,Nexp);  %nItMx=60*ones(1,Nexp);
16  namLg=namA ; namLg=strrep(namLg,'_','\_');  namLg=namA ; namLg=strrep(namLg,'_','\_');
17    undef=123456.7;
18  %-----------  %-----------
 %- ngEn = Nb of Energy plot: = 2 or = 4  ;  
 ngEn=2;  
19  %- test if the variable krd is define :  %- test if the variable krd is define :
20  if size(who('krd'),1) > 0,  if size(who('krd'),1) > 0,
21   fprintf('krd is defined and = %i \n',krd);   fprintf('krd is defined and = %i \n',krd);
# Line 32  if krd > 0, Line 36  if krd > 0,
36    [ntA(n),rList,tim,vv1,listV,kList] = ...    [ntA(n),rList,tim,vv1,listV,kList] = ...
37      read_StD(prefix,namA(n,:),listV);      read_StD(prefix,namA(n,:),listV);
38    nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3);    nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3);
39      vv1(find(vv1==undef))=NaN;
40  %- set global dims: & load vvA --> vvB  %- set global dims: & load vvA --> vvB
41    nbV=size(listV,2);    nbV=size(listV,2);
42    nrec=nIt; n3d=nk; nReg=nRg;    nrec=nIt; n3d=nk; nReg=nRg;
# Line 42  if krd > 0, Line 47  if krd > 0,
47    [ntA(n),rList,tim,vv1,listV] = ...    [ntA(n),rList,tim,vv1,listV] = ...
48      read_StD(prefix,namA(n,:),listV);      read_StD(prefix,namA(n,:),listV);
49    nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3);    nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3);
50      vv1(find(vv1==undef))=NaN;
51    if (nrec < nIt),    if (nrec < nIt),
52      fprintf('\n');      fprintf('\n');
53      error([' Nb of records=',int2str(nIt),' exceeds nrec=',int2str(nrec)]);      error([' Nb of records=',int2str(nIt),' exceeds nrec=',int2str(nrec)]);
# Line 56  if krd > 0, Line 62  if krd > 0,
62     fprintf('save to "sav_StD.mat" file ...');     fprintf('save to "sav_StD.mat" file ...');
63     save('sav_StD.mat','vvA','tiA','ntA','rList','listV');     save('sav_StD.mat','vvA','tiA','ntA','rList','listV');
64     fprintf(' done\n')     fprintf(' done\n')
65   end   end
66  elseif krd < 0,  elseif krd < 0,
67   fprintf('load from "sav_StD.mat" file ...');   fprintf('load from "sav_StD.mat" file ...');
68   load sav_StD   load sav_StD
# Line 64  elseif krd < 0, Line 70  elseif krd < 0,
70  end  end
71  if krd ~= 0,  if krd ~= 0,
72   ttA=squeeze(tiA(:,2,:));   ttA=squeeze(tiA(:,2,:));
73   ttA=ttA/3600; titT='hrs';  ttA=ttA/24; titT='days';   ttA=ttA/3600; titT='hrs';  ttA=ttA/24 ; titT='days';
74   ttA=ttA/30 ; titT='month'; ttA=ttA/12 ; titT='year';   ttA=ttA/30 ; titT='month'; ttA=ttA/12 ; titT='year';
75    %- change to plot annual mean:
76     if nAvr > 1 & rem(nrec,nAvr)==0,
77      nrec=nrec/nAvr; ntA=ntA/nAvr;
78      vvA=reshape(   vvA,[n3d nAvr nrec nReg 5 nbV Nexp]);
79      vvA=reshape(mean(vvA,2),[n3d nrec nReg 5 nbV Nexp]);
80      ttA=reshape(   ttA,[nAvr nrec Nexp]);
81      ttA=reshape(mean(ttA,1),[nrec Nexp]);
82     end
83  end  end
84  %=========================================================  %=========================================================
85    
# Line 79  fprintf('Total length: ntA=');fprintf(' Line 93  fprintf('Total length: ntA=');fprintf('
93  for n=1:Nexp,  for n=1:Nexp,
94  fprintf(' exp %i : time(d):%10.2f ->%10.2f \n', n,ttA(1,n),ttA(ntA(n),n) );  fprintf(' exp %i : time(d):%10.2f ->%10.2f \n', n,ttA(1,n),ttA(ntA(n),n) );
95  end;  end;
96  %--  %-
97    
98  list_on=zeros(1,nbV);  list_on=zeros(1,nbV);
99  nbG=8;  nbG=10;
100  nbG=min(nbG,nbV); list_on(1:nbG)=1 ;  nbG=min(nbG,nbV); list_on(1:nbG)=1 ;
101  %list_on(1:6)=[1 1 1 1 1 1];  %list_on(1:6)=[1 1 1 1 1 1];
102    %list_on(5:7)=0;
103    
104  isA=ones(1,Nexp); ieA=ntA;  isA=ones(1,Nexp); ieA=ntA;
105  %- limit the length : for search of isA <->1500y: find(ttA(:,2) == 1500)  %- limit the length : for search of isA <->1500y: find(ttA(:,2) == 1500)
106  %isA=isA*31 ; % drop the 1rst mnth (1 Monitor/d)  %isA=isA*3 ; % drop the 1rst mnth (1 Monitor/10.d)
 %isA=isA*36 ; % drop the 1rst year (1 Monitor/10d)  
 %isA(1)=31 ; isA(2)=4 ; % drop the 1rst mnth  
107  %ieA(:)=360; isA(:)=1;  %ieA(:)=360; isA(:)=1;
108    
109  linA(1,:)='k-'; % ieA(1)=60 ; % ieA(1)=1152 ;  linA(1,:)='k-'; % ieA(1)=60 ; % ieA(1)=1152 ;
# Line 101  linA(5,:)='m-'; Line 114  linA(5,:)='m-';
114  linA(6,:)='c-';  linA(6,:)='c-';
115    
116  ieA=min(ieA,nItMx);  ieA=min(ieA,nItMx);
 %titall='AIM , Cubic-G (32x32) , cpl-FM Forcing' ;  
 %titall='Global Ocean, Cubic-G (32x32) , NCEP Forc (2)' ;  
117  titall=['Exp: ',namLg(1,:)];  titall=['Exp: ',namLg(1,:)];
118    
119  %=========================================================  %=========================================================
120    
121    %-default: dxRed=0; dyRed=0; dxB=0.1; dyB=0.9;
122    dxRed=0; dyRed=0.03; dxB=0.02; dyB=0.9;
123    [xyP,xyB]=def_subP(-4,dxRed,dyRed,dxB,dyB);
124    xyP(:,2)=xyP(:,2)+0.010;
125    xyB(:,2)=xyB(:,2)+0.010;
126    
127    fxb=100; fyb=60;
128    %fxb=-2600; fyb=160; %fxb=100;
129    
130  for ng=1:nbV,  for ng=1:nbV,
131  %-------------------  %-------------------
132   flag=list_on(ng); kl=0;   yax=[1:nk-1]; if pCoords == 0, yax=-[1:nk-1]; end
133     flag=list_on(ng);
134   vv1=vvA(:,:,:,:,ng,:); namV=char(listV(ng));   vv1=vvA(:,:,:,:,ng,:); namV=char(listV(ng));
135   titv=strrep(namV,'_','\_');   titv=strrep(namV,'_','\_');
136  %if strcmp(namV,'Eta'), vv1=vv1/100; titv='Eta [mb]'; end   if strcmp(namV,'Eta') & pCoords == 1, vv1=vv1/100; titv='Eta [mb]'; end
137  %if strcmp(namV,'T'), kl=1; end   if strcmp(namV,'T') & pCoords == 1,
138   if strcmp(namV,'T'),     namfil=['../res_',namA(1:end),'/RC']; D=dir([namfil,'.data']);
    namfil=['../res_',namA(2:end),'/RC']; D=dir([namfil,'.data']);  
139     if size(D,1) == 1,     if size(D,1) == 1,
140       rC=rdmds(namfil);       rC=rdmds(namfil);
141       fprintf(' convert Pot.Temp to Temp.:');       fprintf(' convert Pot.Temp to Temp.:');
# Line 129  for ng=1:nbV, Line 149  for ng=1:nbV,
149       fprintf(' no file: %s\n',namfil);       fprintf(' no file: %s\n',namfil);
150     end     end
151   end   end
 %if ng == 1, flag=2*list_on(1) ; end  
  if kl > 0, titv=[titv,'\_',int2str(kl)];  
    fprintf([' var= ',namV,' at level k= %i \n'],kl);  
  end  
152    
153   if flag == 1   if flag == 1
154  %--  %--
155    figure(ng); set(ng,'position',[100+100*ng 60+40*ng 500 700]);clf;    figure(ng); set(ng,'position',[fxb+100*ng fyb+40*ng 500 700]);clf;
156  % if ng == 2, var=squeeze(vv1(2,:,1,:,:)); end % to get surf.Temp    colormap jet
157    if kList(ng) == 1,    if kList(ng) == 1,
158     var=squeeze(vv1(1+kl,:,1,:,:));     var=squeeze(vv1(1,:,1,:,:));
159     dd=squeeze(max(var)-min(var)); av=squeeze(mean(var));     dd=squeeze(max(var)-min(var)); av=squeeze(mean(var));
160     if Nexp == 1, av=av'; dd=dd'; end ;     if Nexp == 1, av=av'; dd=dd'; end ;
161     for nv=1:4,     for nv=1:4,
162      subplot(410+nv); ttmn=' Mx-mn:'; ttav=' Av:';      axes('position',xyP(nv,:)); ttmn=' Mx-mn:'; ttav=' Av:';
163      for n=1:Nexp,      for n=1:Nexp,
164        plot(ttA(isA(n):ieA(n),n),var(isA(n):ieA(n),nv,n),linA(n,:));        plot(ttA(isA(n):ieA(n),n),var(isA(n):ieA(n),nv,n),linA(n,:));
165        if n == 1, hold on ; end ;        if n == 1, hold on ; end ;
# Line 152  for ng=1:nbV, Line 168  for ng=1:nbV,
168      end ; hold off ;      end ; hold off ;
169      AA=axis ; dAA=AA(4)-AA(3);      AA=axis ; dAA=AA(4)-AA(3);
170      if AA(3)*AA(4) <= 0, AA(3)=min(AA(3),-dAA/10); AA(4)=max(AA(4),dAA/10); end      if AA(3)*AA(4) <= 0, AA(3)=min(AA(3),-dAA/10); AA(4)=max(AA(4),dAA/10); end
171      if ttax1 < ttax2, AA(1)=ttax1; AA(2)=ttax2; end;      if ttax1 < ttax2, AA(1)=ttax1; AA(2)=ttax2; end;
172      axis(AA); grid ;      axis(AA); grid ;
173      if nv == 1, title(['Avr ',titv,'  ',ttmn]); end      if nv == 1, title(['Avr ',titv,'  ',ttmn]); xlabel(titT); end
174      if nv == 2, title(['Std-Dev ',titv,'  ',ttav]); end      if nv == 2, title(['Std-Dev ',titv,'  ',ttav]); end
175      if nv == 3, title(['min ',titv,'  ',ttav]); legend(namLg(1:Nexp,:),0); end      if nv == 3, title(['min ',titv,'  ',ttav]); legend(namLg(1:Nexp,:),0); end
176      if nv == 4, title(['Max ',titv,'  ',ttav]); end      if nv == 4, title(['Max ',titv,'  ',ttav]); end
177     %if nv == 2, title(['Del-2 ',titv,'  ',ttav]); end     %if nv == 2, title(['Del-2 ',titv,'  ',ttav]); end
178     end ; xlabel(titT);     end ; %xlabel(titT);
179    else    else
180     n=1;     n=1; k1=2;
181       if strcmp(namV,'CONVADJ') || strcmp(namV,'DRHODR'),
182         k1=3; yax=yax(2:nk-1);
183       end
184     for nv=1:4,     for nv=1:4,
185      subplot(410+nv);      axes('position',xyP(nv,:));
186      var=squeeze(vv1(2:nk,:,1,nv,n))';      var=squeeze(vv1(k1:nk,:,1,nv,n))'; mnV=min(var(:)); MxV=max(var(:));
187      mnV=min(var(:)); MxV=max(var(:)); ccv=c_levs(mnV,MxV,-12);      ccv=c_levs(mnV,MxV,-12); %ccv=c_levs(mnV,MxV,-20);
188     %- pressure coordinate, from bottom (k=1) to top (k=nr=nk-1)      if MxV > mnV,
189     %[cs,h]=contour(ttA(isA(n):ieA(n),n),[1:nk-1],var(isA(n):ieA(n),:)',ccv);       [cs,h]=contour(ttA(isA(n):ieA(n),n),yax,var(isA(n):ieA(n),:)',ccv);
190     %- z coordinate, from bottom (k=nr=nk-1) to top (k=1)      %clabel(cs);isoline0(h);
191      [cs,h]=contour(ttA(isA(n):ieA(n),n),-[1:nk-1],var(isA(n):ieA(n),:)',ccv);       BB=colorbar; set(BB,'Position',xyB(nv,:));
192     %clabel(cs);isoline0(h);      end
193      colorbar;      if nv == 1, title(['Avr ',titv]); xlabel(titT); end
     if nv == 1, title(['Avr ',titv]); end  
194      if nv == 2, title(['Std-Dev ',titv]); end      if nv == 2, title(['Std-Dev ',titv]); end
195      if nv == 3, title(['min ',titv]); ; end      if nv == 3, title(['min ',titv]); ; end
196      if nv == 4, title(['Max ',titv]); end      if nv == 4, title(['Max ',titv]); end
197      AA=axis; dAA=AA(4)-AA(3);      AA=axis; dAA=AA(4)-AA(3);
198      ttmn=sprintf('mn= %4.3g , Mx= %4.3g',mnV,MxV);      ttmn=sprintf('mn= %4.3g , Mx= %4.3g',mnV,MxV);
199      text(AA(1)*.4+AA(2)*.6,AA(3)-0.27*dAA,ttmn);      text(AA(1)*.4+AA(2)*.6,AA(3)-0.20*dAA,ttmn);
200     end ; xlabel(titT);     end ; %xlabel(titT);
201    end    end
202  %--  %--
203    axes('position',[.01,.01,.99,.99],'Visible','off');    axes('position',[.01,.01,.99,.99],'Visible','off');
204    T=text(0.5,0.97,titall);    T=text(0.2,0.98,titall);
205    set(T,'HorizontalAlignment','center','FontSize',12);    set(T,'HorizontalAlignment','center','FontSize',12);
206    Td=text(0.99,0.01,date);    Td=text(0.01,0.01,date);
207    set(Td,'HorizontalAlignment','right','FontSize',6);    set(Td,'HorizontalAlignment','left','FontSize',6);
208  %---  %---
209   end   end
210    
211  %-------------------  %-------------------
212  end  end
213    
214  %=========================================================  %=========================================================

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.22