;+
; NAME:
;     SXT_EXPOSURE_MAP
; PURPOSE:
;     use RD_OBS to make an image of where SXT was watching
; CATEGORY:
; CALLING SEQUENCE:
; INPUTS:
; OPTIONAL (KEYWORD) INPUT PARAMETERS:
; OUTPUTS:
; COMMON BLOCKS:
; SIDE EFFECTS:
; RESTRICTIONS:
; MODIFICATION HISTORY:
;     29-Jun-99, written by HSH
;     21-Apr-00, fixed (x1 lt 0) bug
;-

pro sxt_exposure_map, t1, t2, qstop = qstop
if n_elements(t1) eq 0 then begin
  t2 = anytim(!stime)-9.*3600
  t1 = anytim(t2 - 2.*24.*3600,/yo)
  t2 = anytim(t2,/yo)
endif
rd_obs,t1,t2,a,b,c,/sxtp,/quiet
img = intarr(1024,1024)
nc = n_elements(c)
dp_weight = [0,0,8,0,1]
for i = 0,nc-1 do begin
  xy = gt_center(c(i))
  x1 = xy(0)-c(i).shape_cmd(0)/2*2^gt_res(c(i))
; This set x=0 until just now (BNH, 21-Apr-00)
  if x1 lt 0 then x1 = 0
  x2 = xy(0)+c(i).shape_cmd(0)/2*2^gt_res(c(i))
  if x2 gt 1023 then x2 = 1023
  y1 = xy(1)-c(i).shape_cmd(1)/2*2^gt_res(c(i))
  if y1 lt 0 then y1 = 0
  y2 = xy(1)+c(i).shape_cmd(1)/2*2^gt_res(c(i))
  if y2 gt 1023 then y2 = 1023
  cornx = [x1,x2,x2,x1,x1]
  corny = [y1,y1,y2,y2,y1]
  img(x1:x2,y1:y2) = img(x1:x2,y1:y2)+dp_weight(gt_dp_rate(c(i)))
endfor
cen = sxt_cen(t1)
rr = get_rb0p(t1,/rad)/gt_pix_size()
rad = 180/!pi
xx = rr*cos(findgen(361)/rad) + cen(0) 
yy = rr*sin(findgen(361)/rad) + cen(1)
for i = 0, 360 do img(xx(i),yy(i)) = max(img)
rr = rr+1
xx = rr*cos(findgen(361)/rad) + cen(0) 
yy = rr*sin(findgen(361)/rad) + cen(1)
for i = 0, 360 do img(xx(i),yy(i)) = max(img)
rr = rr-1
xx = rr*cos(findgen(361)/rad) + cen(0) 
yy = rr*sin(findgen(361)/rad) + cen(1)
for i = 0, 360 do img(xx(i),yy(i)) = max(img)
wdef,0,256
tvscl,rebin(img,256,256)
xyouts,10,30,/dev,fmt_tim(c(0))+' to '
xyouts,10,10,/dev,fmt_tim(c(nc-1))
over
if keyword_set(qstop) ne 0 then stop
end
