Warning, /verification/advect_xz/input.nlfs/grph_StD_AB.m is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
fc2c9620b4 Jean*0001 prefix='dynStD';
0002 %namA={'n30','n32','n33'};
0003 namA={'std'};
0004 Nexp=size(namA,2);
0005 %-
0006 %namA(2)={'r16a'};
0007
0008 alphAB=0.6; %- Adams-bashforth parameter (= 0.5+abEps )
0009 alphAB=0.;
0010
0011 nItMx=1e10*ones(1,Nexp); %nItMx(3)=11;
0012 nItMx=2400*ones(1,Nexp);
0013 namLg=namA ; namLg=strrep(namLg,'_','\_');
0014 %-----------
0015 %- test if the variable krd is define :
0016 if size(who('krd'),1) > 0,
0017 fprintf('krd is defined and = %i \n',krd);
0018 else
0019 fprintf('krd undefined ; set to 1 \n'); krd=1 ;
0020 end
0021 if krd > 0,
0022 %- define list of fields to read in:
0023 clear listV ;
0024 %listV={'Eta','U','V','W','T','S','DETADT2','RELHUM','Phi'};
0025 %listV={'Eta','W','T','S','CONVADJ','DETADT2'};
0026 %listV={'Eta','UE_VEL_C','VN_VEL_C','W','T','DETADT2','Phi'};
0027 %listV={'Eta','U','W','T','S','ADVx_TH','ADVr_TH','AB_gT','AB_gS'};
0028 %listV={'Eta','U','W','T','S','ADVx_TH','ADVr_TH','gSinAB'};
0029 %- or take all them:
0030 clear listV ; listV='all_flds';
0031 %-----------
0032
0033 %- start to read the longest record:
0034 n=1; rf=-1; if strcmp(char(listV),'all_flds'), rf=0; end
0035 [ntA(n),rList,tim,vv1,listV] = ...
0036 read_StD(prefix,namA(n),listV);
0037 nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3);
0038 %- set global dims: & load vvA --> vvB
0039 nbV=size(listV,2);
0040 nrec=nIt; n3d=nk; nReg=nRg;
0041 vvA=zeros(n3d,nrec,nReg,5,nbV,Nexp); tiA=zeros(nrec,2,Nexp);
0042 vvA(1:nk,1:nIt,1:nRg,:,:,n)=vv1; tiA(1:nIt,:,n)=tim;
0043 %----
0044 for n=2:Nexp,
0045 [ntA(n),rList,tim,vv1,listV] = ...
0046 read_StD(prefix,namA(n),listV);
0047 nIt=ntA(n); nk=size(vv1,1); nRg=size(vv1,3);
0048 if (nrec < nIt),
0049 fprintf('\n');
0050 error([' Nb of records=',int2str(nIt),' exceeds nrec=',int2str(nrec)]);
0051 end
0052 if (n3d < nk),
0053 fprintf('\n');
0054 error([' Nb of Levels=',int2str(nk),' exceeds n3d=',int2str(n3d)]);
0055 end
0056 vvA(1:nk,1:nIt,1:nRg,:,:,n)=vv1; tiA(1:nIt,:,n)=tim;
0057 end;
0058 if krd == 2,
0059 fprintf('save to "sav_StD.mat" file ...');
0060 save('sav_StD.mat','vvA','tiA','ntA','rList','listV');
0061 fprintf(' done\n')
0062 end
0063 elseif krd < 0,
0064 fprintf('load from "sav_StD.mat" file ...');
0065 load sav_StD
0066 fprintf(' done\n'); nbV=size(listV,2);
0067 end
0068 if krd ~= 0,
0069 ttA=squeeze(tiA(:,2,:));
0070 ttA=ttA/86400; titT='days'; %ttA=ttA/30 ; titT='month'; ttA=ttA/12 ; titT='year';
0071 end
0072 %=========================================================
0073
0074 ttax1=0 ; ttax2=0 ; ttay=zeros(nbV,2);
0075 %-- fixed time axis bound :
0076 % ttax1=15.; ttax2=20.;
0077 %-- fixed Y axis bound :
0078 % ttay(4,:)=[0 0.6];
0079 %-----------
0080 fprintf('Total length: ntA=');fprintf(' %i ,',ntA); fprintf(' \n');
0081 for n=1:Nexp,
0082 fprintf(' exp %i : time(d):%10.2f ->%10.2f \n', n,ttA(1,n),ttA(ntA(n),n) );
0083 end;
0084 %--
0085
0086 list_on=zeros(1,nbV);
0087 nbG=8;
0088 nbG=min(nbG,nbV); list_on(1:nbG)=1 ;
0089 %list_on(1:6)=[1 1 1 1 1 1];
0090
0091 isA=ones(1,Nexp); ieA=ntA;
0092 %- limit the length : for search of isA <->1500y: find(ttA(:,2) == 1500)
0093 %isA=isA*31 ; % drop the 1rst mnth (1 Monitor/d)
0094 %isA=isA*2 ; % drop the 1rst mnth (1 Monitor/30d)
0095 %isA(1)=31 ; isA(2)=4 ; % drop the 1rst mnth
0096 %ieA(:)=240; %isA(:)=1;
0097
0098 linA(1,:)='k-'; % ieA(1)=60 ; % ieA(1)=1152 ;
0099 linA(2,:)='b-';
0100 linA(3,:)='r-';
0101 linA(4,:)='g-';
0102 linA(5,:)='m-';
0103 linA(6,:)='c-';
0104
0105 ieA=min(ieA,nItMx);
0106 %titall='AIM , Cubic-G (32x32) , cpl-FM Forcing' ;
0107 %titall='Global Ocean, Cubic-G (32x32) , CORE Forc (2)' ;
0108 titall='Advect\_xz (nlfs) test experiment' ;
0109
0110 %=========================================================
0111
0112 for ng=1:nbV,
0113 %-------------------
0114 flag=list_on(ng); kl=0;
0115 vv1=vvA(:,:,:,:,ng,:); namV=char(listV(ng));
0116 titv=strrep(namV,'_','\_');
0117 %if strcmp(namV,'Eta'), vv1=vv1/100; titv='Eta [mb]'; end
0118 %if strcmp(namV,'T'), kl=1; end % <-- to get surf.Temp
0119 %if ng == 1, flag=2*list_on(1) ; end
0120 if kl > 0, titv=[titv,'\_',int2str(kl)];
0121 fprintf([' var= ',namV,' at level k= %i \n'],kl);
0122 end
0123
0124 if flag == 1
0125 %--
0126 figure(ng); set(ng,'position',[100+100*ng 60+40*ng 500 700]);clf;
0127 var=squeeze(vv1(1+kl,:,1,:,:)); dd=zeros(5,Nexp); av=zeros(5,Nexp);
0128 %------------
0129 gAB=0;
0130 if strcmp(namV,'T'),
0131 if length(strmatch('gTinAB',listV)) == 1, gAB=strmatch('gTinAB',listV); end
0132 end
0133 if strcmp(namV,'S'),
0134 if length(strmatch('gSinAB',listV)) == 1, gAB=strmatch('gSinAB',listV); end
0135 end
0136 if gAB > 0,
0137 tmpvar=squeeze(vvA(1+kl,:,1,1,gAB,:));
0138 if Nexp == 1, tmpvar=tmpvar'; end
0139 delT=(tiA(2,2,:)-tiA(1,2,:)); delN=(tiA(2,1,:)-tiA(1,1,:));
0140 delT=delT./delN; delT=ones(nIt,1)*reshape(delT,[1 Nexp]);
0141 tmpvar=tmpvar.*delT;
0142 tmpvar=alphAB*tmpvar;
0143 tmpvar=reshape(tmpvar,[nIt 1 Nexp]);
0144 var(:,1,:)=var(:,1,:)-tmpvar;
0145 end
0146 %------------
0147 for n=1:Nexp,
0148 dd(:,n)=max(var(isA(n):ieA(n),:,n))-min(var(isA(n):ieA(n),:,n));
0149 av(:,n)=mean(var(isA(n):ieA(n),:,n));
0150 end
0151 for nv=1:4,
0152 subplot(410+nv); ttmn=' Mx-mn:'; ttav=' Av:';
0153 for n=1:Nexp,
0154 plot(ttA(isA(n):ieA(n),n),var(isA(n):ieA(n),nv,n),linA(n,:));
0155 if n == 1, hold on ; end ;
0156 ttmn=sprintf([ttmn,' %2.1e ;'],dd(nv,n));
0157 ttav=sprintf([ttav,' %3.2e ;'],av(nv,n));
0158 end ; hold off ;
0159 AA=axis ; dAA=AA(4)-AA(3);
0160 if AA(3)*AA(4) <= 0, AA(3)=min(AA(3),-dAA/10); AA(4)=max(AA(4),dAA/10); end
0161 if ttax1 < ttax2, AA(1)=ttax1; AA(2)=ttax2; end;
0162 axis(AA); grid ;
0163 if nv == 1, title(['Avr ',titv,' ',ttmn]); end
0164 if nv == 2, title(['Std-Dev ',titv,' ',ttav]); end
0165 if nv == 3, title(['min ',titv,' ',ttav]); legend(namLg,0); end
0166 if nv == 4, title(['Max ',titv,' ',ttav]); end
0167 end ; xlabel(titT);
0168 %--
0169 axes('position',[.01,.01,.99,.99],'Visible','off');
0170 T=text(0.5,0.97,titall);
0171 set(T,'HorizontalAlignment','center','FontSize',12);
0172 Td=text(0.99,0.01,date);
0173 set(Td,'HorizontalAlignment','right','FontSize',6);
0174 %---
0175 end
0176
0177 %-------------------
0178 end
0179
0180 %=========================================================