function [vad,prof,lidar]=pro_analysis(FILENAME,firstgate,Max_Velocity,SNR_cutoff)

%
%*********************************************************************************************


% === IMPORT SCAN DATA ============================================

inputfiles=FILENAME;
clear vad

fid=fopen(FILENAME);
temp=read_Proc_profiles(fid,0.0);
tt=datevec(temp.start_time);
temp.timestamp=datenum([tt(1) tt(2) tt(3) tt(4) tt(5) tt(6)]);

[junk,temp.name]=fileparts(char(inputfiles));
temp.datet=datestr(temp.start_time,'mm/dd/yyyy');
lidar=temp;
[na,nr]=size(lidar.SNR);
vad=lidar;
meanSNR=mean(mean(lidar.SNR(:,nr-50:nr)));
%
% --- Filter --------------------------------------------------------
%disp('--------------------------------------------------------------------------------')
%Max_Velocity=25.;
%SNR_cutoff=1.015;
bad_beam_id=File_Cleaner_Vad(lidar.SNR(1:18,:), lidar.RWS(1:18,:),lidar.azimuth(1:18,:),firstgate,Max_Velocity,SNR_cutoff);
bad_beam_id(19:36,:)=File_Cleaner_Vad(lidar.SNR(19:36,:), lidar.RWS(19:36,:),lidar.azimuth(1:18,:),firstgate,Max_Velocity,SNR_cutoff);
bad_beam_id(37,:)=1;
%disp('Filtering Complete.')
poo=fclose(fid);
uu=find(bad_beam_id==0);
vad.RWS=lidar.RWS(uu);
vad.SNR=lidar.SNR(uu);
vad.Beta=lidar.Beta(uu);
vad.xd=lidar.xd(uu);
vad.yd=lidar.yd(uu);
vad.zd=lidar.zd(uu);
vad.azimuth=lidar.azimuth(uu);
vad.elevation=lidar.elevation(uu);
vad.ranges=lidar.ranges;

prof=vvp_regression(vad);
ind=find(prof.nind<3);
prof.beta(ind)=NaN;
prof.turb(ind)=NaN;
prof.vels(ind,:)=NaN;
prof.theta(ind)=NaN;
prof.u(ind)=NaN;
prof.v(ind)=NaN;
prof.w(ind)=NaN;
prof.Vh(ind)=NaN;
ind=find(abs(prof.u)>60 | abs(prof.v)>60  | abs(prof.w)>60);
prof.beta(ind)=NaN;
prof.turb(ind)=NaN;
prof.vels(ind,:)=NaN;
prof.theta(ind)=NaN;
prof.u(ind)=NaN;
prof.v(ind)=NaN;
prof.w(ind)=NaN;
prof.Vh(ind)=NaN;


return



