| 1 | jmc | 1.3 | prefix='dynStD'; | 
| 2 | jmc | 1.7 | %prefix='iceStD'; | 
| 3 | jmc | 1.5 | namA={'g02','b02'}; | 
| 4 |  |  | %namA={'r17a'}; | 
| 5 | jmc | 1.2 | Nexp=size(namA,2); | 
| 6 | jmc | 1.1 | %- | 
| 7 |  |  |  | 
| 8 | jmc | 1.9 | % $Header: /u/gcmpack/MITgcm_contrib/jmc_script/grph_StD.m,v 1.8 2015/09/06 18:15:09 jmc Exp $ | 
| 9 | jmc | 1.1 | % $Name:  $ | 
| 10 |  |  |  | 
| 11 |  |  | nItMx=1e10*ones(1,Nexp); %nItMx(3)=11; | 
| 12 | jmc | 1.8 | %nItMx=2400*ones(1,Nexp); | 
| 13 | jmc | 1.2 | namLg=namA ; namLg=strrep(namLg,'_','\_'); | 
| 14 | jmc | 1.6 | undef=123456.7; | 
| 15 | jmc | 1.1 | %----------- | 
| 16 |  |  | %- test if the variable krd is define : | 
| 17 |  |  | if size(who('krd'),1) > 0, | 
| 18 |  |  | fprintf('krd is defined and = %i \n',krd); | 
| 19 |  |  | else | 
| 20 |  |  | fprintf('krd undefined ; set to 1 \n'); krd=1 ; | 
| 21 |  |  | end | 
| 22 |  |  | if krd > 0, | 
| 23 |  |  | %- define list of fields to read in: | 
| 24 |  |  | %listV={'Eta','U','V','W','T','S','DETADT2','RELHUM','Phi'}; | 
| 25 | jmc | 1.4 | %listV={'Eta','W','T','S','CONVADJ','DETADT2'}; | 
| 26 | jmc | 1.2 | %listV={'Eta','UE_VEL_C','VN_VEL_C','W','T','DETADT2','Phi'}; | 
| 27 | jmc | 1.1 | %- or take all them: | 
| 28 | jmc | 1.4 | clear listV ; listV='all_flds'; | 
| 29 | jmc | 1.1 | %----------- | 
| 30 |  |  |  | 
| 31 |  |  | %- start to read the longest record: | 
| 32 |  |  | n=1; rf=-1; if strcmp(char(listV),'all_flds'), rf=0; end | 
| 33 |  |  | [ntA(n),rList,tim,vv1,listV] = ... | 
| 34 | jmc | 1.2 | read_StD(prefix,namA(n),listV); | 
| 35 | jmc | 1.1 | nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3); | 
| 36 |  |  | %- 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 |  |  | if (nrec < nIt), | 
| 47 |  |  | fprintf('\n'); | 
| 48 |  |  | error([' Nb of records=',int2str(nIt),' exceeds nrec=',int2str(nrec)]); | 
| 49 |  |  | end | 
| 50 |  |  | if (n3d < nk), | 
| 51 |  |  | fprintf('\n'); | 
| 52 |  |  | error([' Nb of Levels=',int2str(nk),' exceeds n3d=',int2str(n3d)]); | 
| 53 |  |  | end | 
| 54 |  |  | vvA(1:nk,1:nIt,1:nRg,:,:,n)=vv1; tiA(1:nIt,:,n)=tim; | 
| 55 |  |  | end; | 
| 56 |  |  | if krd == 2, | 
| 57 |  |  | fprintf('save to "sav_StD.mat" file ...'); | 
| 58 |  |  | save('sav_StD.mat','vvA','tiA','ntA','rList','listV'); | 
| 59 |  |  | fprintf(' done\n') | 
| 60 | jmc | 1.5 | end | 
| 61 | jmc | 1.1 | elseif krd < 0, | 
| 62 |  |  | fprintf('load from "sav_StD.mat" file ...'); | 
| 63 |  |  | load sav_StD | 
| 64 |  |  | fprintf(' done\n'); nbV=size(listV,2); | 
| 65 |  |  | end | 
| 66 |  |  | if krd ~= 0, | 
| 67 |  |  | ttA=squeeze(tiA(:,2,:)); | 
| 68 | jmc | 1.4 | ttA=ttA/3600; titT='hrs';  ttA=ttA/24; titT='days'; | 
| 69 |  |  | ttA=ttA/30 ; titT='month'; ttA=ttA/12 ; titT='year'; | 
| 70 | jmc | 1.1 | end | 
| 71 |  |  | %========================================================= | 
| 72 |  |  |  | 
| 73 |  |  | ttax1=0 ; ttax2=0 ; ttay=zeros(nbV,2); | 
| 74 |  |  | %-- fixed time axis bound : | 
| 75 | jmc | 1.2 | % ttax1=15.; ttax2=20.; | 
| 76 | jmc | 1.1 | %-- 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 | jmc | 1.8 | nbG=18; | 
| 87 | jmc | 1.1 | nbG=min(nbG,nbV); list_on(1:nbG)=1 ; | 
| 88 | jmc | 1.5 | %if nbG < nbV, list_on=0; list_on(nbG:nbV)=1; end %- to get 2nd set of plots | 
| 89 | jmc | 1.1 | %list_on(1:6)=[1 1 1 1 1 1]; | 
| 90 |  |  |  | 
| 91 |  |  | isA=ones(1,Nexp); ieA=ntA; | 
| 92 | jmc | 1.5 | %- limit the length : for search of isA <->1500y: find(ttA(:,2) == 1500) | 
| 93 | jmc | 1.1 | %isA=isA*31 ; % drop the 1rst mnth (1 Monitor/d) | 
| 94 | jmc | 1.3 | isA=isA*2 ; % drop the 1rst mnth (1 Monitor/30d) | 
| 95 | jmc | 1.1 | %isA(1)=31 ; isA(2)=4 ; % drop the 1rst mnth | 
| 96 | jmc | 1.3 | %ieA(:)=240; %isA(:)=1; | 
| 97 | jmc | 1.1 |  | 
| 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 | jmc | 1.5 | %titall='AIM , Cubic-G (32x32) , cpl-FM Forcing' ; | 
| 107 | jmc | 1.3 | titall='Global Ocean, Cubic-G (32x32) , CORE Forc (2)' ; | 
| 108 | jmc | 1.2 | %titall='Dyncore test-case 5 (cs-32)' ; | 
| 109 | jmc | 1.1 |  | 
| 110 |  |  | %========================================================= | 
| 111 | jmc | 1.9 | ng=0; fxb=100; fyb=60; fdx=100; fdy=40; fsc=1.; | 
| 112 |  |  | %fyb=-360; fxb=-2600; fdy=60; fsc=1.5; | 
| 113 | jmc | 1.5 |  | 
| 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.9 | figure(ng); set(ng,'position',[fxb+fdx*ng fyb+fdy*ng [500 700]*fsc]);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 | jmc | 1.7 | tmp=var(isA(n):ieA(n),:,n); [I]=find(tmp(:,1)==undef); tmp(I,:)=0; | 
| 134 |  |  | av(:,n)=sum(tmp); | 
| 135 |  |  | if length(I) < size(tmp,1), av(:,n)=av(:,n)/(size(tmp,1)-length(I)); end | 
| 136 |  |  | tmp(I,:)=NaN; dd(:,n)=max(tmp)-min(tmp); | 
| 137 | jmc | 1.3 | end | 
| 138 | jmc | 1.7 | var(find(var==undef))=NaN; | 
| 139 | jmc | 1.1 | for nv=1:4, | 
| 140 |  |  | subplot(410+nv); ttmn=' Mx-mn:'; ttav=' Av:'; | 
| 141 |  |  | for n=1:Nexp, | 
| 142 |  |  | plot(ttA(isA(n):ieA(n),n),var(isA(n):ieA(n),nv,n),linA(n,:)); | 
| 143 |  |  | if n == 1, hold on ; end ; | 
| 144 |  |  | ttmn=sprintf([ttmn,' %2.1e ;'],dd(nv,n)); | 
| 145 |  |  | ttav=sprintf([ttav,' %3.2e ;'],av(nv,n)); | 
| 146 |  |  | end ; hold off ; | 
| 147 |  |  | AA=axis ; dAA=AA(4)-AA(3); | 
| 148 |  |  | if AA(3)*AA(4) <= 0, AA(3)=min(AA(3),-dAA/10); AA(4)=max(AA(4),dAA/10); end | 
| 149 | jmc | 1.2 | if ttax1 < ttax2, AA(1)=ttax1; AA(2)=ttax2; end; | 
| 150 | jmc | 1.1 | axis(AA); grid ; | 
| 151 |  |  | if nv == 1, title(['Avr ',titv,'  ',ttmn]); end | 
| 152 |  |  | if nv == 2, title(['Std-Dev ',titv,'  ',ttav]); end | 
| 153 | jmc | 1.10 | if nv == 3, title(['min ',titv,'  ',ttav]); | 
| 154 |  |  | legend(namLg,'Location','best'); end | 
| 155 | jmc | 1.1 | if nv == 4, title(['Max ',titv,'  ',ttav]); end | 
| 156 |  |  | end ; xlabel(titT); | 
| 157 |  |  | %-- | 
| 158 |  |  | axes('position',[.01,.01,.99,.99],'Visible','off'); | 
| 159 |  |  | T=text(0.5,0.97,titall); | 
| 160 |  |  | set(T,'HorizontalAlignment','center','FontSize',12); | 
| 161 |  |  | Td=text(0.99,0.01,date); | 
| 162 |  |  | set(Td,'HorizontalAlignment','right','FontSize',6); | 
| 163 | jmc | 1.5 | %--- | 
| 164 | jmc | 1.1 | end | 
| 165 |  |  |  | 
| 166 | jmc | 1.5 | %------------------- | 
| 167 | jmc | 1.1 | end | 
| 168 |  |  |  | 
| 169 |  |  | %========================================================= |