procit=0;

if procit
    clear all; close all

    sub=[56:823];

    %% u
    load data_u; u=ConVel'; u=u(:,sub); bad=min(u(:)); idx=find(u==bad); u(idx)=NaN; ut=ConTitle;
    %% v
    load data_v; v=ConVel';  v=v(:,sub); bad=min(v(:)); idx=find(v==bad); v(idx)=NaN; vt=ConTitle;
    %% w
    load data_w; w=ConVel';  w=w(:,sub); bad=min(w(:)); idx=find(w==bad); w(idx)=NaN; wt=ConTitle;
    %% magnitude
    load data_mag; mag=ConVel';  mag=mag(:,sub); bad=min(mag(:)); idx=find(mag==bad); mag(idx)=NaN; magt=ConTitle;
    %% magnitude
    load data_dir; dir=ConVel';  dir=dir(:,sub); bad=min(dir(:)); idx=find(dir==bad); dir(idx)=NaN; dirt=ConTitle;
    %% Error velocity
    load data_error; e=ConVel';  e=e(:,sub); bad=min(e(:)); idx=find(e==bad); e(idx)=NaN; et=ConTitle;
    %% Average amplitude
    load data_amp; a=ConEchoAmp';  a=a(:,sub); bad=min(a(:)); idx=find(a==bad); a(idx)=NaN; at=ConTitle;

    % Time reference
    dd=ConDay(sub); hh=ConHour(sub); mn=ConMin(sub); sec=ConSec(sub);
    time=dd+hh/24+mn/(24*60)+sec/(24*60*60);
    idx=find(diff(time)<0); sub=[idx+1:length(time)]; mtime=time(sub); mtime=mtime-min(mtime);
    mtime=mtime+1/48; time(sub)=time(idx)+mtime;
    figure(1); clf; plot(time); hold on; plot(idx,time(idx),'r*');
    % Depth reference:
    % Transducer at 96 m according to ancillary depth variable
    % First good +3 m, so for 100 1-m bins:
    z=[93:-1:-6]';
    u=mf(u,3,1); v=mf(v,3,1); w=mf(w,3,1); a=mf(a,3,1); mag=mf(mag,3,1); dir=mf(dir,3,1);
    zidx=find(z>=10); u=u(zidx,:); v=v(zidx,:); w=w(zidx,:); mag=mag(zidx,:); dir=dir(zidx,:); z=z(zidx);
    save processed_data u v w mag dir time z
else
    load processed_data
end

% time=time-min(time);

zidx=find(z>=25); 

XT=[16:1:35];
figure(1); clf; thx_fig; load jetplus; colormap(jetplus);
subplot(411); imagesc(time,z(zidx),u(zidx,:)/10); set(gca,'Ydir','reverse'); ylabel('Depth (m)');
cb=colorbar; yl=get(cb,'Ylabel'); set(yl,'string','u (cm/s)');
set(gca,'Xtick',XT,'Tickdir','out');
subplot(412); imagesc(time,z(zidx),v(zidx,:)/10); set(gca,'Ydir','reverse'); ylabel('Depth (m)');
cb=colorbar; yl=get(cb,'Ylabel'); set(yl,'string','v (cm/s)');
set(gca,'Xtick',XT,'Tickdir','out');
subplot(413); imagesc(time,z(zidx),w(zidx,:)/10); set(gca,'Ydir','reverse'); ylabel('Depth (m)');
cb=colorbar; yl=get(cb,'Ylabel'); set(yl,'string','w (cm/s)');
set(gca,'Xtick',XT,'Tickdir','out');
subplot(414); imagesc(time,z(zidx),a(zidx,:),[70 160]); set(gca,'Ydir','reverse'); ylabel('Depth (m)');
cb=colorbar; yl=get(cb,'Ylabel'); set(yl,'string','amp (counts)');
set(gca,'Xtick',XT,'Tickdir','out');
xlabel('Day of time series, starting April 15');

frame
t=text(.5,.97,'MBARI OCCO Program, Shelfbreak ADCP Mooring, April 2003');
set(t,'fontsize',12,'fontweight','bold','horizontalalignment','center');

return

figure(2); clf; thx_fig; load jetplus; colormap(jet);
subplot(211); imagesc(time,z,mag/10); set(gca,'Ydir','reverse'); ylabel('Depth (m)');
cb=colorbar; yl=get(cb,'Ylabel'); set(yl,'string','speed (cm/s)');
set(gca,'Xtick',XT,'Tickdir','out');
subplot(212); imagesc(time,z,dir/10); set(gca,'Ydir','reverse'); ylabel('Depth (m)');
cb=colorbar; yl=get(cb,'Ylabel'); set(yl,'string','direction');
set(gca,'Xtick',XT,'Tickdir','out');
xlabel('Day of time series, starting April 15');

frame
t=text(.5,.97,'MBARI OCCO Program, Shelfbreak ADCP Mooring, April 2003');
set(t,'fontsize',12,'fontweight','bold','horizontalalignment','center');

