| 1 | prefix='dynStD'; | 
| 2 | namA='r527'; | 
| 3 | Nexp=1; Nc=size(namA,2); | 
| 4 | %-- | 
| 5 |  | 
| 6 | % $Header: /u/gcmpack/MITgcm_contrib/jmc_script/plot_StD.m,v 1.1 2008/10/08 18:18:04 jmc Exp $ | 
| 7 | % $Name:  $ | 
| 8 |  | 
| 9 | nItMx=1e10*ones(1,Nexp); %nItMx(3)=11; | 
| 10 | %nItMx=60*ones(1,Nexp); | 
| 11 | namLg=namA ; namLg=strrep(namLg,'_','\_'); | 
| 12 | %----------- | 
| 13 | %- ngEn = Nb of Energy plot: = 2 or = 4  ; | 
| 14 | ngEn=2; | 
| 15 | %- test if the variable krd is define : | 
| 16 | if size(who('krd'),1) > 0, | 
| 17 | fprintf('krd is defined and = %i \n',krd); | 
| 18 | else | 
| 19 | fprintf('krd undefined ; set to 1 \n'); krd=1 ; | 
| 20 | end | 
| 21 | if krd > 0, | 
| 22 | %- define list of fields to read in: | 
| 23 | %listV={'Eta','U','V','W','T','S','DETADT2','RELHUM','Phi'}; | 
| 24 | %listV={'Eta','U','V','W','T','S','CONVADJ','DETADT2'}; | 
| 25 | %listV={'Eta','UE_VEL_C','VN_VEL_C','W','T','DETADT2','Phi'}; | 
| 26 | %- or take all them: | 
| 27 | clear listV ; listV='all_flds'; | 
| 28 | %----------- | 
| 29 |  | 
| 30 | %- start to read the longest record: | 
| 31 | n=1; rf=-1; if strcmp(char(listV),'all_flds'), rf=0; end | 
| 32 | [ntA(n),rList,tim,vv1,listV,kList] = ... | 
| 33 | read_StD(prefix,namA(n,:),listV); | 
| 34 | nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3); | 
| 35 | %- set global dims: & load vvA --> vvB | 
| 36 | nbV=size(listV,2); | 
| 37 | nrec=nIt; n3d=nk; nReg=nRg; | 
| 38 | vvA=zeros(n3d,nrec,nReg,5,nbV,Nexp); tiA=zeros(nrec,2,Nexp); | 
| 39 | vvA(1:nk,1:nIt,1:nRg,:,:,n)=vv1; tiA(1:nIt,:,n)=tim; | 
| 40 | %---- | 
| 41 | for n=2:Nexp, | 
| 42 | [ntA(n),rList,tim,vv1,listV] = ... | 
| 43 | read_StD(prefix,namA(n,:),listV); | 
| 44 | nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3); | 
| 45 | if (nrec < nIt), | 
| 46 | fprintf('\n'); | 
| 47 | error([' Nb of records=',int2str(nIt),' exceeds nrec=',int2str(nrec)]); | 
| 48 | end | 
| 49 | if (n3d < nk), | 
| 50 | fprintf('\n'); | 
| 51 | error([' Nb of Levels=',int2str(nk),' exceeds n3d=',int2str(n3d)]); | 
| 52 | end | 
| 53 | vvA(1:nk,1:nIt,1:nRg,:,:,n)=vv1; tiA(1:nIt,:,n)=tim; | 
| 54 | end; | 
| 55 | if krd == 2, | 
| 56 | fprintf('save to "sav_StD.mat" file ...'); | 
| 57 | save('sav_StD.mat','vvA','tiA','ntA','rList','listV'); | 
| 58 | fprintf(' done\n') | 
| 59 | end | 
| 60 | elseif krd < 0, | 
| 61 | fprintf('load from "sav_StD.mat" file ...'); | 
| 62 | load sav_StD | 
| 63 | fprintf(' done\n'); nbV=size(listV,2); | 
| 64 | end | 
| 65 | if krd ~= 0, | 
| 66 | ttA=squeeze(tiA(:,2,:)); | 
| 67 | ttA=ttA/3600; titT='hrs';  ttA=ttA/24; titT='days'; | 
| 68 | ttA=ttA/30 ; titT='month'; ttA=ttA/12 ; titT='year'; | 
| 69 | end | 
| 70 | %========================================================= | 
| 71 |  | 
| 72 | ttax1=0 ; ttax2=0 ; ttay=zeros(nbV,2); | 
| 73 | %-- fixed time axis bound : | 
| 74 | % ttax1=15.; ttax2=20.; | 
| 75 | %-- fixed Y axis bound : | 
| 76 | % ttay(4,:)=[0 0.6]; | 
| 77 | %----------- | 
| 78 | fprintf('Total length: ntA=');fprintf(' %i ,',ntA); fprintf(' \n'); | 
| 79 | for n=1:Nexp, | 
| 80 | fprintf(' exp %i : time(d):%10.2f ->%10.2f \n', n,ttA(1,n),ttA(ntA(n),n) ); | 
| 81 | end; | 
| 82 | %-- | 
| 83 |  | 
| 84 | list_on=zeros(1,nbV); | 
| 85 | nbG=8; | 
| 86 | nbG=min(nbG,nbV); list_on(1:nbG)=1 ; | 
| 87 | %list_on(1:6)=[1 1 1 1 1 1]; | 
| 88 |  | 
| 89 | isA=ones(1,Nexp); ieA=ntA; | 
| 90 | %- limit the length : for search of isA <->1500y: find(ttA(:,2) == 1500) | 
| 91 | %isA=isA*31 ; % drop the 1rst mnth (1 Monitor/d) | 
| 92 | %isA=isA*36 ; % drop the 1rst year (1 Monitor/10d) | 
| 93 | %isA(1)=31 ; isA(2)=4 ; % drop the 1rst mnth | 
| 94 | %ieA(:)=360; isA(:)=1; | 
| 95 |  | 
| 96 | linA(1,:)='k-'; % ieA(1)=60 ; % ieA(1)=1152 ; | 
| 97 | linA(2,:)='b-'; | 
| 98 | linA(3,:)='r-'; | 
| 99 | linA(4,:)='g-'; | 
| 100 | linA(5,:)='m-'; | 
| 101 | linA(6,:)='c-'; | 
| 102 |  | 
| 103 | ieA=min(ieA,nItMx); | 
| 104 | %titall='AIM , Cubic-G (32x32) , cpl-FM Forcing' ; | 
| 105 | %titall='Global Ocean, Cubic-G (32x32) , NCEP Forc (2)' ; | 
| 106 | titall=['Exp: ',namLg(1,:)]; | 
| 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 strcmp(namV,'T'), | 
| 118 | namfil=['../res_',namA(2:end),'/RC']; D=dir([namfil,'.data']); | 
| 119 | if size(D,1) == 1, | 
| 120 | rC=rdmds(namfil); | 
| 121 | fprintf(' convert Pot.Temp to Temp.:'); | 
| 122 | %    fprintf(' convert Pot.Temp to Temp.:'); fprintf(' %i',size(vv1)); | 
| 123 | kappa=2/7; facP=squeeze(rC)/1.e+5; facP=facP.^kappa; | 
| 124 | var=facP*ones(1,nrec*4*Nexp); var=reshape(var,[nk-1 nrec 1 4 Nexp]); | 
| 125 | vv1([2:nk],:,1,[1:4],:)=vv1([2:nk],:,1,[1:4],:).*var; | 
| 126 | %    for k=2:nk, vv1(k,:,1,[1:4],:)=vv1(k,:,1,[1:4],:)*facP(k-1); end | 
| 127 | fprintf(' OK\n'); | 
| 128 | else | 
| 129 | fprintf(' no file: %s\n',namfil); | 
| 130 | end | 
| 131 | end | 
| 132 | %if ng == 1, flag=2*list_on(1) ; end | 
| 133 | if kl > 0, titv=[titv,'\_',int2str(kl)]; | 
| 134 | fprintf([' var= ',namV,' at level k= %i \n'],kl); | 
| 135 | end | 
| 136 |  | 
| 137 | if flag == 1 | 
| 138 | %-- | 
| 139 | figure(ng); set(ng,'position',[100+100*ng 60+40*ng 500 700]);clf; | 
| 140 | % if ng == 2, var=squeeze(vv1(2,:,1,:,:)); end % to get surf.Temp | 
| 141 | if kList(ng) == 1, | 
| 142 | var=squeeze(vv1(1+kl,:,1,:,:)); | 
| 143 | dd=squeeze(max(var)-min(var)); av=squeeze(mean(var)); | 
| 144 | if Nexp == 1, av=av'; dd=dd'; end ; | 
| 145 | for nv=1:4, | 
| 146 | subplot(410+nv); ttmn=' Mx-mn:'; ttav=' Av:'; | 
| 147 | for n=1:Nexp, | 
| 148 | plot(ttA(isA(n):ieA(n),n),var(isA(n):ieA(n),nv,n),linA(n,:)); | 
| 149 | if n == 1, hold on ; end ; | 
| 150 | ttmn=sprintf([ttmn,' %2.1e ;'],dd(nv,n)); | 
| 151 | ttav=sprintf([ttav,' %3.2e ;'],av(nv,n)); | 
| 152 | end ; hold off ; | 
| 153 | AA=axis ; dAA=AA(4)-AA(3); | 
| 154 | if AA(3)*AA(4) <= 0, AA(3)=min(AA(3),-dAA/10); AA(4)=max(AA(4),dAA/10); end | 
| 155 | if ttax1 < ttax2, AA(1)=ttax1; AA(2)=ttax2; end; | 
| 156 | axis(AA); grid ; | 
| 157 | if nv == 1, title(['Avr ',titv,'  ',ttmn]); end | 
| 158 | if nv == 2, title(['Std-Dev ',titv,'  ',ttav]); end | 
| 159 | if nv == 3, title(['min ',titv,'  ',ttav]); legend(namLg(1:Nexp,:),0); end | 
| 160 | if nv == 4, title(['Max ',titv,'  ',ttav]); end | 
| 161 | %if nv == 2, title(['Del-2 ',titv,'  ',ttav]); end | 
| 162 | end ; xlabel(titT); | 
| 163 | else | 
| 164 | n=1; | 
| 165 | for nv=1:4, | 
| 166 | subplot(410+nv); | 
| 167 | var=squeeze(vv1(2:nk,:,1,nv,n))'; | 
| 168 | mnV=min(var(:)); MxV=max(var(:)); ccv=c_levs(mnV,MxV,-12); | 
| 169 | %- pressure coordinate, from bottom (k=1) to top (k=nr=nk-1) | 
| 170 | %[cs,h]=contour(ttA(isA(n):ieA(n),n),[1:nk-1],var(isA(n):ieA(n),:)',ccv); | 
| 171 | %- z coordinate, from bottom (k=nr=nk-1) to top (k=1) | 
| 172 | [cs,h]=contour(ttA(isA(n):ieA(n),n),-[1:nk-1],var(isA(n):ieA(n),:)',ccv); | 
| 173 | %clabel(cs);isoline0(h); | 
| 174 | colorbar; | 
| 175 | if nv == 1, title(['Avr ',titv]); end | 
| 176 | if nv == 2, title(['Std-Dev ',titv]); end | 
| 177 | if nv == 3, title(['min ',titv]); ; end | 
| 178 | if nv == 4, title(['Max ',titv]); end | 
| 179 | AA=axis; dAA=AA(4)-AA(3); | 
| 180 | ttmn=sprintf('mn= %4.3g , Mx= %4.3g',mnV,MxV); | 
| 181 | text(AA(1)*.4+AA(2)*.6,AA(3)-0.27*dAA,ttmn); | 
| 182 | end ; xlabel(titT); | 
| 183 | end | 
| 184 | %-- | 
| 185 | axes('position',[.01,.01,.99,.99],'Visible','off'); | 
| 186 | T=text(0.5,0.97,titall); | 
| 187 | set(T,'HorizontalAlignment','center','FontSize',12); | 
| 188 | Td=text(0.99,0.01,date); | 
| 189 | set(Td,'HorizontalAlignment','right','FontSize',6); | 
| 190 | %--- | 
| 191 | end | 
| 192 |  | 
| 193 | %------------------- | 
| 194 | end | 
| 195 |  | 
| 196 | %========================================================= |