hurricane='isabel'; 
%rep=input('enter directory to work on \n','s') 
 files=dir(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\',hurricane,'\data\*swp*EV**dat']);
 test=81%input('modify az for the right scanning strategy \n'); %will add NaN if there are missing azimuths from the record
 
for fil=1:2%4:length(files)
    
    sweepfile=files(fil).name;
    data=load(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\',hurricane,'\data\',sweepfile]);
   az=data(length(data),:);
    data=data(1:length(data)-1,:);
     u_360=find(az>=360);
     az(u_360)=az(u_360)-360;
      mod_az=az;  
 
mod_data=data;
u=find(data < -150);
mod_data(u)=NaN;

 if length(az)< test
     
[li,co]=size(mod_data);
 az=az';
 ent=(az);
 ent1=ent(1:length(ent)-1);
 ent2=ent(2:length(ent));
dif=round(ent2-ent1)-1;
v=find(dif<0);
dif(v)=dif(v)+360;
v=find(dif >=1);
mod_az=az(1:v(1));
mod_data2=mod_data(:,1:v(1));

if length(v)>1
 for i=1:length(v)-1
    add=(1:dif(v(i)))';
    miss_az=az(v(i))*ones(dif(v(i)),1)+add;
    miss_data=NaN*ones(li,dif(v(i)));
    mod_az=[mod_az;miss_az;az(v(i)+1:v(i+1))];
    mod_data2=[mod_data2 miss_data mod_data(:,v(i)+1:v(i+1))];
end
end
add=(1:dif(v(length(v))))';
miss_az=az(v(length(v)))*ones(dif(v(length(v))),1)+add;
miss_data=NaN*ones(li,dif(v(length(v))));
mod_az=[mod_az;miss_az;az(v(length(v))+1:length(az))];
mod_data2=[mod_data2 miss_data mod_data(:,v(length(v))+1:co)];

mod_data=mod_data2;
mod_az=mod_az';
 end
 save(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\',hurricane,'\data\modified\',sweepfile],'mod_data','mod_az','-ascii')
end  

