function [lcl,ftime,flag]=lcl_to_lidar_load(LCL,timer)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Created by: Neil Lareau (neil.lareau@utah.edu)
% Created on: 4-25-2011
% Purpose: Read in the king air one second flight data and interpolate to
% the radar time stamps. We'll specifically be looking at vertical velocity
% measured from the gust probe and an assortment of liquid water and
% droplet variables
%
% Please note that the directory structure will need to be modified
% depending on where the actual data resides and if the naming convenction
% changes
%
% input: case_name = prefix in filename for the case (e.g., 'rf08_apr19')
%        tm_name  = date/time of flight, as in filename
%                      (e.g., '20110419.154753_155956')
%        timemx = time matrix associated with the radar data, we'll need
%                 these timestamps for the interpolation
%
% output: wwind2=vertical velocity interpolated to radar timeseries
%         lwc2 = liquid water (hot wire) interp.
%         fssp2 = fssp liquid water interp.
%         fsspnum2= fssp number concentrations
%         ydist2 = distance lake relative in y
%         time = time vector associated with the above data 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%         
flag=0;

flighttime=LCL(:,1)./86400 + 734504;
flighttime=permute(flighttime,[2 1]);
lcl1=LCL(:,2);
%%
%now lets find the start time of the radar data
time=timer;
starttime=time(1);
stoptime=time(end);

%find the flight time closest to the start and stop times
[junk,index]=min(abs(flighttime-starttime));
[junk,index2]=min(abs(flighttime-stoptime));
index2=index2;%+1; %make sure it goes just a little longer than we're interested in
%check to see if the data overlaps fully before interp is performed
if stoptime>flighttime(end)
    display('WARNING DATA DOES NOT FULLY OVERLAP');
    %lcl=zeros(index2-index,1).*nan;
    flag =1;
    %return
elseif starttime<flighttime(1)
    display('WARNING DATA DOES NOT FULLY OVERLAP');
    %lcl=zeros(index2-index,1).*nan;

    flag=1;
    %return
end

    
    
%now interpolate the data to the flight times
lcl=interp1(flighttime(index:index2),lcl1(index:index2),time);
ftime=interp1(flighttime(index:index2),flighttime(index:index2),time);


