hurricane='isabel';
rep='total_wind\';
VAD_wd=[];
VAD_wd_pt=[];
VAD_ws=[];
files=dir(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\',hurricane,'\data\',rep,'*1.5*.dat']); 
for fil= 1:67%length(files)
    sweepfile=files(fil).name;
    data=load(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\',hurricane,'\data\',rep,sweepfile]);
    temp_wd=data(72,2);
    data=data(60:250,:);
    u_NaN=find(~isnan(data(:,1)));
    VAD_ws=[VAD_ws;mean(data(u_NaN,1))];
    segment_wd=data(u_NaN,2);
    for i=1:length(segment_wd)
        ang(i)=(segment_wd(i)*pi)/180;
        if ang(i)<=pi/2
            u(i)=-sin(ang(i));
            v(i)=-cos(ang(i));
            
            
        elseif ang(i) > pi/2 & ang(i) <= pi
            ang(i)=ang(i)-pi/2;
            u(i)=-cos(ang(i));
            v(i)=sin(ang(i));
            
        elseif ang(i) > pi & ang(i) <= 3*pi/2
            ang(i)=ang(i)-pi;
            u(i)=sin(ang(i));
            v(i)=cos(ang(i));
            
        elseif ang(i) > 3*pi/2 & ang(i) <=2* pi
            ang(i)=ang(i)-3*pi/2;
            u(i)=cos(ang(i));
            v(i)=-sin(ang(i));
        else
            u(i)=NaN;
            v(i)=NaN;
        end
        
    end
    
    
    
    u_NaN=find(~isnan(u));
    U=mean(u(u_NaN));
    V=mean(v(u_NaN));
    
    if U >0 & V >0
        alpha=atan(U/V);
        alpha=pi+alpha;
        
    elseif U >0 & V <0
        alpha=-atan((V/U));
        alpha=3*pi/2+alpha;
        
    elseif U <0 & V >0
        alpha=-atan((V/U));
        alpha=pi/2+alpha;
        
    elseif U <0 & V <0
        alpha=atan(U/V);
    else
        alpha=NaN;
    end
    alpha=rad2deg(alpha);
    temp=alpha;
    VAD_wd=[VAD_wd;temp];
    VAD_wd_pt=[VAD_wd_pt;temp_wd];
end

