function wtv=smooth()
profile_dir='E:/C17FSR/Wind_Profile_Analysis';
Streamline_data_dir='E:/C17FSR/0714-90/Matfiles';
event_dir='E:/C17FSR/Event';

load('profile_info.mat')
load('wtv_info.mat')
load('event_info.mat')

numprof=length(profile_info);
for j=1:numprof
    time_profile(j)=profile_info(j).time;
end

testday=input('Test day 1-6:  ');

numofevents=length(event(testday).time_event);

eventnum=input(['Pick event number (1-',num2str(numofevents),'): '])

hevent=imshow(char(event(testday).file_event(eventnum)))

iind=find(time_profile<event(testday).time_event(eventnum),1,'last')
load(fullfile(profile_dir,char(profile_info(iind).filename)))

iind=find(wtv_time<event(testday).time_event(eventnum),1,'last');
load(char(wtv_files(iind)))
lidar= File_Cleaner_V3(lidar,20,1.005)
scan=scangen(lidar,'rhi');
nscans=length(scan);

if nscans>1
    scannum=input(['Pick scan number 1-',num2str(nscans),': ']);
elseif nscans==0
    stop
else
    scannum=1;
end

u=profile.u;
v=profile.v;
AZ=lidar.azimuth(scan(scannum).ind,:);
EL=lidar.elevation(scan(scannum).ind,:);
XD=lidar.xd(scan(scannum).ind,1:end);
YD=lidar.yd(scan(scannum).ind,1:end);
ZD=lidar.zd(scan(scannum).ind,1:end);
RWS=lidar.RWS(scan(scannum).ind,:);
SNR=lidar.SNR(scan(scannum).ind,:);
STARTTIME=lidar.start_time;
DECTIME=lidar.lidar_decimal_time(scan(scannum).ind);
RHOD=sqrt(XD.^2+YD.^2);
[cm,ii]=min((profile.heights-1000).^2);
zh=profile.heights(ii:end);
prof=vvp_regression_RHI(RHOD,ZD,RWS,SNR,lidar.ranges,AZ,EL,zh);

[na,nr]=size(ZD);
uu=prof.rho*sind(AZ(1,1));
vv=prof.rho*cosd(AZ(1,1));
ww=prof.w;
profile.heights=cat(2,prof.heights,profile.heights);
profile.u(ii:end)=uu;
profile.v(ii:end)=vv;
profile.w(ii:end)=ww;

profile.w(find(abs(profile.w)>6))=0.;
for ja=1:na
  ud=interp1(profile.heights,profile.u,ZD(ja,:),'pchip',0.);
  vd=interp1(profile.heights,profile.v,ZD(ja,:),'pchip',0.);
  wd=interp1(profile.heights,profile.w,ZD(ja,:),'pchip',0.); 
  VR(ja,:)=(sind(AZ(ja,1)).*cosd(EL(ja,1)))*ud+(cosd(AZ(ja,1)).*cosd(EL(ja,1)))*vd ...
      + sind(EL(ja,1))*wd;
end

RWSeff=RWS-VR;
wtv.AZ=AZ;
wtv.EL=EL;
wtv.XD=XD;
wtv.YD=YD;
wtv.ZD=ZD;
wtv.RWS=RWS;
wtv.RWSeff=RWSeff;
wtv.SNR=SNR;
wtv.STARTTIME=STARTTIME;
wtv.DECTIME=DECTIME;
wtv.RHOD=RHOD;
pd=sind(AZ).*XD+cosd(AZ).*YD;
hwtv=figure
hf=pcolor(pd,ZD,RWS-VR);
set(hf,'Edgecolor','none')
caxis([-15 15])
return