%
% Overlays evolution of b-deck maximum wind speed on WRT-AER event set wind
% speeds. "Ecintensity.m" must be run first. 
%
%  Copyright WindRiskTech, L.L.C., October 2010
%
%--------------------------------------------------------------------------
if storm(1:2) == 'AL'
    stormlc='al';
elseif storm(1:2) == 'EP'
    stormlc='ep';
elseif storm(1:2) == 'WP'
    stormlc='wp';
elseif storm(1:2) == 'IO'
    stormlc='io';
elseif storm(1:2) == 'SH'
    stormlc='sh';
end
stormnew=storm;
stormnew(1:2)=stormlc;
file=strcat('decks/b',stormnew,datea(1:4),'.dat');
fid=fopen(file,'r');
C=textscan(fid,'%s %f %d %*s %*s %*d %s %s %f %*[^\n]','delimiter',',');
st=fclose(fid);
dates=C{3};
ws=C{6};
q=max(size(dates));
imin=q;
for i=1:q,
    if dates(i) == str2num(datea)
        imin=i;
        break
    end
end    
wind=ws(imin:end);
year=floor(dates(imin:end)./1e6);
month=floor((dates(imin:end)-1e6.*year)./1e4);
day=floor((dates(imin:end)-1e6.*year-1e4.*month)/1e2);
hour=floor((dates(imin:end)-1e6.*year-1e4.*month-1e2.*day));
%
byear=floor(str2num(datea)./1e6);
bmonth=floor((str2num(datea)-1e6.*byear)./1e4);
bday=floor((str2num(datea)-1e6.*byear-1e4.*bmonth)/1e2);
bhour=floor((str2num(datea)-1e6.*byear-1e4.*bmonth-1e2.*bday));
%
q=max(size(year));
ndate=zeros(1,q);
for i=1:q,
    ndate(i)=datenum(double(year(i)),double(month(i)),double(day(i)),double(hour(i)),0,0);
end    
bndate=datenum(byear,bmonth,bday,bhour,0,0);
btime=double(ndate-bndate);
hold on
   k=plot(btime,transpose(wind),'y','linewidth',2);
hold off   
