| 1 | jmc | 1.3 | prefix='dynStD'; | 
| 2 | jmc | 1.5 | namA={'g02','b02'}; | 
| 3 |  |  | %namA={'r17a'}; | 
| 4 | jmc | 1.2 | Nexp=size(namA,2); | 
| 5 | jmc | 1.1 | %- | 
| 6 |  |  |  | 
| 7 | jmc | 1.6 | % $Header: /u/gcmpack/MITgcm_contrib/jmc_script/grph_StD.m,v 1.5 2014/08/25 21:35:12 jmc Exp $ | 
| 8 | jmc | 1.1 | % $Name:  $ | 
| 9 |  |  |  | 
| 10 |  |  | nItMx=1e10*ones(1,Nexp); %nItMx(3)=11; | 
| 11 | jmc | 1.3 | nItMx=2400*ones(1,Nexp); | 
| 12 | jmc | 1.2 | namLg=namA ; namLg=strrep(namLg,'_','\_'); | 
| 13 | jmc | 1.6 | undef=123456.7; | 
| 14 | jmc | 1.1 | %----------- | 
| 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 | jmc | 1.4 | %listV={'Eta','W','T','S','CONVADJ','DETADT2'}; | 
| 25 | jmc | 1.2 | %listV={'Eta','UE_VEL_C','VN_VEL_C','W','T','DETADT2','Phi'}; | 
| 26 | jmc | 1.1 | %- or take all them: | 
| 27 | jmc | 1.4 | clear listV ; listV='all_flds'; | 
| 28 | jmc | 1.1 | %----------- | 
| 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] = ... | 
| 33 | jmc | 1.2 | read_StD(prefix,namA(n),listV); | 
| 34 | jmc | 1.1 | nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3); | 
| 35 | jmc | 1.6 | vv1(find(vv1==undef))=NaN; | 
| 36 | jmc | 1.1 | %- set global dims: & load vvA --> vvB | 
| 37 |  |  | nbV=size(listV,2); | 
| 38 |  |  | nrec=nIt; n3d=nk; nReg=nRg; | 
| 39 |  |  | vvA=zeros(n3d,nrec,nReg,5,nbV,Nexp); tiA=zeros(nrec,2,Nexp); | 
| 40 |  |  | vvA(1:nk,1:nIt,1:nRg,:,:,n)=vv1; tiA(1:nIt,:,n)=tim; | 
| 41 |  |  | %---- | 
| 42 |  |  | for n=2:Nexp, | 
| 43 |  |  | [ntA(n),rList,tim,vv1,listV] = ... | 
| 44 | jmc | 1.2 | read_StD(prefix,namA(n),listV); | 
| 45 | jmc | 1.1 | nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3); | 
| 46 | jmc | 1.6 | vv1(find(vv1==undef))=NaN; | 
| 47 | jmc | 1.1 | 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 | jmc | 1.5 | end | 
| 62 | jmc | 1.1 | 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 | jmc | 1.4 | ttA=ttA/3600; titT='hrs';  ttA=ttA/24; titT='days'; | 
| 70 |  |  | ttA=ttA/30 ; titT='month'; ttA=ttA/12 ; titT='year'; | 
| 71 | jmc | 1.1 | end | 
| 72 |  |  | %========================================================= | 
| 73 |  |  |  | 
| 74 |  |  | ttax1=0 ; ttax2=0 ; ttay=zeros(nbV,2); | 
| 75 |  |  | %-- fixed time axis bound : | 
| 76 | jmc | 1.2 | % ttax1=15.; ttax2=20.; | 
| 77 | jmc | 1.1 | %-- 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 | jmc | 1.5 | %if nbG < nbV, list_on=0; list_on(nbG:nbV)=1; end %- to get 2nd set of plots | 
| 90 | jmc | 1.1 | %list_on(1:6)=[1 1 1 1 1 1]; | 
| 91 |  |  |  | 
| 92 |  |  | isA=ones(1,Nexp); ieA=ntA; | 
| 93 | jmc | 1.5 | %- limit the length : for search of isA <->1500y: find(ttA(:,2) == 1500) | 
| 94 | jmc | 1.1 | %isA=isA*31 ; % drop the 1rst mnth (1 Monitor/d) | 
| 95 | jmc | 1.3 | isA=isA*2 ; % drop the 1rst mnth (1 Monitor/30d) | 
| 96 | jmc | 1.1 | %isA(1)=31 ; isA(2)=4 ; % drop the 1rst mnth | 
| 97 | jmc | 1.3 | %ieA(:)=240; %isA(:)=1; | 
| 98 | jmc | 1.1 |  | 
| 99 |  |  | linA(1,:)='k-'; % ieA(1)=60 ; % ieA(1)=1152 ; | 
| 100 |  |  | linA(2,:)='b-'; | 
| 101 |  |  | linA(3,:)='r-'; | 
| 102 |  |  | linA(4,:)='g-'; | 
| 103 |  |  | linA(5,:)='m-'; | 
| 104 |  |  | linA(6,:)='c-'; | 
| 105 |  |  |  | 
| 106 |  |  | ieA=min(ieA,nItMx); | 
| 107 | jmc | 1.5 | %titall='AIM , Cubic-G (32x32) , cpl-FM Forcing' ; | 
| 108 | jmc | 1.3 | titall='Global Ocean, Cubic-G (32x32) , CORE Forc (2)' ; | 
| 109 | jmc | 1.2 | %titall='Dyncore test-case 5 (cs-32)' ; | 
| 110 | jmc | 1.1 |  | 
| 111 |  |  | %========================================================= | 
| 112 | jmc | 1.5 |  | 
| 113 |  |  | ng=0; | 
| 114 |  |  | for jv=1:nbV, | 
| 115 | jmc | 1.1 | %------------------- | 
| 116 | jmc | 1.5 | flag=list_on(jv); kl=0; | 
| 117 |  |  | vv1=vvA(:,:,:,:,jv,:); namV=char(listV(jv)); | 
| 118 | jmc | 1.1 | titv=strrep(namV,'_','\_'); | 
| 119 |  |  | %if strcmp(namV,'Eta'), vv1=vv1/100; titv='Eta [mb]'; end | 
| 120 | jmc | 1.3 | %if strcmp(namV,'T'), kl=1; end         % <-- to get surf.Temp | 
| 121 | jmc | 1.1 | if kl > 0, titv=[titv,'\_',int2str(kl)]; | 
| 122 |  |  | fprintf([' var= ',namV,' at level k= %i \n'],kl); | 
| 123 |  |  | end | 
| 124 |  |  |  | 
| 125 |  |  | if flag == 1 | 
| 126 |  |  | %-- | 
| 127 | jmc | 1.5 | ng=ng+1; | 
| 128 |  |  | %- reset "ng" to jv for fix fig number (independent of which one is in list_on): | 
| 129 |  |  | %ng=jv; | 
| 130 | jmc | 1.1 | figure(ng); set(ng,'position',[100+100*ng 60+40*ng 500 700]);clf; | 
| 131 | jmc | 1.3 | var=squeeze(vv1(1+kl,:,1,:,:)); dd=zeros(5,Nexp); av=zeros(5,Nexp); | 
| 132 |  |  | for n=1:Nexp, | 
| 133 |  |  | dd(:,n)=max(var(isA(n):ieA(n),:,n))-min(var(isA(n):ieA(n),:,n)); | 
| 134 |  |  | av(:,n)=mean(var(isA(n):ieA(n),:,n)); | 
| 135 |  |  | end | 
| 136 | jmc | 1.1 | for nv=1:4, | 
| 137 |  |  | subplot(410+nv); ttmn=' Mx-mn:'; ttav=' Av:'; | 
| 138 |  |  | for n=1:Nexp, | 
| 139 |  |  | plot(ttA(isA(n):ieA(n),n),var(isA(n):ieA(n),nv,n),linA(n,:)); | 
| 140 |  |  | if n == 1, hold on ; end ; | 
| 141 |  |  | ttmn=sprintf([ttmn,' %2.1e ;'],dd(nv,n)); | 
| 142 |  |  | ttav=sprintf([ttav,' %3.2e ;'],av(nv,n)); | 
| 143 |  |  | end ; hold off ; | 
| 144 |  |  | AA=axis ; dAA=AA(4)-AA(3); | 
| 145 |  |  | if AA(3)*AA(4) <= 0, AA(3)=min(AA(3),-dAA/10); AA(4)=max(AA(4),dAA/10); end | 
| 146 | jmc | 1.2 | if ttax1 < ttax2, AA(1)=ttax1; AA(2)=ttax2; end; | 
| 147 | jmc | 1.1 | axis(AA); grid ; | 
| 148 |  |  | if nv == 1, title(['Avr ',titv,'  ',ttmn]); end | 
| 149 |  |  | if nv == 2, title(['Std-Dev ',titv,'  ',ttav]); end | 
| 150 | jmc | 1.2 | if nv == 3, title(['min ',titv,'  ',ttav]); legend(namLg,0); end | 
| 151 | jmc | 1.1 | if nv == 4, title(['Max ',titv,'  ',ttav]); end | 
| 152 |  |  | end ; xlabel(titT); | 
| 153 |  |  | %-- | 
| 154 |  |  | axes('position',[.01,.01,.99,.99],'Visible','off'); | 
| 155 |  |  | T=text(0.5,0.97,titall); | 
| 156 |  |  | set(T,'HorizontalAlignment','center','FontSize',12); | 
| 157 |  |  | Td=text(0.99,0.01,date); | 
| 158 |  |  | set(Td,'HorizontalAlignment','right','FontSize',6); | 
| 159 | jmc | 1.5 | %--- | 
| 160 | jmc | 1.1 | end | 
| 161 |  |  |  | 
| 162 | jmc | 1.5 | %------------------- | 
| 163 | jmc | 1.1 | end | 
| 164 |  |  |  | 
| 165 |  |  | %========================================================= |