function plot_oneway(t,x,u,k,t0,tf,lt,x0,x1,lx,ord,pltord)
% PLOT_ONEWAY plots output for run_oneway.m
% Set parameter equal to 1 for corresponding plot
nwater=0; nmesh=1; nmom=1; nenergy=0; nmovie = 0;

pltord = min(pltord,ord);
dxplot = 2^(ord-pltord);
nxplot = 1:dxplot:lx;
xplot = x(nxplot);
uplot = u(:,nxplot);

%% Surface plot
%%
if (nwater==1)
    figure(1);  clf;                    % waterfall plot
    waterfall(xplot,t,uplot)
    view(10,70)
%    umax = max(max(u));
%    umin = min(min(u));   
%    axis([0 2*pi t0 tf umin umax])
    axis tight
    xlabel('x'), ylabel('t'), zlabel('u')
    grid off
end

if (nmesh==1)
    figure(2); clf;                     % mesh plot with contours
    meshc(xplot,t,uplot)            
    view(10,70)
    axis tight
    xlabel('x'), ylabel('t'), zlabel('u')
    grid off
end

%% Momentum and energy plot
%%
if (nmom==1)
    figure(3);   clf;                   % momentum int[u*|D|u] vs. t 
    m=zeros(1,lt);
    for j=1:lt
        m(j) = sum(abs(fft(u(j,:))).^2.*abs(k))/lx^2;
    end
    plot(t,m);
    mmax=1.2*max(m); mmin=0;
    axis ([t0 tf mmin mmax]);
%    axis ([.46 .54 .4995 .5001]);
    xlabel('t'); ylabel('m');
end

if (nenergy==1)
    figure(4);   clf;                   % energy int[h*u*|D|u] vs. t 
    e=zeros(1,lt);
    for j=1:lt
        h = hilbert(u(j,:),lx);
        h2 = 0.5*h.*h;
        e(j) = -real(sum(conj(fft(u(j,:))).*fft(h2).*k.^2))/lx^2;
    end
    plot(t,e);
    emax=max(0,1.2*max(e)); emin = min(0,1.2*min(e));
    axis ([t0 tf emin emax]);
    xlabel('t'); ylabel('e');
end

%% Movie plot
%%     
if (nmovie==1)       
        figure(5); clf;       
        umax = max(max(u));
        umin = min(min(u));
        textx = x1 -(x1-x0)/5;
        textu = umax - (umax-umin)/10;
        mvplot=moviein(lt);
        hold off;      
        for j = 1:lt
            umplot = u(j,:);
            plot(x,umplot);
            title(strcat('time =',num2str(t(j))));
            axis([x0 x1 umin umax]);
            text(textx,textu,strcat('time =',num2str(t(j))));
            xlabel('x'); ylabel('u');
            mvplot(j) = getframe;
        end
    
        movie2avi(mvplot,'hiz.avi','fps',10,'quality',100,...
                    'compression','None');
%        movie(mvplot,1);   
end

%% Other stuff
%%
u_spec = zeros(lt,lx);
ux = zeros(lt,lx);
v = zeros(lt,lx);
vx = zeros(lt,lx);
vxxx = zeros(lt,lx);
lvxvx = zeros(lt,lx);
lvvxxx = zeros(lt,lx);
for j=1:lt
    u_spec(j,:) = fft(u(j,:));
    ux(j,:) = deriv(u(j,:),k); 
    v(j,:) = hilbert(u(j,:),lx);
    vx(j,:) = deriv(v(j,:),k);
    vxxx(j,:) = dderiv(v(j,:),k);
    lvxvx(j,:) = hilbert(deriv(vx(j,:).*vx(j,:),k),lx) ...
                 - 2*vx(j,:).*hilbert(deriv(vx(j,:),k),lx);
    lvvxxx(j,:) = hilbert(v(j,:).*vxxx(j,:),lx) ...
                 - v(j,:).*hilbert(vxxx(j,:),lx);
end

kplot = k(2:dxplot:lx/4);
kplot = log(abs(kplot));
u_spec_plot = log(abs(u_spec(:,2:dxplot:lx/4)));

ux_plot = ux(:,nxplot);
lvxvx_plot = lvxvx(:,nxplot);
lvvxxx_plot = lvvxxx(:,nxplot);
c_plot = - 2*vx(:,nxplot);

figure(6); clf;
meshc(xplot,t,ux_plot);            
view(10,70)
axis tight
xlabel('x'), ylabel('t'), zlabel('u_x')

figure(7); clf;
meshc(xplot,t,lvxvx_plot);            
view(10,70)
axis tight
xlabel('x'), ylabel('t'), zlabel('v_x-v_x')

figure(8); clf;
meshc(xplot,t,lvvxxx_plot);            
view(10,70)
axis tight
xlabel('x'), ylabel('t'), zlabel('v-v_{xxx}')

figure(9); clf;
meshc(xplot,t,c_plot);            
view(10,70)
axis tight
xlabel('x'), ylabel('t'), zlabel('c = -2*v_x')


figure(10); clf;
meshc(kplot,t,u_spec_plot);            
view(10,70)
axis tight
xlabel('log|k|'), ylabel('t'), zlabel('log|spectrum|')
