%
%  Overlays a-deck track on event set. "Alltrplot.m" must be run first.
%
%  Copyright WindRiskTech, L.L.C., October, 2010
%  Last modified February 2011
%
%-------------------------------------------------------------
%
adeck=input('Use real-time .fst file (1) or adeck file (2)');
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;
if adeck == 1
    file=strcat(stormnew,datea(1:4),'.fst');
else
    file=strcat('decks/a',stormnew,datea(1:4),'.dat');
end    
fid=fopen(file,'r');
C=textscan(fid,'%s %f %d %*s %s %*d %s %s %f %*[^\n]','delimiter',',');
st=fclose(fid);
bas=C{1};
dates=C{3};
model=C{4};
xlats=C{5};
xlongs=C{6};
nend=max(size(xlats));
jbeg=nend;
jend=1;
for j=1:nend,
    TF1=strcmp(model(j,1),'OFCL');
    TF2=strcmp(model(j,1),'JTWC');
    if dates(j,1) == str2num(datea) & (TF1 == 1 | TF2 == 1)
        jbeg=min(j,jbeg);
        jend=max(j,jend);
    end
end  
jsize=jend-jbeg+1;
if jsize < 1
    disp(' ')
    disp('.fst deck for appropriate forecast time not found')
    return
end    
lats=zeros(1,jsize);
longs=zeros(1,jsize);
hemi=zeros(1,jsize);
for i=jbeg:jend,
    ii=i-jbeg+1;
    clear ulats ulongs
    ulats=char(xlats(i));
    ulongs=char(xlongs(i));
    mend=max(size(ulats));
    lats(ii)=0.1.*str2num(ulats(1:mend-1));
    mend=max(size(ulongs));
    longs(ii)=0.1.*str2num(ulongs(1:mend-1));
    hemi(ii)=ulongs(mend);
end    
%
if char(hemi(1)) == 'W'
    longs=360-longs;
end    
q=max(size(lats));
%
hold on
k=m_plot(longs,lats,'r','linewidth',3);
k1=m_plot(longs,lats,'.b');
hold off