PAR_AV
Torsten Linders, torsten@oceansurface.se, September 28, 2011
Puts values from legs into averages.
Contents
Cleaning up
clear
Settings
par='Ekad'; % eps, N2, U, shear, intU, Udst, p, Epot platform='mss'; % mss, ship, timos saving='matlab'; % matlab, octave, no
Loading prepared data
load mat/timeposlegs load mat/fjordsection load mat/sigma sigma_v load mat/mycolormap if strcmp(par,'eps') load mat/epsal load mat/densal elseif strcmp(par,'dens') || strcmp(par,'p') load mat/densal elseif strcmp(par,'Epot') load mat/Epotal1 elseif strcmp(par,'Epad') load mat/p0al load mat/Utal Epad=-diff(p0al,1,2).*Utal(:,2:end,:)/1025/dx; elseif strcmp(par,'N2') load mat/N2al elseif strcmp(par,'U') || strcmp(par,'Udst') if strcmp(platform,'ship') load mat/Usal load mat/Utal elseif strcmp(platform,'timos') load mat/Utal load mat/densal end elseif strcmp(par,'Ek') || strcmp(par,'Ekad') load mat/Utal Ek=0.5*Utal.^2; Ekad=-diff(Ek,1,2).*Utal(:,2:end,:); elseif strcmp(par,'shear') kmax=kmax-1; if strcmp(platform,'ship') load mat/shsal elseif strcmp(platform,'timos') load mat/shtal end elseif strcmp(par,'intU') if strcmp(platform,'ship') load mat/intUsal elseif strcmp(platform,'timos') load mat/intUtal end end
Allocating
if strcmp(par,'Ek') Ekav=zeros(kmax,imax,4)*NaN; elseif strcmp(par,'Ekad') Ekadav=zeros(kmax,imax,4)*NaN; elseif strcmp(par,'Epad') Epadav=zeros(kmax,imax,4)*NaN; end
Averaging
for avday=1:4; % 0, 1, 2, 3, 4
if avday==1 avlegs=1:3; elseif avday==2 avlegs=4:13; elseif avday==3 avlegs=14:23; else avlegs=1:23; end if strcmp(par,'eps') epsav=zeros(kmax,imax)*NaN; for k=1:kmax for i=1:imax legs=find(not(isnan(epsal(k,i,avlegs)))); epsal_ki=10.^epsal(k,i,:); epsav(k,i)=log10(mean(epsal_ki(avlegs(legs)))); end end elseif strcmp(par,'N2') N2av=zeros(kmax,imax)*NaN; for k=1:kmax for i=1:imax legs=find(not(isnan(N2al(k,i,avlegs)))); N2av(k,i)=mean(N2al(k,i,avlegs(legs))); end end elseif strcmp(par,'dens') || strcmp(par,'p') densav=zeros(kmax,imax)*NaN; densavc=zeros(kmax,1)*NaN; for k=1:kmax for i=1:imax legs=find(densal(k,i,avlegs)>0); densav(k,i)=mean(densal(k,i,avlegs(legs))); end is=find(densav(k,:)>0); densavc(k)=mean(densav(k,is),2); end pavc=densavc*NaN; pavc(19:end)=cumsum(densavc(19:end))*dz*9.81; elseif strcmp(par,'U') if strcmp(platform,'ship') Usav=zeros(kmax,imax)*NaN; for k=1:kmax for i=1:imax legs=find(not(isnan(Usal(k,i,avlegs)))); Usav(k,i)=mean(Usal(k,i,avlegs(legs))); end end elseif strcmp(platform,'timos') Utav=zeros(kmax,imax)*NaN; for k=1:kmax for i=1:imax legs=find(not(isnan(Utal(k,i,avlegs)))); Utav(k,i)=mean(Utal(k,i,avlegs(legs))); end end end elseif strcmp(par,'Ek') for k=1:kmax for i=1:imax legs=find(not(isnan(Ek(k,i,avlegs)))); Ekav(k,i,avday)=mean(Ek(k,i,avlegs(legs))); end end elseif strcmp(par,'Ekad') for k=1:kmax for i=1:imax-1 legs=find(not(isnan(Ekad(k,i,avlegs)))); Ekadav(k,i,avday)=mean(Ekad(k,i,avlegs(legs))); end end elseif strcmp(par,'Epad') for k=1:kmax for i=1:imax-1 legs=find(not(isnan(Epad(k,i,avlegs)))); Epadav(k,i,avday)=mean(Epad(k,i,avlegs(legs))); end end elseif strcmp(par,'intU') if strcmp(platform,'ship') intUsav=zeros(1,imax)*NaN; for i=1:imax legs=find(not(isnan(intUsal(1,i,avlegs)))); intUsav(1,i)=mean(intUsal(1,i,avlegs(legs))); end elseif strcmp(platform,'timos') intUtav=zeros(1,imax)*NaN; for i=1:imax legs=find(not(isnan(intUtal(1,i,avlegs)))); intUtav(1,i)=mean(intUtal(1,i,avlegs(legs))); end end elseif strcmp(par,'shear') if strcmp(platform,'ship') shsav=zeros(kmax,imax)*NaN; for k=1:kmax for i=1:imax legs=find(not(isnan(shsal(k,i,avlegs)))); shsav(k,i)=mean(shsal(k,i,avlegs(legs))); end end elseif strcmp(platform,'timos') shtav=zeros(kmax,imax)*NaN; for k=1:kmax for i=1:imax legs=find(not(isnan(shtal(k,i,avlegs)))); % shtav(k,i)=mean(shtal(k,i,avlegs(legs))); shtav(k,i)=mean(abs(shtal(k,i,avlegs(legs)))); end end end elseif strcmp(par,'Epot') Epotav=zeros(kmax,imax)*NaN; for k=1:kmax for i=1:imax legs=find(not(isnan(Epotal(k,i,avlegs)))); Epotav(k,i)=mean(Epotal(k,i,avlegs(legs))); end end end
Saving
if strcmp(saving,'matlab') || strcmp(saving,'octave') if strcmp(saving,'octave') default_save_options('-mat') end if strcmp(par,'eps') if avday==0 save epsav epsav elseif avday==1 save epsav1 epsav elseif avday==2 save epsav2 epsav elseif avday==3 save epsav3 epsav end elseif strcmp(par,'dens') || strcmp(par,'p') if avday==0 save densav densav densavc save pavc pavc elseif avday==1 save densav1 densav densavc save pavc1 pavc elseif avday==2 save densav2 densav densavc save pavc2 pavc elseif avday==3 save densav3 densav densavc save pavc3 pavc end elseif strcmp(par,'N2') if avday==0 save N2av N2av elseif avday==1 save N2av1 N2av elseif avday==2 save N2av2 N2av elseif avday==3 save N2av3 N2av end elseif strcmp(par,'U') if strcmp(platform,'ship') if avday==0 save Usav Usav elseif avday==1 save Usav1 Usav elseif avday==2 save Usav2 Usav elseif avday==3 save Usav3 Usav end elseif strcmp(platform,'timos') if avday==0 save Utav Utav elseif avday==1 save Utav1 Utav elseif avday==2 save Utav2 Utav elseif avday==3 save Utav3 Utav end end elseif strcmp(par,'Ek') save Ekav Ekav elseif strcmp(par,'Ekad') save Ekadav Ekadav elseif strcmp(par,'Epad') save Epadav Epadav elseif strcmp(par,'intU') if strcmp(platform,'ship') if avday==0 save intUsav intUsav elseif avday==1 save intUsav1 intUsav elseif avday==2 save intUsav2 intUsav elseif avday==3 save intUsav3 intUsav end elseif strcmp(platform,'timos') if avday==0 save intUtav intUtav elseif avday==1 save intUtav1 intUtav elseif avday==2 save intUtav2 intUtav elseif avday==3 save intUtav3 intUtav end end elseif strcmp(par,'shear') if strcmp(platform,'ship') if avday==0 save shsav shsav elseif avday==1 save shsav1 shsav elseif avday==2 save shsav2 shsav elseif avday==3 save shsav3 shsav end elseif strcmp(platform,'timos') if avday==0 save shtav shtav elseif avday==1 save shtav1 shtav elseif avday==2 save shtav2 shtav elseif avday==3 save shtav3 shtav end end elseif strcmp(par,'Epot') if avday==0 save Epotav Epotav elseif avday==1 save Epotav1 Epotav elseif avday==2 save Epotav2 Epotav elseif avday==3 save Epotav3 Epotav end end end
end