
att_struct
cba_struct
gen_struct
bcs_struct
hxt_struct
sxt_struct
wbs_struct
;
if (n_elements(temps) eq 0) then begin
    ;
    infil = filnam_fix('refdata:cba*')
    ;infil = filnam_fix('refdata:cba9109*')
    ff = findfile(infil)
    ;
    for ifil=0,n_elements(ff)-1 do begin
	infil = ff(ifil)
	print, 'Now processing ', infil
	;
	rd_pointer, infil, pointer, recsiz
	rd_fheader, infil, fheader, ndset
	;
	dset_arr = indgen(ndset)
	;
	rd_cba, infil, dset_arr, index, data, roadmap
	;
	temps0 = byte(data.basic(0,2,*),0, 64,ndset)
	fi0 = index.dp_time(3)
	time0 = index.time
	day0  = index.day
	;
	if (ifil eq 0) then begin
	    temps = temps0
	    fi = fi0
	    time = time0
	    day = day0
	end else begin
	    temps = append_mat(temps, temps0)
	    fi = [fi, fi0]
	    time = [time, time0]
	    day = [day, day0]
	end
    end
    ;
    tim = (day-min(day))*86400000 + time
    tim = tim/1000./60/60/24.	;convert to days
    ;
    sort_time, day, time, ss
    fi   = fi(ss)
    temps= temps(*,ss)
    tim  = tim(ss)
end
;
int2ex, 0, min(day), daytim
dd = fmt_tim(daytim, day_str, time_str)
;
laser
if (!d.name eq 'X') then begin
    loadct, 12
    window,0,retain=2
end
;
goto, skip
skip:
;
ss = where(fi/64 mod 2 eq 1)
mat = temps(*,ss)
x = tim(ss)
dx = deriv_arr(x)*60*60.*24.
;
plot, [0,0], [0,0], xrange=[0,max(x)], yrange=[-10,30], xtitle='Days past ' + day_str, $
	ytitle = 'Temperature (C)'
for i=18,26 do begin
    ;oplot, x, ahk_conv(mat(i,*),i+64), color=(i-19)*20
    yy = mat(i,*)
    icutoff = 50
    if (min(yy) lt icutoff) then begin
	print, string(7b), 'Sensor ', i, ' cutoff at', icutoff
	ssss = where(yy lt icutoff)
	print, ' actual min is', min(yy), ' and there are', n_elements(ssss), ' values below the cutoff'
    end
    sss = where((yy lt 170) and (yy gt icutoff))
    if (sss(0) ne -1) then begin
	xx = x(sss)
	yy = yy(sss)
	dx = deriv_arr(xx)*60*60.*24.
	plot_gaps, xx, ahk_conv(yy,i+64), gaps=dx, color=(i-19)*20
    end
end
stop

plot, [0,0], [0,0], xrange=[0,max(x)], yrange=[-5,35], xtitle='Days past ' + day_str
for i=31,33 do begin
    ;oplot, x, ahk_conv(mat(i,*),i+64), color=(i-19)*20
    plot_gaps, x, ahk_conv(mat(i,*),i+64), gaps=dx, color=(i-31)*20
end
stop
;
ss = where(fi/64 mod 2 eq 0)
mat = temps(*,ss)
x = tim(ss)
dx = deriv_arr(x)*60*60*24.
plot, [0,0], [0,0], xrange=[0,max(x)], yrange=[0,30], xtitle='Days past ' + day_str
;for i=2,12 do begin
for i=5,6 do begin
    plot_gaps, x, ahk_conv(mat(i,*),i), gaps=dx, color=(i-2)*10
end

;
end
