;+
;
; NAME: 
;       PROCESS_CRAB_RESP
;
; PURPOSE:
;       This main program obtains the predicted Crab flux for each observation
;        in the database as a function of angle and energy.  Should not be used
;        now, but components of this procedure may be examined and cannibalized
;
; CATEGORY:
;       BATSE, OCCULTS
;
; CALLING SEQUENCE:
;
;
; CALLS:
;	none
;
; INPUTS:
;       none explicit, only through commons;
;
; OPTIONAL INPUTS:
;	none
;
; OUTPUTS:
;       none explicit, only through commons;
;
; OPTIONAL OUTPUTS:
;	none
;
; KEYWORDS:
;	none
; COMMON BLOCKS:
;	none
;
; SIDE EFFECTS:
;	none
;
; RESTRICTIONS:
;	none
;
; PROCEDURE:
;	none
;
; MODIFICATION HISTORY:
;
;-
restore,'discsp_crab.sav',/verb
restore,'crab_resp.sav',/verb
apar=[.0025,2.12,fltarr(2)]

checkvar, crab_resp, fltarr(2,n_elements(crab))
checkvar, det_edges,fltarr(2,2,n_elements(crab))
checkvar, inradec,[83.516, 22.0197] ;use epoch 2000 not 1950 [82.89, 21.98]
istart=(where(total(abs(det_edges(*,0,*)),1) eq 0))(0)
help,istart
for i=istart, n_elements(crab)-1 do begin 
	 edges=discsp_edges(crab(i).(0),det=crab(i).det_id) 
	 det_edges(0,0,i) = edges(*,0:1) 
	 gro_point, [crab(i).zradec,crab(i).xradec],inradec, cos_lad,cos_spec 
	 for j=0,1 do begin 
		discsp_resp, edges(*,j) <1000. >3.0, !radeg*acos(cos_spec(crab(i).det_id)) <80., $
		apar,resp 
		 crab_resp(j,i)=resp 
	 endfor 
	 if i mod 100 eq 0 then begin
		help,i
		save,/verb,file='crab_resp.sav',/xdr,crab_resp,det_edges
		spawn,'purge crab_resp.sav'
	endif
endfor
save,file='crab_resp.sav',/xdr,crab_resp,det_edges

end
