PLOT_LEGS
Torsten Linders, torsten@oceansurface.se, January 4, 2012
Plots parameters from matices (or vectors) representing legs. Some of the plotted parameters are calculated in this script, but most parameters are loaded from mat-files, which are saved in other scripts.
Contents
Cleaning up
clear
close all
Parameters to plot
Turbulence parameters
- eps: dissipation,
- eNS: dissipation against N2 and shear.
- tke: turbulent kinetic energy,
- ust: friction velocity,
- l: mixing length,
- teps: dissipation timescale,
- shpr: shear production of TKE,
- bpr: buoyancy production of TKE,
Density parameters
- dens: density,
- N2: Buoyancy frequency squared,
- zdev: z deviation from average density column (this day),
- Epot: potential energy of z deviation of density from average density column (this day),
- Epad: horizontal advection of potential energy,
- dens_h: horizontal density gradient.
Pressure paramers
- pdev: pressure deviation from average pressure column (this day),
- dP: "potential energy" (to dist=1km).
Velocity parameters
- U: horizontal velocity,
- V: horizontal cross-velocity,
- intU: depth integrated velocity,
- Udst: difference in horizontal velocity, ship ADCP - TIMOS
- mUt: mean horizontal velocity, TIMOS,
- shear: vertical shear,
- shear_h: horizontal shear,
- shdens_h: ??,
- Ek: kinetic energy,
- Ekad: horizontal advection of kinetic energy,
- G: Froude number.
Time and position parameters
- time: time against along fjord distance.
Settings
par='eNS'; % eps, N2, U, shear, mUt, Udst, intU, ... plot_dens=0; % 0, 1 (does not work well with octave) par_vector=0; % 0, 1 mlegs=2; % 2, 3, ... platform='timos'; % mss, ship, timos avday=0; % 0, 1, 2, 3
Loading prepared data
Some allocations are also made here.
Common parameters
load mat/timeposlegs load mat/fjordsection load mat/sigma sigma_v load mat/mycolormap
Turbulence parameters
if strcmp(par,'eps') load mat/epsal load mat/densal elseif strcmp(par,'eNS') load mat/eNSal elseif strcmp(par,'tke') || strcmp(par,'ust') || strcmp(par,'teps') || ... strcmp(par,'shpr') || strcmp(par,'bpr') || strcmp(par,'l')
load mat/tkeal load mat/epsal load mat/shtal
Density parameters
elseif strcmp(par,'dens') load mat/densal elseif strcmp(par,'N2') load mat/N2al elseif strcmp(par,'zdev') load mat/zdeval elseif strcmp(par,'Epot') load mat/Epotal elseif strcmp(par,'Epad') load mat/p0al load mat/Utal elseif strcmp(par,'dens_h')
load mat/dens_hal
Pressure paramers
elseif strcmp(par,'pdev') load mat/pdeval elseif strcmp(par,'dP')
load mat/p0al
Velocity parameters
elseif strcmp(par,'U') || strcmp(par,'mUt') || strcmp(par,'Udst') || ... strcmp(par,'Ek') || strcmp(par,'Ekad') if strcmp(platform,'ship') load mat/Usal load mat/Utal elseif strcmp(platform,'timos') load mat/Utal load mat/densal end elseif strcmp(par,'V') load mat/Vtal load mat/densal elseif strcmp(par,'intU') if strcmp(platform,'ship') load mat/intUsal elseif strcmp(platform,'timos') load mat/intUtal end elseif strcmp(par,'shear') if strcmp(platform,'ship') load mat/shsal elseif strcmp(platform,'timos') load mat/shtal end elseif strcmp(par,'shear_h') if strcmp(platform,'ship') elseif strcmp(platform,'timos') load mat/sht_hal end elseif strcmp(par,'G') load mat/Utal load mat/densal load mat/shtal G=zeros(3,imax,23); U2=zeros(4,imax); rho=zeros(4,imax); gp=zeros(3,imax); end
Legs
Selecting legs
if avday==1 if strcmp(platform,'timos') legs=2:2; else legs=1:3; end elseif avday==2 legs=4:13; elseif avday==3 legs=14:23; else if strcmp(platform,'timos') legs=2:23; else legs=1:23; end end
Plotting
for leg=legs
fig=figure(leg); set(fig,'Position',[1 1 800 900]); set(fig,'Colormap',mycolormap);
Turbulence parameters
if strcmp(par,'eps') imagesc(epsal(:,:,leg)) if plot_dens hold on contour(fliplr(rot90(densal(:,:,leg)',-1)),sigma_v,'w') hold off title(['Leg ' num2str(leg) ', Dissipation (log_{10}[m^2 s^{-3}]) and density lines']) else title(['Leg ' num2str(leg) ', Dissipation (log_{10}[m^2 s^{-3}])']) end caxis([-10 -4]) elseif strcmp(par,'eNS') subplot(2,1,1) imagesc(eNSal(:,:,leg)) title(['Leg ' num2str(leg) ', dissipation (log_{10}(W/kg)) at ' num2str(dmin) ' - ' num2str(dmax) ' m, averaging of un-logarithmized values']) caxis([-9 -5]) plot_extras subplot(2,1,2) imagesc(log10(eNSali(:,:,leg))) title(['Leg ' num2str(leg) ', number of observations (log_{10})']) caxis([0 5]) elseif strcmp(par,'tke') imagesc(tkelogal(:,:,leg)) title(['Leg ' num2str(leg) ', Turbulent kinetic energy (log_{10}(J/kg))']) caxis([-8 -2]) elseif strcmp(par,'ust') imagesc(ustal(:,:,leg)) title(['Leg ' num2str(leg) ', Friction velocity (m/s)']) caxis([0 0.05]) elseif strcmp(par,'l') imagesc(lal(:,:,leg)) title(['Leg ' num2str(leg) ', Mixing length (m)']) caxis([-10 0]) elseif strcmp(par,'teps') imagesc(tkelogal(:,:,leg)-epsal(:,:,leg)) title(['Leg ' num2str(leg) ', Dissipation timescale (log_{10}(s))']) caxis([-10 0]) elseif strcmp(par,'shpr') imagesc(log10(10.^tkelogal(2:end,:,leg).*abs(shtal(:,:,leg)))) title(['Leg ' num2str(leg) ', Shear production of TKE (log_{10}(m^2s^{-3}))']) caxis([-10 0]) elseif strcmp(par,'bpr')
imagesc(log10(max(0,10.^tkelogal(2:end,:,leg).*abs(shtal(:,:,leg))-10.^epsal(2:end,:,leg)))) title(['Leg ' num2str(leg) ', Buoyancy production of TKE (log_{10}(m^2s^{-3}))']) caxis([-10 0])
Density parameters
elseif strcmp(par,'dens') imagesc(densal(:,:,leg)) title(['Leg ' num2str(leg) ', Density']) caxis([20 30]) elseif strcmp(par,'N2') imagesc(N2al(:,:,leg)) title(['Leg ' num2str(leg) ', Buoyancy frequency squared (s^{-2})']) caxis([0 0.002]) elseif strcmp(par,'zdev') imagesc(zdeval(:,:,leg)) title(['Leg ' num2str(leg) ', Z deviation (m) of density from average density column (this day)']) caxis([-5 5]) elseif strcmp(par,'Epot') imagesc(Epotal(:,:,leg)) title(['Leg ' num2str(leg) ', Potential energy (J/kg) of z deviation of density from average density column (this day)']) caxis([-3 2]) elseif strcmp(par,'Epad') Epad=-diff(p0al(:,:,leg),1,2).*Utal(:,2:end,leg)/1025/dx; imagesc(Epad) title(['Leg ' num2str(leg) ', Horizontal advection of potential energy (m^2 s^{-3})']) caxis([-3 3]*1e-5) elseif strcmp(par,'dens_h')
imagesc(dens_hal(:,:,leg)) title(['Leg ' num2str(leg) ', Horizontal density gradient (kg m^{-4})']) caxis([-0.001 0.001])
Pressure paramers
elseif strcmp(par,'pdev') imagesc(pdeval(:,:,leg)) title(['Leg ' num2str(leg) ', Pressure (Pa) deviation from average pressure column (this day)']) caxis([-50 50]) elseif strcmp(par,'dP')
p00=repmat(p0al(:,201,leg),1,imax); dP=(p0al(:,:,leg)-p00)/1025; imagesc(dP) title(['Leg ' num2str(leg) ', "Potential energy" (to dist=1km) (m^2/s^2)']) caxis([-0.05 0.05])
Velocity parameters
elseif strcmp(par,'U') if strcmp(platform,'ship') imagesc(Usal(:,:,leg)) title(['Leg ' num2str(leg) ', Horizontal velocity (m/s), ship ADCP']) elseif strcmp(platform,'timos') imagesc(Utal(:,:,leg)) if plot_dens hold on contour(fliplr(rot90(densal(:,:,leg)',-1)),sigma_v,'k') hold off title(['Leg ' num2str(leg) ', Horizontal velocity (m/s), TIMOS, and density']) else title(['Leg ' num2str(leg) ', Horizontal velocity (m/s), TIMOS']) end end caxis([-0.4 0.4]) elseif strcmp(par,'V') imagesc(Vtal(:,:,leg)) if plot_dens hold on contour(fliplr(rot90(densal(:,:,leg)',-1)),sigma_v,'k') hold off title(['Leg ' num2str(leg) ', Horizontal cross-velocity (m/s), TIMOS, and density']) else title(['Leg ' num2str(leg) ', Horizontal cross-velocity (m/s), TIMOS']) end caxis([-0.4 0.4]) elseif strcmp(par,'intU') subplot(2,1,2) if strcmp(platform,'ship') plot(x,intUsal(:,:,leg),'.r-') title(['Leg ' num2str(leg) ', the ship ADCP']) elseif strcmp(platform,'timos') plot(x,intUtal(:,:,leg),'.g-') title(['Leg ' num2str(leg) ', TIMOS']) end elseif strcmp(par,'Udst') imagesc(Usal(:,:,leg)-Utal(:,:,leg)) title(['Leg ' num2str(leg) ', Difference in horizontal velocity (m/s), ship ADCP - TIMOS']) caxis([-0.2 0.2]) elseif strcmp(par,'mUt') && leg>mlegs imagesc(mean(Utal(:,:,leg-mlegs+1:leg),3)) if plot_dens hold on contour(fliplr(rot90(mean(densal(:,:,leg-mlegs+1:leg),3)',-1)),sigma_v,'k') hold off title(['Leg ' num2str(leg-mlegs+1) ' - ' num2str(leg) ', Mean horizontal velocity (m/s), TIMOS, and density']) else title(['Leg ' num2str(leg-mlegs+1) ' - ' num2str(leg) ', Mean horizontal velocity (m/s), TIMOS']) end caxis([-0.4 0.4]) elseif strcmp(par,'shear') if strcmp(platform,'ship') imagesc(shsal(:,:,leg)) title(['Leg ' num2str(leg) ', Vertical shear (s^{-1}), ship ADCP']) elseif strcmp(platform,'timos') imagesc(shtal(:,:,leg)) title(['Leg ' num2str(leg) ', Vertical shear (s^{-1}), TIMOS']) text(160,460,'Shear of both u and v, velocities filtered over 10 vertical points, i.e. 2 m') end caxis([0 0.1]) elseif strcmp(par,'shear_h') if strcmp(platform,'ship') imagesc(shs_hal(:,:,leg)) title(['Leg ' num2str(leg) ', Horizontal shear (s^{-1}), ship ADCP']) elseif strcmp(platform,'timos') imagesc(sht_hal(:,:,leg)) title(['Leg ' num2str(leg) ', Horizontal shear (s^{-1}), TIMOS']) end caxis([-0.001 0.001]) elseif strcmp(par,'shdens_h') imagesc(sht_hal(:,:,leg).*dens_hal(1:end,:,leg)./... (sqrt(N2al(1:end,:,leg)*9.81*1025))) title(['Leg ' num2str(leg) ', shdens_h (??)']) caxis([-1 1]*1e-7) elseif strcmp(par,'Ek') Ek=0.5*Utal(:,:,leg).^2; imagesc(Ek) title(['Leg ' num2str(leg) ', Kinetic energy (m^2 s^{-2})']) caxis([0 0.05]) elseif strcmp(par,'Ekad') Ek=0.5*Utal(:,:,leg).^2; imagesc(-diff(Ek,1,2).*Utal(:,2:end,leg)/dx) title(['Leg ' num2str(leg) ', Horizontal advection of kinetic energy (m^2 s^{-3})']) caxis([-3 3]*1e-5) elseif strcmp(par,'G') clear h1 kh1 hmax=[20 30 40]; span=10; for i=1:imax shi=convn(shtal(:,i,leg),ones(span,1)/span,'same'); [y,kh1(i)]=min(shi(26:101)); h1(i)=dz*kh1(i)+z(26); end span=50; h1=convn(h1',ones(span,1)/span,'same')'; kh1=round(h1/dz)+1; for i=1:imax h2(1,:)=hmax(1)-h1; h2(2,:)=hmax(2)-h1; h2(3,:)=hmax(3)-h1; U2(1,i)=mean1(Utal(1:kh1(i),i,leg).^2); U2(2,i)=mean1(Utal(kh1(i)+1:hmax(1)/dz,i,leg).^2); U2(3,i)=mean1(Utal(kh1(i)+1:hmax(2)/dz,i,leg).^2); U2(4,i)=mean1(Utal(kh1(i)+1:hmax(3)/dz,i,leg).^2); rho(1,i)=mean1(densal(1:kh1(i),i,leg)); rho(2,i)=mean1(densal(kh1(i)+1:hmax(1)/dz,i,leg)); rho(3,i)=mean1(densal(kh1(i)+1:hmax(2)/dz,i,leg)); rho(4,i)=mean1(densal(kh1(i)+1:hmax(3)/dz,i,leg)); gp(1,:)=9.81/1025*(rho(2,:)-rho(1,:)); gp(2,:)=9.81/1025*(rho(3,:)-rho(1,:)); gp(3,:)=9.81/1025*(rho(4,:)-rho(1,:)); G(1,:,leg)=U2(1,:)./gp(1,:)./h1; G(2,:,leg)=U2(1,:)./gp(2,:)./h1; G(3,:,leg)=U2(1,:)./gp(3,:)./h1; G(4,:,leg)=U2(2,:)./gp(1,:)./h2(1); G(5,:,leg)=U2(3,:)./gp(2,:)./h2(2); G(6,:,leg)=U2(4,:)./gp(3,:)./h2(3); end subplot(2,2,1) plot(1:imax,rho(2,:),1:imax,rho(3,:),1:imax,rho(4,:),1:imax,rho(1,:)) title(['Leg ' num2str(leg) ', r_1 and r_2 (kg m^{-3})']) axis([1 imax 22 26]) set(gca,'XTick',1:200:imax) set(gca,'XTickLabel',0:1:xmax/1000) xlabel('Along fjord distance (km)') grid on legend('dens_2','dens_2','dens_2','dens_1') subplot(2,2,2) plot(1:imax,G(1,:,leg),1:imax,G(2,:,leg),1:imax,G(3,:,leg),... 1:imax,G(4,:,leg),'b--',1:imax,G(5,:,leg),'g--',1:imax,G(6,:,leg),'r--') title(['Leg ' num2str(leg) ', Froude number, term 1 and 2']) axis([1 imax 0 1]) set(gca,'XTick',1:200:imax) set(gca,'XTickLabel',0:1:xmax/1000) xlabel('Along fjord distance (km)') grid on legend('U^2_1/g*h_1','U^2_1/g*h_1','U^2_1/g*h_1',... 'U^2_2/g*h_2','U^2_2/g*h_2','U^2_2/g*h_2') subplot(2,2,3) plot(1:imax,U2(2,:),1:imax,U2(3,:),1:imax,U2(4,:),1:imax,U2(1,:)) title(['Leg ' num2str(leg) ', U^2_1 and U^2_2 (m^2 s^{-2})']) axis([1 imax 0 0.1]) set(gca,'XTick',1:200:imax) set(gca,'XTickLabel',0:1:xmax/1000) xlabel('Along fjord distance (km)') grid on legend('U^2_2','U^2_2','U^2_2','U^2_1') subplot(2,2,4) imagesc(Utal(:,:,leg)) title(['Leg ' num2str(leg) ', Horizontal velocity (m/s), and h_1 and h_2']) hold on plot(1:imax,h1/dz,'k-','LineWidth',1) plot(1:imax,hmax(1)/dz+1,'b-','LineWidth',3) plot(1:imax,hmax(2)/dz+1,'g-','LineWidth',3) plot(1:imax,hmax(3)/dz+1,'r-','LineWidth',3) hold off
Time and positions
elseif strcmp(par,'time') subplot(2,1,1) if strcmp(platform,'mss') li=filmss(leg):lilmss(leg); for ibad=imssbad li=li(find(li~=ibad)); end plot(distmss(li),tmss(li),'ob') title(['Leg ' num2str(leg) ', MSS']) elseif strcmp(platform,'ship') li=filship(leg):lilship(leg); plot(distship(li),tship(li),'.r') title(['Leg ' num2str(leg) ', the ship']) elseif strcmp(platform,'timos') li=filtimos(leg):liltimos(leg); plot(disttimos(li),ttimos(li),'.g') title(['Leg ' num2str(leg) ', TIMOS']) end end
Adjustments and saving
The help script plotextras.m is used for adding features to the axes, etc.
plot_extras
The help script printplot.m is used for producing an png-file of each figure.
printplot
close all
end