Viewing contents of file '../idllib/ghrs/pro/calfos_ccs0.pro'
pro calfos_ccs0,name,config,h,areas
;+
;			CALFOS_ccs0
;
; Read aperture area table
;
; CALLING SEQUENCE:
;	calfos_ccs0,name,config,h,areas
;
; INPUTS:
;	name - ccs0 table name
;	config - configuration vector (from CALFOS_RD)
;	
; INPUT/OUTPUTS:
;	h - FITS header for the observation
; OUTPUTS:
;	coef - vector of areas
;		area(0) = upper
;		area(1) = lower
;
; HISTORY:
;	version 1.0  D. Lindler  Jan 1990
;-
;---------------------------------------------------------------------------
;
; read table
;
	fname = strtrim(name)
	if fname eq '' then return		;Do we need the areas?
	tab_read,fname,tcb,tab
;
; add history
;
	hist = 'Aperture area table: '+fname
	sxaddhist,hist,h
	if !dump gt 0 then print,hist
;
; extract columns to be searched
;
	detector = strtrim(config(0))
	aper_id = strtrim(config(1))

	det = tab_val(tcb,tab,'DETECTOR')
	aper = tab_val(tcb,tab,'APER_ID')
	aper_pos = tab_val(tcb,tab,'APER_POS')
	aper_area = tab_val(tcb,tab,'APER_AREA')
	nrows = n_elements(det)
;
; search table for correct detector and aper_id
;

	areas = replicate(-1.0d0,2)
	for i=0,nrows-1 do begin
		if (strtrim(aper(i)) eq aper_id) and $
		   (strtrim(det(i)) eq detector) then begin

			case strtrim(aper_pos(i)) of
			   'UPPER': areas(0) = aper_area(i)
			   'LOWER': areas(1) = aper_area(i)
			   else:
			endcase
		endif
	endfor
;
; check if we found both upper and lower value
;
	if min(areas) lt 0 then begin
	    print,'CALFOS_CCS0 - rows in ccs0 not found for '+fgwa_id+' '+$
			detector+' for both APER_POS'
	    retall
	endif
return
end