function m2_lookPrr(ndays)
% m2_lookPrr  - web image generator for M2 Mooring
% Generate gif images of data for the last (ndays) of data for web site.
%
% Use as: m2_lookPrr(ndays)
% Inputs: ndays = number of days of data to plot

% Erich Rienecker
% 01 Dec 1998
% 08 Jun 1999; Modified by Brian Schlining


%this area should contain everything that might need to be modified%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
datapath = fullfile(getOasisPath, 'm2', 'specprr');
imgpath  = fullfile(getOasisPath, 'web', 'extern', 'bog', 'images');
if ~nargin
   ndays = 7; %number of days to plot THIS IS WHERE YOU CHOOSE THE NUMBER OF DAYS TO DISPLAY
end

%===============================================
%Gets the file names, then sorts them in order.
%===============================================
filenameS = getfname(datapath);
filenameS = filenameS(3:end,:);
[r,c] = size(filenameS);
filenameN = str2num(filenameS);
filenameN = sort(filenameN);

%=============================================
%Extract the days (filenames) I want to plot.
%=============================================
year      = str2num(filenameS(:,1:4));
day       = str2num(filenameS(:,5:7));
filedates = jul2date(day, year);
good      = find(filedates >= (now - ndays));
if isempty(good)
    return;
end


%==========================================
% Load ndays worth of data while filtering
%==========================================
for i = 1:length(good)
   if i == 1
      data = readoasis(fullfile(datapath, filenameS(good(i),:)));
      [r c] = size(data);
   else
      buf = readoasis(fullfile(datapath,filenameS(good(i),:)));
      [r c] = size(buf);
      data = [data; buf];
   end
   Year{i} = year(good(i))*ones(1, r);
end

Year = [Year{:}]';
sdn  = jul2date(data(:,1), Year);

%===================
% Create the graphs
%===================
figure(1);
plot(sdn,data(:,2:7));
datetick('x',6);
xlabel('Date','FontSize',7);
ylabel('uwatts/cm2/nm','FontSize',7);
title('Surface PRR 620 ,M2','FontSize',7);

%set paper position
set(gca,'FontSize',5);
set(gcf,'PaperPosition',[0.25 0.25 4 3]);
legend('Ed412','Ed443','Ed490','Ed510','Ed555','Ed656',0);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5

figure(2);
plot(sdn,data(:,15:20));

datetick('x',6);
xlabel('Date','FontSize',7);
ylabel('uwatts/cm2/nm/str','FontSize',7);
title('Surface LU Satlantic Spectro, M2','FontSize',7);

%set paper position
set(gca,'FontSize',5);
set(gcf,'PaperPosition',[0.25 0.25 4 3]);
legend( 'Lu443', 'Lu490','Lu510','Lu555','Lu670','Lu683',0);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
figure(3);
plot(sdn,data(:,30:35));
datetick('x',6);
xlabel('Date','FontSize',7);
ylabel('uwatts/cm2/nm','FontSize',7);
title('10m Ed PRR-600 ,M2','FontSize',7);

%set paper position
set(gca,'FontSize',5);
set(gcf,'PaperPosition',[0.25 0.25 4 3]);
legend('Ed412','Ed443','Ed490','Ed510','Ed555','Ed656',0);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

figure(4);
plot(sdn,data(:,46:52));
datetick('x',6);
xlabel('Date','FontSize',7);
ylabel('uwatts/cm2/nm/str','FontSize',7);
title('10m LU PRR-600, M2','FontSize',7);

%set paper position
set(gca,'FontSize',5);
set(gcf,'PaperPosition',[0.25 0.25 4 3]);
legend( 'Lu443', 'Lu490','Lu510','Lu555','Lu670','Lu683',0);

