function[diurnalCyclesAll2,datesAll2,cldIndicators2,vertResolutionVector,QCIndicatorVector,cycHours,timeVector,utcTimeVector,pblHeightVector,cldIndicatorVector,stationNum,lat,lon,alt,diurnalCyclesAll,timesAll,datesAll,timeDifsAll2,cldIndicators,not30IndSum]=buildDiurnalCyclesDatabaseNC(heightVec_nc1,heightVec_nc2,heightVec_nc3,heightVec_nc4,heightVec_nc5,heightVec_nc6,heightVec_nc7,heightVec_nc8,heightVec_nc9,heightVec_nc10,heightVec_nc11,heightVec_nc12,utcTime_nc1,utcTime_nc2,utcTime_nc3,utcTime_nc4,utcTime_nc5,utcTime_nc6,utcTime_nc7,utcTime_nc8,utcTime_nc9,utcTime_nc10,utcTime_nc11,utcTime_nc12,localTime_nc1,localTime_nc2,localTime_nc3,localTime_nc4,localTime_nc5,localTime_nc6,localTime_nc7,localTime_nc8,localTime_nc9,localTime_nc10,localTime_nc11,localTime_nc12,cloud_fracs_nc1,cloud_fracs_nc2,cloud_fracs_nc3,cloud_fracs_nc4,cloud_fracs_nc5,cloud_fracs_nc6,cloud_fracs_nc7,cloud_fracs_nc8,cloud_fracs_nc9,cloud_fracs_nc10,cloud_fracs_nc11,cloud_fracs_nc12,snr_grid_nc1,snr_grid_nc2,snr_grid_nc3,snr_grid_nc4,snr_grid_nc5,snr_grid_nc6,snr_grid_nc7,snr_grid_nc8,snr_grid_nc9,snr_grid_nc10,snr_grid_nc11,snr_grid_nc12,mask_for_snr1,mask_for_snr2,mask_for_snr3,mask_for_snr4,mask_for_snr5,mask_for_snr6,mask_for_snr7,mask_for_snr8,mask_for_snr9,mask_for_snr10,mask_for_snr11,mask_for_snr12,startYear,stationNum,lat,lon,alt)


    [diurnalCyclesAll]=NaN.*ones(4464,12); 
    %There could be up to 4464 cycles (365 days per year for 12 years) and
    %up to 12 profiles per smooth diurnal cycle (hourly from 9AM-8PM)
    %actually running dates using 31 days/month, so have to allow up to
    %4464
    [timesAll]=NaN.*ones(4464,12);
    [datesAll]=NaN.*ones(4464,3);
    [timeDifsAll]=NaN.*ones(4464,1);
    [cldIndicators]=NaN.*ones(4464,12);
    [vertResolutions]=NaN.*ones(4464,12); 
    [QCIndicators]=NaN.*ones(4464,12);
    [not30IndSum]=0;
    
    doy=NaN.*ones(12*31,2);
    ctr=1;
    for i=1:12
        for j=1:31
            doy(ctr,1)=i;
            doy(ctr,2)=j;
            ctr=ctr+1;
        end
    end
                        
    
    cycleidx=1;
    
    
    for i =1:size(doy,1)
        try 
            [~,smoothDiurnalCycle_nc,polyEvalTimes_nc,~,~,~,~,~,~,~,~,~,~,~,~,~,~,smoothResolutionCurve_nc,negIndVector2_nc,~,~,cloud_fracs_nc_idx,not30Indsum_nc,timeDif]=getDiurnal_nc(doy(i,1),doy(i,2),startYear,heightVec_nc1,snr_grid_nc1,mask_for_snr1,localTime_nc1,utcTime_nc1,cloud_fracs_nc1);
            datesAll(cycleidx,1)=doy(i,1);
            datesAll(cycleidx,2)=doy(i,2);
            datesAll(cycleidx,3)=startYear;
            cldIndicators(cycleidx,1:size(cloud_fracs_nc_idx,2))=cloud_fracs_nc_idx;
            timeDifsAll(cycleidx)=timeDif;
            vertResolutions(cycleidx,1:size(smoothResolutionCurve_nc,2))=smoothResolutionCurve_nc;
            QCIndicators(cycleidx,1:size(negIndVector2_nc,2))=negIndVector2_nc;
            diurnalCyclesAll(cycleidx,1:size(smoothDiurnalCycle_nc,2))=smoothDiurnalCycle_nc; 
            timesAll(cycleidx,1:size(polyEvalTimes_nc,2))=polyEvalTimes_nc; 
            not30IndSum=not30IndSum+not30Indsum_nc;
            cycleidx=cycleidx+1;
        catch
            disp("Insufficient data");
        end      
    end
    
    for i =1:size(doy,1)
        try 
            [~,smoothDiurnalCycle_nc,polyEvalTimes_nc,~,~,~,~,~,~,~,~,~,~,~,~,~,~,smoothResolutionCurve_nc,negIndVector2_nc,~,~,cloud_fracs_nc_idx,not30Indsum_nc,timeDif]=getDiurnal_nc(doy(i,1),doy(i,2),startYear+1,heightVec_nc2,snr_grid_nc2,mask_for_snr2,localTime_nc2,utcTime_nc2,cloud_fracs_nc2);
            datesAll(cycleidx,1)=doy(i,1);
            datesAll(cycleidx,2)=doy(i,2);
            datesAll(cycleidx,3)=startYear+1;
            cldIndicators(cycleidx,1:size(cloud_fracs_nc_idx,2))=cloud_fracs_nc_idx;
            timeDifsAll(cycleidx)=timeDif;
            vertResolutions(cycleidx,1:size(smoothResolutionCurve_nc,2))=smoothResolutionCurve_nc;
            QCIndicators(cycleidx,1:size(negIndVector2_nc,2))=negIndVector2_nc;
            diurnalCyclesAll(cycleidx,1:size(smoothDiurnalCycle_nc,2))=smoothDiurnalCycle_nc; 
            timesAll(cycleidx,1:size(polyEvalTimes_nc,2))=polyEvalTimes_nc; 
            not30IndSum=not30IndSum+not30Indsum_nc;
            cycleidx=cycleidx+1;
        catch
            disp("Insufficient data");
        end      
    end
    
    for i =1:size(doy,1)
        try 
            [~,smoothDiurnalCycle_nc,polyEvalTimes_nc,~,~,~,~,~,~,~,~,~,~,~,~,~,~,smoothResolutionCurve_nc,negIndVector2_nc,~,~,cloud_fracs_nc_idx,not30Indsum_nc,timeDif]=getDiurnal_nc(doy(i,1),doy(i,2),startYear+2,heightVec_nc3,snr_grid_nc3,mask_for_snr3,localTime_nc3,utcTime_nc3,cloud_fracs_nc3);
            datesAll(cycleidx,1)=doy(i,1);
            datesAll(cycleidx,2)=doy(i,2);
            datesAll(cycleidx,3)=startYear+2;
            cldIndicators(cycleidx,1:size(cloud_fracs_nc_idx,2))=cloud_fracs_nc_idx;
            timeDifsAll(cycleidx)=timeDif;
            vertResolutions(cycleidx,1:size(smoothResolutionCurve_nc,2))=smoothResolutionCurve_nc;
            QCIndicators(cycleidx,1:size(negIndVector2_nc,2))=negIndVector2_nc;
            diurnalCyclesAll(cycleidx,1:size(smoothDiurnalCycle_nc,2))=smoothDiurnalCycle_nc; 
            timesAll(cycleidx,1:size(polyEvalTimes_nc,2))=polyEvalTimes_nc; 
            not30IndSum=not30IndSum+not30Indsum_nc;
            cycleidx=cycleidx+1;
        catch
            disp("Insufficient data");
        end      
    end
    for i =1:size(doy,1)
        try 
            [~,smoothDiurnalCycle_nc,polyEvalTimes_nc,~,~,~,~,~,~,~,~,~,~,~,~,~,~,smoothResolutionCurve_nc,negIndVector2_nc,~,~,cloud_fracs_nc_idx,not30Indsum_nc,timeDif]=getDiurnal_nc(doy(i,1),doy(i,2),startYear+3,heightVec_nc4,snr_grid_nc4,mask_for_snr4,localTime_nc4,utcTime_nc4,cloud_fracs_nc4);
            datesAll(cycleidx,1)=doy(i,1);
            datesAll(cycleidx,2)=doy(i,2);
            datesAll(cycleidx,3)=startYear+3;
            cldIndicators(cycleidx,1:size(cloud_fracs_nc_idx,2))=cloud_fracs_nc_idx;
            timeDifsAll(cycleidx)=timeDif;
            vertResolutions(cycleidx,1:size(smoothResolutionCurve_nc,2))=smoothResolutionCurve_nc;
            QCIndicators(cycleidx,1:size(negIndVector2_nc,2))=negIndVector2_nc;
            diurnalCyclesAll(cycleidx,1:size(smoothDiurnalCycle_nc,2))=smoothDiurnalCycle_nc; 
            timesAll(cycleidx,1:size(polyEvalTimes_nc,2))=polyEvalTimes_nc; 
            not30IndSum=not30IndSum+not30Indsum_nc;
            cycleidx=cycleidx+1;
        catch
            disp("Insufficient data");
        end      
    end
    for i =1:size(doy,1)
        try 
            [~,smoothDiurnalCycle_nc,polyEvalTimes_nc,~,~,~,~,~,~,~,~,~,~,~,~,~,~,smoothResolutionCurve_nc,negIndVector2_nc,~,~,cloud_fracs_nc_idx,not30Indsum_nc,timeDif]=getDiurnal_nc(doy(i,1),doy(i,2),startYear+4,heightVec_nc5,snr_grid_nc5,mask_for_snr5,localTime_nc5,utcTime_nc5,cloud_fracs_nc5);
            datesAll(cycleidx,1)=doy(i,1);
            datesAll(cycleidx,2)=doy(i,2);
            datesAll(cycleidx,3)=startYear+4;
            cldIndicators(cycleidx,1:size(cloud_fracs_nc_idx,2))=cloud_fracs_nc_idx;
            timeDifsAll(cycleidx)=timeDif;
            vertResolutions(cycleidx,1:size(smoothResolutionCurve_nc,2))=smoothResolutionCurve_nc;
            QCIndicators(cycleidx,1:size(negIndVector2_nc,2))=negIndVector2_nc;
            diurnalCyclesAll(cycleidx,1:size(smoothDiurnalCycle_nc,2))=smoothDiurnalCycle_nc; 
            timesAll(cycleidx,1:size(polyEvalTimes_nc,2))=polyEvalTimes_nc; 
            not30IndSum=not30IndSum+not30Indsum_nc;
            cycleidx=cycleidx+1;
        catch
            disp("Insufficient data");
        end      
    end
    for i =1:size(doy,1)
        try 
            [~,smoothDiurnalCycle_nc,polyEvalTimes_nc,~,~,~,~,~,~,~,~,~,~,~,~,~,~,smoothResolutionCurve_nc,negIndVector2_nc,~,~,cloud_fracs_nc_idx,not30Indsum_nc,timeDif]=getDiurnal_nc(doy(i,1),doy(i,2),startYear+5,heightVec_nc6,snr_grid_nc6,mask_for_snr6,localTime_nc6,utcTime_nc6,cloud_fracs_nc6);
            datesAll(cycleidx,1)=doy(i,1);
            datesAll(cycleidx,2)=doy(i,2);
            datesAll(cycleidx,3)=startYear+5;
            cldIndicators(cycleidx,1:size(cloud_fracs_nc_idx,2))=cloud_fracs_nc_idx;
            timeDifsAll(cycleidx)=timeDif;
            vertResolutions(cycleidx,1:size(smoothResolutionCurve_nc,2))=smoothResolutionCurve_nc;
            QCIndicators(cycleidx,1:size(negIndVector2_nc,2))=negIndVector2_nc;
            diurnalCyclesAll(cycleidx,1:size(smoothDiurnalCycle_nc,2))=smoothDiurnalCycle_nc; 
            timesAll(cycleidx,1:size(polyEvalTimes_nc,2))=polyEvalTimes_nc; 
            not30IndSum=not30IndSum+not30Indsum_nc;
            cycleidx=cycleidx+1;
        catch
            disp("Insufficient data");
        end      
    end
    for i =1:size(doy,1)
        try 
            [~,smoothDiurnalCycle_nc,polyEvalTimes_nc,~,~,~,~,~,~,~,~,~,~,~,~,~,~,smoothResolutionCurve_nc,negIndVector2_nc,~,~,cloud_fracs_nc_idx,not30Indsum_nc,timeDif]=getDiurnal_nc(doy(i,1),doy(i,2),startYear+6,heightVec_nc7,snr_grid_nc7,mask_for_snr7,localTime_nc7,utcTime_nc7,cloud_fracs_nc7);
            datesAll(cycleidx,1)=doy(i,1);
            datesAll(cycleidx,2)=doy(i,2);
            datesAll(cycleidx,3)=startYear+6;
            cldIndicators(cycleidx,1:size(cloud_fracs_nc_idx,2))=cloud_fracs_nc_idx;
            timeDifsAll(cycleidx)=timeDif;
            vertResolutions(cycleidx,1:size(smoothResolutionCurve_nc,2))=smoothResolutionCurve_nc;
            QCIndicators(cycleidx,1:size(negIndVector2_nc,2))=negIndVector2_nc;
            diurnalCyclesAll(cycleidx,1:size(smoothDiurnalCycle_nc,2))=smoothDiurnalCycle_nc; 
            timesAll(cycleidx,1:size(polyEvalTimes_nc,2))=polyEvalTimes_nc; 
            not30IndSum=not30IndSum+not30Indsum_nc;
            cycleidx=cycleidx+1;
        catch
            disp("Insufficient data");
        end      
    end
    for i =1:size(doy,1)
        try 
            [~,smoothDiurnalCycle_nc,polyEvalTimes_nc,~,~,~,~,~,~,~,~,~,~,~,~,~,~,smoothResolutionCurve_nc,negIndVector2_nc,~,~,cloud_fracs_nc_idx,not30Indsum_nc,timeDif]=getDiurnal_nc(doy(i,1),doy(i,2),startYear+7,heightVec_nc8,snr_grid_nc8,mask_for_snr8,localTime_nc8,utcTime_nc8,cloud_fracs_nc8);
            datesAll(cycleidx,1)=doy(i,1);
            datesAll(cycleidx,2)=doy(i,2);
            datesAll(cycleidx,3)=startYear+7;
            cldIndicators(cycleidx,1:size(cloud_fracs_nc_idx,2))=cloud_fracs_nc_idx;
            timeDifsAll(cycleidx)=timeDif;
            vertResolutions(cycleidx,1:size(smoothResolutionCurve_nc,2))=smoothResolutionCurve_nc;
            QCIndicators(cycleidx,1:size(negIndVector2_nc,2))=negIndVector2_nc;
            diurnalCyclesAll(cycleidx,1:size(smoothDiurnalCycle_nc,2))=smoothDiurnalCycle_nc; 
            timesAll(cycleidx,1:size(polyEvalTimes_nc,2))=polyEvalTimes_nc; 
            not30IndSum=not30IndSum+not30Indsum_nc;
            cycleidx=cycleidx+1;
        catch
            disp("Insufficient data");
        end      
    end
    for i =1:size(doy,1)
        try 
            [~,smoothDiurnalCycle_nc,polyEvalTimes_nc,~,~,~,~,~,~,~,~,~,~,~,~,~,~,smoothResolutionCurve_nc,negIndVector2_nc,~,~,cloud_fracs_nc_idx,not30Indsum_nc,timeDif]=getDiurnal_nc(doy(i,1),doy(i,2),startYear+8,heightVec_nc9,snr_grid_nc9,mask_for_snr9,localTime_nc9,utcTime_nc9,cloud_fracs_nc9);
            datesAll(cycleidx,1)=doy(i,1);
            datesAll(cycleidx,2)=doy(i,2);
            datesAll(cycleidx,3)=startYear+8;
            cldIndicators(cycleidx,1:size(cloud_fracs_nc_idx,2))=cloud_fracs_nc_idx;
            timeDifsAll(cycleidx)=timeDif;
            vertResolutions(cycleidx,1:size(smoothResolutionCurve_nc,2))=smoothResolutionCurve_nc;
            QCIndicators(cycleidx,1:size(negIndVector2_nc,2))=negIndVector2_nc;
            diurnalCyclesAll(cycleidx,1:size(smoothDiurnalCycle_nc,2))=smoothDiurnalCycle_nc; 
            timesAll(cycleidx,1:size(polyEvalTimes_nc,2))=polyEvalTimes_nc; 
            not30IndSum=not30IndSum+not30Indsum_nc;
            cycleidx=cycleidx+1;
        catch
            disp("Insufficient data");
        end      
    end
    for i =1:size(doy,1)
        try 
            [~,smoothDiurnalCycle_nc,polyEvalTimes_nc,~,~,~,~,~,~,~,~,~,~,~,~,~,~,smoothResolutionCurve_nc,negIndVector2_nc,~,~,cloud_fracs_nc_idx,not30Indsum_nc,timeDif]=getDiurnal_nc(doy(i,1),doy(i,2),startYear+9,heightVec_nc10,snr_grid_nc10,mask_for_snr10,localTime_nc10,utcTime_nc10,cloud_fracs_nc10);
            datesAll(cycleidx,1)=doy(i,1);
            datesAll(cycleidx,2)=doy(i,2);
            datesAll(cycleidx,3)=startYear+9;
            cldIndicators(cycleidx,1:size(cloud_fracs_nc_idx,2))=cloud_fracs_nc_idx;
            timeDifsAll(cycleidx)=timeDif;
            vertResolutions(cycleidx,1:size(smoothResolutionCurve_nc,2))=smoothResolutionCurve_nc;
            QCIndicators(cycleidx,1:size(negIndVector2_nc,2))=negIndVector2_nc;
            diurnalCyclesAll(cycleidx,1:size(smoothDiurnalCycle_nc,2))=smoothDiurnalCycle_nc; 
            timesAll(cycleidx,1:size(polyEvalTimes_nc,2))=polyEvalTimes_nc; 
            not30IndSum=not30IndSum+not30Indsum_nc;
            cycleidx=cycleidx+1;
        catch
            disp("Insufficient data");
        end      
    end
    for i =1:size(doy,1)
        try 
            [~,smoothDiurnalCycle_nc,polyEvalTimes_nc,~,~,~,~,~,~,~,~,~,~,~,~,~,~,smoothResolutionCurve_nc,negIndVector2_nc,~,~,cloud_fracs_nc_idx,not30Indsum_nc,timeDif]=getDiurnal_nc(doy(i,1),doy(i,2),startYear+10,heightVec_nc11,snr_grid_nc11,mask_for_snr11,localTime_nc11,utcTime_nc11,cloud_fracs_nc11);
            datesAll(cycleidx,1)=doy(i,1);
            datesAll(cycleidx,2)=doy(i,2);
            datesAll(cycleidx,3)=startYear+10;
            cldIndicators(cycleidx,1:size(cloud_fracs_nc_idx,2))=cloud_fracs_nc_idx;
            timeDifsAll(cycleidx)=timeDif;
            vertResolutions(cycleidx,1:size(smoothResolutionCurve_nc,2))=smoothResolutionCurve_nc;
            QCIndicators(cycleidx,1:size(negIndVector2_nc,2))=negIndVector2_nc;
            diurnalCyclesAll(cycleidx,1:size(smoothDiurnalCycle_nc,2))=smoothDiurnalCycle_nc; 
            timesAll(cycleidx,1:size(polyEvalTimes_nc,2))=polyEvalTimes_nc; 
            not30IndSum=not30IndSum+not30Indsum_nc;
            cycleidx=cycleidx+1;
        catch
            disp("Insufficient data");
        end      
    end
    for i =1:size(doy,1)
        try 
            [~,smoothDiurnalCycle_nc,polyEvalTimes_nc,~,~,~,~,~,~,~,~,~,~,~,~,~,~,smoothResolutionCurve_nc,negIndVector2_nc,~,~,cloud_fracs_nc_idx,not30Indsum_nc,timeDif]=getDiurnal_nc(doy(i,1),doy(i,2),startYear+11,heightVec_nc12,snr_grid_nc12,mask_for_snr12,localTime_nc12,utcTime_nc12,cloud_fracs_nc12);
            datesAll(cycleidx,1)=doy(i,1);
            datesAll(cycleidx,2)=doy(i,2);
            datesAll(cycleidx,3)=startYear+11;
            cldIndicators(cycleidx,1:size(cloud_fracs_nc_idx,2))=cloud_fracs_nc_idx;
            timeDifsAll(cycleidx)=timeDif;
            vertResolutions(cycleidx,1:size(smoothResolutionCurve_nc,2))=smoothResolutionCurve_nc;
            QCIndicators(cycleidx,1:size(negIndVector2_nc,2))=negIndVector2_nc;
            diurnalCyclesAll(cycleidx,1:size(smoothDiurnalCycle_nc,2))=smoothDiurnalCycle_nc; 
            timesAll(cycleidx,1:size(polyEvalTimes_nc,2))=polyEvalTimes_nc; 
            not30IndSum=not30IndSum+not30Indsum_nc;
            cycleidx=cycleidx+1;
        catch
            disp("Insufficient data");
        end      
    end
    
