function windpatch(t,lon,lat,r64,r50,r34);

% function windpatch(t,lon,lat,r64,r50,r34);

plot(lon,lat,'bo','markersize',4);
hold on;

for rval=1:3;    % loop through wind speeds (34kt, 50kt, 64kt)
    for j=1:length(t);    % loop through time/lat/lon
        
        if (rval==1)    % 34 kt winds
            ws='34';
            %colr=[1 1 .75];lwidth=1;
            colr=[1 0.9 0];lwidth=1;
        elseif (rval==2)    % 50 kt winds
            ws='50';
            colr=[1 .5 0];lwidth=2;
        else    % 64 kt winds
            ws='64';
            colr=[1 0 0];lwidth=2;
        end;
        eval(['r=r',ws,'(j,:);']);
    
        theta=0:pi/16:2*pi;
        R=NaN*ones(size(theta));
        del=abs(theta-pi/4); % NE
        q=find(del==min(del));   
        R(q)=r(1);
        del=abs(theta-7*pi/4);   % SE
        q=find(del==min(del));
        R(q)=r(2);    
        del=abs(theta-5*pi/4);   % SW
        q=find(del==min(del));
        R(q)=r(3);
        del=abs(theta-3*pi/4);  % NW
        q=find(del==min(del));
        R(q)=r(4);
        q=find(theta==0 | theta==max(theta));
        R(q)=( r(1)+r(2) )/2;
        q=find(isnan(R));
        q2=find(isfinite(R));  
        R(q)=interp1(theta(q2),R(q2),theta(q),'linear');
        
        x=R.*cos(theta); x=[x x(1)];
        y=R.*sin(theta); y=[y y(1)];
        
        %patch(lon(j)+x/60,lat(j)+y/60, ...
            %colr,'edgecolor','none');
        plot(lon(j)+x/60,lat(j)+y/60,'color',colr,'LineWidth',lwidth);
    end;
end;    % loop over j (lon,lat points)

% label each storm plot with time
    for j=1:length(t);
        gd=gregoriand(t(j));
        txt=[num2str(gd(2)),'/',num2str(gd(3)),' '];
        if (gd(4)<10) txt=[txt,'0']; end;
        txt=[txt,num2str(gd(4))];
        if (gd(5)<10) txt=[txt,'0']; end;
        txt=[txt,num2str(gd(5)),'Z'];
        text(lon(j)+.02*(max(lon)-min(lon)),lat(j)+.02*(max(lat)-min(lat)), ...
            txt,'fontsize',8,'horizontalalignment','left');
    end;
    
if length(t)==1  % Note storm position at deployment time
    gd=gregoriand(t);
    txt=[num2str(gd(2)),'/',num2str(gd(3)),' '];
    if (gd(4)<10) txt=[txt,'0']; end;
    txt=[txt,num2str(gd(4))];
    if (gd(5)<10) txt=[txt,'0']; end;
    txt=[txt,num2str(gd(5)),'Z'];

    title(['Storm shown at NHC forecast for ',txt,'.  Wind circles: 64/50/34kt winds']);
end;

plot(lon,lat,'.w','markersize',6);
hold off;
set(gca,'dataaspectratio',[1 1 1])
axis([min(lon)-max(max(r34))/60 max(lon)+max(max(r34)/60) ...
        min(lat)-max(max(r34))/60 max(lat)+max(max(r34))/60]);

%%%%%%%%%% END windpatch.m %%%%%%%%%%%

    
    
