function servlet_epplot(FileName, ep, c, Date1, Date2, LineColor) % SERVLET_EPPLOT - Creates png image file of ep data % % Use as: servlet_epplot(FileName, ep, c) % servlet_epplot(FileName, ep, c,LineType) % or servlet_epplot(FileName, ep, c, Date1, Date2, LineType) % Inputs: FileName = Name of the gif to save it as % ep = Eqpac mooring number(1 or 2) % c = Column Number or Vector of Column numbers % Date1 = String representation of starting date (e.g. '01 jan 1998') % Date2 = String representation of ending date (e.g. '01 jan 1998') % LineColor = string color or 1x3 Vector of color values % Brian Schlining % 12 Apr 1999 % 15 Apr 1999; Modified to handle multiple columns % 20 May 1999; warning off ep_ini; % Load the header of each column of data (ColumnS) and the units (UnitS) i = strcmp(ColumnS,'Decimal_Year'); x = ep_cmpl; % Read the data files in epX directories on tsunami numCols = length(c); %======================================= % Get the dates, Correct for Y2K issues %======================================= sdn = x(ep).dat(:,i); y2k = find(sdn >= 85 & sdn <= 99.9999); sdn(y2k) = sdn(y2k) + 1900; y2k = find(sdn >= 0 & sdn < 85); sdn(y2k) = sdn(y2k) + 2000; sdn = dy2date(sdn); % Get Dates %========================================================= % Refine the approximate dates to make them more accurate %========================================================= [Year Month Day Hour Minute Second] = datevec(sdn); i = strcmp(ColumnS,'Time'); Day = round(Day) + x(ep).dat(:,i)./2400; % Correct the day to the local time sdn = datenum(Year, Month, Day); %================= % Check arguments %================= if nargin < 4 Date1 = min(sdn); Date2 = max(sdn); LineColor = 'k'; elseif nargin == 4 LineColor = Date1; Date1 = min(sdn); Date2 = max(sdn); elseif nargin == 5 Date1 = datenum(Date1); Date2 = datenum(Date2); LineColor = 'k'; end if isempty(Date1); Date1 = min(sdn); end if isempty(Date2); Date2 = max(sdn); end %===================================================== % Make sure that color matrix is same size as numCols %===================================================== [rl cl] = size(LineColor); if isstr(LineColor) & (cl > rl) LineColor = LineColor'; end if numCols > 1 & rl ==1 & cl == 1 LineColor = repmat(LineColor,numCols,1); end GOOD = find(sdn >= Date1 & sdn <= Date2); % Find Points within the Date Limits sdn = sdn(GOOD); %figure('Visible','off','PaperPosition', [0 0 5 4]); for n = 1:numCols y = x(ep).dat(GOOD,c(n)); GOOD2 = find(~isnan(y)); y = y(GOOD2); sdn2 = sdn(GOOD2); hl(n) = plot(sdn2, y,'-'); set(hl(n),'Color',LineColor(n,:)) if n == 1 hold('on') end hp = plot(sdn2, y,'.'); set(hp,'Color',LineColor(n,:)) end xlabel('Date') if numCols == 1 ylabel(UnitsS(c)); title(ColumnS(c)); else legendS = [char(ColumnS(c)) char(UnitsS(c))]; legend(hl,legendS,0) end hold('off') dt = Date2- Date1; if dt <= 2 tick = 15; elseif dt > 2 & dt <= 50 tick = 6; elseif dt > 50 & dt <= 450 tick = 3; else tick = 10; end datetick('x',tick); set(gca,'XLim',[Date1 Date2]) writegif(FileName)