Viewing contents of file '../idllib/ghrs/pro/calfos_rdddt.pro'
pro calfos_rdddt,rname,name,config,pattern,h,ddt
;+
;			CALFOS_RDddt
;
; read disable diode file
;
; CALLING SEQUENCE:
;	calfos_rdddt,rname,name,config,pattern,h,ddt
;
; INPUTS:
;	rname - rootname of observation
;	name - reference file name
;	config - configuration vector (from CALFOS_RD)
;	pattern - pattern vector (from CALFOS_RD)
;
; INPUT/OUTPUTS:
;	h - FITS header
;
; OUTPUTS:
;	ddt - disabled diode vector (length = nchnls)
;
; HISTORY:
;	version 1.0 D. Lindler  Jan 1980
;	version 1.1 D. Neill	Mar 1992  reads ddt from ref file or .ulh file
;-
;--------------------------------------------------------------------------
; extract configuration and pattern info from input vectors
;
	detector = strtrim(config(0))
	fchnl = pattern(0)
	nchnls = pattern(1)
	overscan = pattern(2)
	nxsteps = pattern(3)
	ns_per_xstep = pattern(7)
	ns = pattern(8)
;
; extract ddt from appropriate location
;
	fname = strtrim(name)
	if fname eq '' then begin
;
; if required, read the ULH disabled diode table
;
		fname = strtrim(rname,2) + '.ulh'
		sxopen,1,fname,h2
		sxaddpar,h,'YXPITCH',sxpar(h2,'YXPITCH')
		sxaddpar,h,'YYPITCH',sxpar(h2,'YYPITCH')
		sxaddpar,h,'YXBASE',sxpar(h2,'YXBASE')
		ulh = sxread(1)
		ddt = ulh(321+fchnl:320+fchnl+nchnls)
		ddt = (ddt lt 0) or (ddt gt 32767)	;bad diodes = 1

	endif else begin
;
; read input file and check consistency
;
		sxopen,1,fname,href
		det = strtrim(sxpar(href,'detector',fname))
		ddt = sxread(1) eq 0

		if (det ne detector) and (det ne 'ANY') then begin
		    print,'CALFOS_RDDDT-- Reference file '+fname+' detector mismatch'
		    retall
		endif

		if n_elements(ddt) ne 512 then begin
		    print,'CALFOS_RDDDT - invalid vector length in file '+fname
		    retall
		endif
;
; extract correct portion
;
		ddt = ddt(fchnl:fchnl+nchnls-1)
	endelse
;
	hist = 'Disabled diode file: '+fname
	sxaddhist,hist,h
	if !dump gt 0 then print,hist
return
end