Viewing contents of file '../idllib/ghrs/pro/calfos_ccg2.pro'
pro calfos_ccg2,name,config,h,coef
;+
;			CALFOS_CCG2
;
; Read deadtime coefficient table
;
; CALLING SEQUENCE:
;	calfos_ccg2,name,config,h,coef
;
; INPUTS:
;	name - ccg2 table name
;	config - configuration vector (from CALFOS_RD)
;	
; INPUT/OUTPUTS:
;	h - FITS header for the observation
; OUTPUTS:
;	coef - vector of coefficients
;		    coef(0) - tau1
;			(1) - theshold
;			(2) - q0
;			(3) - q1
;			(4) - F
;			(5) - RSAT
;			(6) - R20
;			(7) - R5
;
; HISTORY:
;	version 1.0  D. Lindler  Jan 1990
;-
;---------------------------------------------------------------------------
;
; read table
;
	fname = strtrim(name)
	if fname eq '' then return		;Do we need the coef?
	tab_read,fname,tcb,tab
;
; add history
;
	hist = 'Deadtime coefficient table: '+fname
	sxaddhist,hist,h
	if !dump gt 0 then print,hist
;
; extract columns to be searched
;
	detector = strtrim(config(0))
	if detector eq 'AMBER' then detector=1 else detector=2
	det = tab_val(tcb,tab,'DETECTOR')
	good = where(det eq detector) & ngood=!err
	if ngood lt 1 then goto,not_found
	instrument = tab_val(tcb,tab,'INSTRUMENT',good)
	for i=0,ngood-1 do if strtrim(instrument(i)) eq 'FOS' then goto,found

not_found:
	print,'CALFOS_CCG2 - no row found in CCG2 for FOS '+detector+' detector'
	retall
;
; read values
;
found:  
	coef=dblarr(8)
	coef(0) = tab_val(tcb,tab,'TAU1',i)
	coef(1) = tab_val(tcb,tab,'THRESHOLD',i)
	coef(2) = tab_val(tcb,tab,'Q0',i)
	coef(3) = tab_val(tcb,tab,'Q1',i)
	coef(4) = tab_val(tcb,tab,'F',i)
	coef(5) = tab_val(tcb,tab,'RSAT',i)
	coef(6) = tab_val(tcb,tab,'R20',i)
	coef(7) = tab_val(tcb,tab,'R5',i)
return
end