function ep_plot_dp(id, Date1, Date2)
% EP_PLOT_DP - Plot derived products of an ep mooring
%
% Use as: ep_plot_dp(ep, c)
%      or ep_plot_dp(ep, Date1, Date2)
% Inputs: ep = Eqpac mooring number(1 or 2)
%         Date1 = String representation of starting date (e.g. '01 jan 1998')
%         Date2 = String representation of ending date (e.g. '01 jan 1998')


% Brian Schlining
% 02 Mar 2000

warning off
ep_ini;                             % Load the header of each column of data (ColumnS) and the units (UnitS)



% Set the path to the data file depending on what type of machine this function is run from
switch lower(id)
case 'ep1'
   loc = '0 155W';
   FileName = 'ep1_specprr_full.nc';
   lon = -155;
   dat = ep1;
case 'ep2'
   loc = '2S 170W';
   FileName = 'ep2_specprr_full.nc';
   lon = -170;
   dat = ep2;
otherwise
   loc = [];
   return
end

FileLoc = fullfile(getOasisPath, 'eqpac', 'netcdf', FileName);

ep = netcdf(FileLoc);
X  = ep_cmplNc(ep);
ncquit(ep);

sdn = X.t;

% Prompt for input if no input arguments are specified
if nargin == 1 
   Date1 = max(sdn - 30);
   Date2 = max(sdn);
end

if nargin < 3
   Date1 = max(sdn - Date1);
   Date2 = max(sdn);
end

Position = get(0, 'ScreenSize');
Position = [Position(1:3) Position(4) - Position(4)*.1];



goodTime = find(sdn >= Date1 & sdn <= Date2); % Find Points within the Date Limits
if isempty(goodTime)
   goodTime = length(sdn);
end


%=================
% Check arguments
%=================
if nargin == 1
   Date1 = min(sdn);
   Date2 = max(sdn);
end

%==========================
% Plot attenuation coef (K). This is acutally KEd but we apply it to Lu 
%==========================
fh = figure;
set(fh, 'Position', Position)
plot(sdn(goodTime), X.K(goodTime,:));
ylabel('K [m^-^1]')
xlabel('Date')
title(['Attenuation Coeff. at ' loc])
datetick('x')
legend('412nm','443','490','510','555', 0)
setfontsize(7)
set(gca,'YLim',[0 1]);
grid

%=========================
% Plot attenuation length
%=========================
fh = figure;
set(fh, 'Position', Position)
plot(sdn(goodTime), 1./X.K(goodTime,:));
ylabel('1/K [m]')
xlabel('Date')
title(['Attenuation length at ' loc])
datetick('x')
legend('412nm','443','490','510','555', 0)
setfontsize(7)
set(gca,'YLim',[1 100], 'YScale', 'log');
grid

%=================================
% Plot Water-leaving radiance (Lw)
%=================================
fh = figure;
set(fh, 'Position', Position)
plot(sdn(goodTime), X.Lw(goodTime,:));
ylabel('Lw [\muW cm^-^2 nm^-^1 str^-^1]')
xlabel('Date')
title(['Water-Leaving radiance at ' loc])
datetick('x')
legend('412nm','443','490','510','555', 0)
setfontsize(7)
set(gca,'YLim',[0 1.2]);
grid

%==========
% Plot Rrs
%==========
fh = figure;
set(fh, 'Position', Position)
lambda = [412 443 490 510 555];
plot(sdn(goodTime), X.Rrs(goodTime, :),'-')
title(['Remote Sensing Reflectance at ' loc])
ylabel('Rrs [str^-^1]')
xlabel('Date')
datetick('x')
legend('412nm','443','490','510','555', 0)
setfontsize(7)
grid

%==============
% Plot OC2 CHL
%==============
fh = figure;
set(fh, 'Position', Position)
subplot(2,1,1)
plot(sdn(goodTime),X.oc_cov(goodTime, :))
title(['OC2 CHL at ' loc])
ylabel('Coeff. Variation (std/mean)')
datetick('x') %,12)
set(gca, 'YLim', [0 2]);
grid

subplot(2,1,2)
plot(sdn(goodTime), X.oc(goodTime, :), '-');
hold on
plot(sdn(goodTime), morel_chl2(X.K(goodTime,3), 490), '-', 'Color', [.8 .42 .2], 'lineWidth', 1.5);
hold off
datetick('x') %,12);
ylabel('OC2 [CHL]');
xlabel('Date')
legend('R15','R25','R35','R45', 'Morel',0);
set(gca, 'YLim', [0.01 100], 'YScale','log')
grid
setfontsize(7)



