;****************************************** ; Look for data gaps and fill them in ;****************************************** pro insert_blanks,data,time_offset,height,missing ;****************************************************** ; Constants ;****************************************************** ; Find array sizes num_heights=n_elements(height) numtimes=n_elements(time_offset) ;******************************************* ; Get the expected time interval (data_int) between shots ;******************************************* delta_time=time_offset delta_time=[delta_time[1:numtimes-1],delta_time[numtimes-1]] delta_time=delta_time-time_offset hist_mode,missing,1,delta_time,data_int ;****************************************** ; Fill any gap that is larger than data_int ;****************************************** gap=data_int*2.0 ;****************************************** ; Create temporary arrays to hold the filled in data ;****************************************** ; New time array newtime=make_array(numtimes+10000,/double,value=missing) newtime[0]=time_offset[0] ;set the first element ; New data array if size(data,/n_dimensions) eq 1 then begin dim=1 newdata=make_array(numtimes+10000,/float,value=missing) newdata[0,*]=data[0] ;set the first element endif else if size(data,/n_dimensions) eq 2 then begin dim=2 newdata=make_array(numtimes+10000,num_heights,/float,value=missing) newdata[0,*]=data[0,*] ;set the first element endif ; Delta t between two successive time measurements spacing=lonarr(numtimes) ;****************************************** ; find the missing time intervals and replace with missing data values ;****************************************** ; Index for new time array j=-0L ; Loop through the times for i=0L,numtimes-2 do begin spacing[i+1]=time_offset[i+1]-time_offset[i] ;print,'t1',time_offset[i],'t2',time_offset[i+1],'sp',spacing[i+1],$ ; format='(A2,1X,I8,1X,A2,1X,I8,1X,A2,1X,I3)' if spacing[i+1] gt gap then begin x=fix(spacing[i+1]/data_int) if x*data_int+time_offset[i] eq time_offset[i+1] then x=x-1 for k=1.0,x do begin j=j+1.0 newtime[j]=time_offset[i]+k*data_int if dim eq 2 then begin newdata[j,*]=missing ;print,'j',j,'nt',newtime[j],'nd',newdata[j,0],$ ; format='(A2,1X,I8,1X,A2,1X,I12,1X,A2,1X,I12)' endif else if dim eq 1 then begin newdata[j]=missing ;print,'j',j,'nt',newtime[j],'nd',newdata[j],$ ; format='(A2,1X,I8,1X,A2,1X,I12,1X,A2,1X,I12)' endif endfor j=j+1 newtime[j]=time_offset[i+1] if dim eq 2 then begin newdata[j,*]=data[i+1,*] ;print,'j',j,'nt',newtime[j],'nd',newdata[j,0],$ ; format='(A2,1X,I8,1X,A2,1X,I12,1X,A2,1X,I12)' endif else if dim eq 1 then begin newdata[j,*]=data[i+1] ;print,'j',j,'nt',newtime[j],'nd',newdata[j],$ ; format='(A2,1X,I8,1X,A2,1X,I12,1X,A2,1X,I12)' endif endif else begin j=j+1 newtime[j]=time_offset[i+1] if dim eq 2 then begin newdata[j,*]=data[i+1,*] ;print,'j',j,'nt',newtime[j],'nd',newdata[j,0],$ ; format='(A2,1X,I8,1X,A2,1X,I12,1X,A2,1X,I12)' endif else if dim eq 1 then begin newdata[j,*]=data[i+1] ;print,'j',j,'nt',newtime[j],'nd',newdata[j],$ ; format='(A2,1X,I8,1X,A2,1X,I12,1X,A2,1X,I12)' endif endelse endfor ; cut the arrays down to their size time_offset=newtime[0:j] if dim eq 2 then begin data=newdata[0:j,*] endif else if dim eq 1 then begin data=newdata[0:j] endif return end