uniquetimesAll = unique(timesAll(:,:));
numtimes = sum(~isnan(uniquetimesAll));
uniquetimesAll = squeeze(uniquetimesAll(1:numtimes));
uniquetimesAll = uniquetimesAll.';
timesAll2 = NaN.*ones(size(timesAll,1),numtimes);
diurnalCyclesAll2=NaN.*ones(size(diurnalCyclesAll,1),numtimes);
cldIndicators2=NaN.*ones(size(cldIndicators,1),numtimes);
vertResolutions2=NaN.*ones(size(vertResolutions,1),numtimes);
QCIndicators2=NaN.*ones(size(QCIndicators,1),numtimes);

    for cycles = 1:size(timesAll,1)
        for uniques = 1:numtimes
            if find(timesAll(cycles,:)==uniquetimesAll(uniques))>0
                timesAll2(cycles,uniques)=uniquetimesAll(uniques);
            else
                timesAll2(cycles,uniques)=NaN;
            end
        end
    end
    

    
    %build snrforcontour
    for i = 1:size(timesAll2,1)
        for j = 1:size(timesAll2,2)
            if j<=size(timesAll,2) && timesAll2(i,j)==timesAll(i,j)
                diurnalCyclesAll2(i,j)=diurnalCyclesAll(i,j);
                vertResolutions2(i,j)=vertResolutions(i,j);
                QCIndicators2(i,j)=QCIndicators(i,j);
                cldIndicators2(i,j)=cldIndicators(i,j);
            elseif j<=size(timesAll,2) & (find(timesAll2(i,:)==timesAll(i,j))>0)
                k=find(timesAll2(i,:)==timesAll(i,j));
                diurnalCyclesAll2(i,k)=diurnalCyclesAll(i,j);
                vertResolutions2(i,k)=vertResolutions(i,j);
                QCIndicators2(i,k)=QCIndicators(i,j);
                cldIndicators2(i,k)=cldIndicators(i,j);
            end
        end
    end
    
    datesAll2=datesAll(any(~isnan(diurnalCyclesAll2),2),:);
    timeDifsAll2=timeDifsAll(any(~isnan(diurnalCyclesAll2),2),:);
    vertResolutions2=vertResolutions2(any(~isnan(diurnalCyclesAll2),2),:);
    QCIndicators2=QCIndicators2(any(~isnan(diurnalCyclesAll2),2),:);
    cldIndicators2=cldIndicators2(any(~isnan(diurnalCyclesAll2),2),:);
    diurnalCyclesAll2=diurnalCyclesAll2(any(~isnan(diurnalCyclesAll2),2),:);
    
    cycHours=uniquetimesAll./60;
    cycHours=cycHours';
    
    utcTimeVector=NaN.*ones((size(diurnalCyclesAll2,1)*size(cycHours,1)),1);
    timeVector=NaN.*ones((size(diurnalCyclesAll2,1)*size(cycHours,1)),1);
    cldIndicatorVector=NaN.*ones((size(diurnalCyclesAll2,1)*size(cycHours,1)),1);
    pblHeightVector=NaN.*ones((size(diurnalCyclesAll2,1)*size(cycHours,1)),1);
    vertResolutionVector=NaN.*ones((size(diurnalCyclesAll2,1)*size(cycHours,1)),1);
    QCIndicatorVector=NaN.*ones((size(diurnalCyclesAll2,1)*size(cycHours,1)),1);
    
    idxctr=1;
    for i =1:size(diurnalCyclesAll2,1)
        for j=1:size(cycHours,1)
            a = '2009-05-17 00:00';
            if datesAll2(i,1)<10
                month=strcat('0',int2str(datesAll2(i,1)));
            else
                month=int2str(datesAll2(i,1));
            end
            
            if datesAll2(i,2)<10
                day=strcat('0',int2str(datesAll2(i,2)));
            else
                day=int2str(datesAll2(i,2));
            end
            
            if cycHours(j)<10
                hour=strcat('0',int2str(cycHours(j)));
            else
                hour=int2str(cycHours(j));
            end
            
            b = strcat(int2str(datesAll2(i,3)),'-',month,'-',day,{' '},hour,':00'); 
            b=char(b);
            numHours = hours(diff(datetime({a; b}, 'InputFormat', 'yyyy-MM-dd HH:mm')));
            numHours = numHours + 24.*(numHours < 0);
            timeVector(idxctr)=numHours;
            utcTimeVector(idxctr)=numHours-timeDifsAll2(i);
            
            pblHeightVector(idxctr)=diurnalCyclesAll2(i,j);
            vertResolutionVector(idxctr)=vertResolutions2(i,j);
            QCIndicatorVector(idxctr)=QCIndicators2(i,j); 
            cldIndicatorVector(idxctr)=cldIndicators2(i,j); 
            idxctr=idxctr+1;
        end
    end
    
    pblHeightVector(find(isnan(pblHeightVector)))=1.e+15;
    cldIndicatorVector(find(isnan(cldIndicatorVector)))=1.e+15;
    vertResolutionVector(find(isnan(vertResolutionVector)))=1.e+15;
    QCIndicatorVector(find(isnan(QCIndicatorVector)))=1.e+15;
    %timesAll2=timesAll2(any(~isnan(timesAll2),2),:);


%D = duration('84394:00','Format','hh:mm');
%D2=datetime('2009-05-17 00:00')+D;

    
end