% Mooring Morel CHL
infile = netcdf('D:\www\bog\netcdf\ep2.avg.nc');
x = load('i:\matlab\work\oms\data\SeaWiFS_chl_2s_170w.txt');

t = nctime(infile);
k = oms_k1(infile, 490);
c = morel_chl2(k(:,1), 490);
ncquit(infile);

badStart = [0 datenum('11 Nov 1998')];
badEnd   = [datenum('01 Nov 1998') datenum('11 Nov 1999')];

for i = 1:length(badStart)
   bad = find(t >= badStart(i) & t <= badEnd(i));
   c(bad) = NaN;
end

% Morel CHl Running mean
cm = specmean(c, 7);

% SeaWiFS CHL
tSwf = x(:,1) + datenum('31 Dec 1996');
chlSwf = x(:,2);

% Insitu CHL
in = read_insitu_chl('i:\matlab\work\simbios\insitu_chl_2s_170w.txt');
good = find(in.p == 10);

% SST
w = read_windSST('i:\matlab\work\simbios\windSST_2s_170w.txt');
%mc = netcdf('d:\www\bog\netcdf\ep1_microcat.nc');
%tmc = nctime(mc);
%[tmc i] = sort(tmc);
%temp = mc{'temp'}(:);
%temp = specmean(temp(i), 24);
%useMe = [1:400:length(temp)];
%tmc = tmc(useMe);
%temp = temp(useMe);
%ncquit(mc)

%mint = min(tmc);
%goodT = find(w.t < mint);

% Plots
a1 = axes;
XTick = datenum(['01 Nov 1999'; '01 Jan 2000'; '01 Mar 2000'; '01 May 2000'; '01 Jul 2000'])'
ph(1) = plot(t, c, 'o', 'MarkerSize', 2, 'MarkerEdgeColor', [.8 .8 .8])
hold on
ph(2) = plot(tSwf, chlSwf, 'k^')
ph(3) = plot(in.t(good), in.chl(good), 'ks', 'MarkerFaceColor', [.4 .4 .4]);
ph(4) = plot(t, cm, 'k', 'linewidth', 2);
hold off
datetick('x');
XLim = [datenum('01 Nov 1997') datenum('Jan 5 2000')];
set(gca, 'YLim', [0 1.5], 'XLim', XLim );
XTick = get(gca, 'XTick');
ylabel('\bf{Chl a (\mug l ^{-1})}');
xlabel('\bf{Year}')

a2 = axes;
ph(5)= plot(w.t, w.sst, 'k:');
hold on 
%plot(tmc, temp, 'k:');
hold off
set(gca, 'XLim', XLim, 'XTick', [], 'Color', 'None', 'YaxisLocation', 'right', 'XTickLabel', [], 'YLim', [22 31]);
ylabel('\bf{SST (^oC)}');
legend(ph, 'Mooring CHL', 'SeaWiFS CHL', 'in situ CHL','Mooring Running Mean', 'SST');


