; $Id: darplot.pro,v 1.2 2002/01/14 20:59:26 amunter Exp $
PRO darplot,t2d=t2d
;;
;; read the '.dar' files for area detector
;;

darf=pickfile(filter='*.dar',/READ,title='Select a TASCOM .dar file')

on_ioerror,bad
openr,unit,darf,/get_lun
junk=''
fir=''
readf,unit,junk
fir=readword(junk,0)
while fir ne '#siz' do begin
    readf,unit,junk
    fir=readword(junk,0)
endwhile

ddx=readword(junk,1)
ddy=readword(junk,3)
dd=bytarr(ddx,ddy)
readf,unit,dd
print,total(dd)
dd=transpose(dd)
if keyword_set (t2d) then tvscl,dd $
else begin


    x=findgen(ddy)

    dy=fltarr(ddy)

    for j=0,ddy-1 do dy(j)=total(dd(j,*))
    plot,x,dy,psym=4,  $
      ystyle=1
;  /ylog,yrange=[1e-2,1e4]
    errplot,x,dy-sqrt(dy),dy+sqrt(dy)
endelse


;tvscl,dd
;expand,dd,512,512,aa
;ma=max(aa)
;aa=aa/ma*255
;dissolve,aa,siz=16



goto,done

bad:
    aux=0
    print,"Cann't read array file: ",darf
done:
end
