function [lambda]=rhi_wavelength




files=dir(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\frances\data\modified\meanless\rhi\*316.0_*.dat']); 

for fil=1:length(files)
    sweepfile=files(fil).name;
    
    
    data=load(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\frances\data\modified\meanless\rhi\',sweepfile]);
    el=data(length(data),:);
    el=el';
    eli=0.5:0.1:8.5;
    
    rhi=data(1:length(data)-1,:);
    rg=33.35:66.7:199*66.7+33.35;
    [ri,zi,rhii]=new_rhi(el,rg,rhi,150,50);
    z_rhi=[];
    u=find(zi(:,1)>=200 & zi(:,1) <= 1000);
    rhii=rhii(u,:);
    ri=ri(u,:);
    zi=zi(u,:);
    delta_x=abs(ri(1,1)-ri(1,2));
    
    for height=1:length(u)
        temp=rhii(height,:);
        
                  %%%%%%%%%%%%%Filtering%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            
%             u_NaN = find(~isnan(temp));
%         temp2=temp(u_NaN)';
%         Fs=1/(delta_x);
%         NFFT=length(temp2);
%         NumUniquePts = ceil((NFFT+1)/2);
%         f = (0:NumUniquePts-1)*Fs/NFFT;
%        
%         
%         if length(temp2)> 40
%              [b,a] = butter(5,limit_inf/(Fs/2),'high');  
%             Hd = dfilt.df2t(b,a); 
%             zfilt = filter(Hd,temp2);
%            
%             if limit_sup/(Fs/2) <= 1
%                 [b,a] = butter(5,limit_sup/(Fs/2));
%                 Hd = dfilt.df2t(b,a);        
%                 zfilt = filter(Hd,zfilt);
%             end
%           temp(u_NaN)=zfilt';
%       end
            
            
            %%%%%%%%%%Fin de %%%%%%%%%%filtering%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        
        
        z_rhi=[z_rhi,temp'];   
    end
    
    
    
  
    
    [li,col]=size(z_rhi);
    fqcy=[];
    psd=[];
%     for jj=1:col
%         [psd_final,t,f,f1,aver_FFT,check]=fft_analysis(z_rhi(:,jj),(1/delta_x(1)),rectwin(100),0,0,0);
%         [mfcy,nfcy]=size(fqcy);
%         [mpsd,npsd]=size(psd);
%         if length(f1) < mfcy
%             add=abs(length(f1)-mfcy);
%             add=NaN*ones(add,1);
%             f1=[f1;add];
%             fqcy=[fqcy f1];
%             
%             add=abs(length(aver_FFT)-mpsd);
%             add=NaN*ones(add,1);
%             aver_FFT=[aver_FFT;add];
%             psd=[psd aver_FFT];
%         elseif length(f1) > mfcy
%             add=abs(length(f1)-mfcy);
%             add=NaN*ones(add,nfcy);
%             fqcy=[fqcy;add];
%             fqcy=[fqcy f1];
%             
%             add=abs(length(aver_FFT)-mpsd);
%             add=NaN*ones(add,npsd);
%             psd=[psd;add];
%             psd=[psd aver_FFT];
%         elseif length(f1) == mfcy
%             fqcy=[fqcy f1];
%             psd=[psd aver_FFT];
%         end
%     end
%     lambda.fqcy=fqcy;
%     lambda.psd=psd
    lambda.ri=ri;
    lambda.zi=zi;
    lambda.z_rhi=z_rhi;
        save(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\frances\data\wavelength analysis\rhi\rect_rhi_',files(fil).name(12:17)],'lambda');

end



