Viewing contents of file '../idllib/ghrs/pro/calhrs_xdef.pro'
pro calhrs_xdef,udls,u1,u2,ih,log
;
;+
;			calhrs_xdef
; routine to extract inital x-deflection information from udl and place results
; in header vector.
;
; CALLING SEQUENCE:
;	calhrs_xdef,udls,u1,u2,ih,log
;
; INPUTS:
;	udls - array of unique data logs
;	u1 - vector of beginning udl numbers for each header in ih.
;		(output from CALHRS_UDL)
;	u2 - vector of ending udl numbers (output from CALHRS_UDL)
;
; INPUT/OUTPUTS:
;	ih - headers for science data array
;		the following information is added to ih:
;		  words			value
;		   52		intial x-deflection without comb-addition
;					or doppler offsets
;		
; OPTIONAL INPUT/OUTPUT:
;	log - history log (string array)
;
; HISTORY:
;	version 1  D. Lindler   Mar 89
;
;-
;---------------------------------------------------------------------------
;
; determine which udl to use for each science record
;
	u = u2>u1
	bad=where(u lt 0, u_found)
	if u_found gt 0 then begin
		u(bad)=0		;use first udl
	   	hist='HRSCAL_XDEF -- warning: missing unique data log(s)'
		if !dump eq 0 then printf,!textunit,hist else print,hist
		if n_params(0) gt 4 then sxaddhist,hist,log
	endif
;
; extract intial xdeflections
;
	ixdef=udls(37,*)
	xdcal=udls(85)/50.0
	xdcalp=udls(99)/500.0
	xdefs = ixdef + xdcal + (ixdef-2048)*xdcalp
	xdefs=fix(xdefs+0.5)
	ih(52,0)=transpose(xdefs(u))
	return
	end