pro HXISBORESIGHT, TDOY,PITCH,YAW
common  hxiswidget,     comment
common  hxiscata, catplace

; Read HXIS_UVCAT.T80 containing the 15729 times (DOY 51.7927-328.366) for 
;    all 1980 records in the UVSP catalog
; The array index of the time closest to TDOY is the same as the number of
;    the required record in the HXIS_UVCAT.D80 catalog

if TDOY lt 51.5 or TDOY gt 328.5 then $
    widget_control, comment, set_value='Extrapolation outside catalog ' + $
                       'time range', /append

opsys_lgcl, part1='HXIS', discern='_', part2='CAT', $
          separate=1, dataplace=catplace, ok=ok, $
          instructme=['Enter your designation for the CATALOG '+$
                    'location, then return',$
              '     VMS    ex: SDAC::HXIS_CAT, ' + $
                    '$1$DIA4:[HXIS]',$
              '     UNIX   ex: $HXIS_CAT, /usr/users/Data']

if not(ok) then begin               ; error occurred 
    acknowledge, message=(['Progam will try to continue', $
                   'without pointing information.', $
                   'Also, temperature and emmission',$
                   'measures will not be possible.'])
    return          ; no place given to look for the catalogs
endif

;openr, /get_lun, IU, 'HXIS_CAT:HXIS_UVCAT.T80'
openr, /get_lun, IU, catplace + 'HXIS_UVCAT.T80'

TL = fstat(IU)          ; & TL = TL.REC_LEN/4
tl = 8000           ; 32000 byte records / 4

TT = assoc(IU, fltarr(TL))  &  TL = TL-1
A = TT(0)  
a = conv_vax_unix2(a)

M1 = min(abs(A-TDOY),REC)       ; Find closest time on record
if REC eq TL and TDOY gt A(TL) then begin
   A = TT(1)  &  a = conv_vax_unix2(a)  &  A = A(where(A gt 0))
   M2 = min(abs(A-TDOY),REC)
   if REC gt 0 or M2 lt M1 then REC = TL+1+REC else REC =TL
endif
free_lun, IU


;openr, /get_lun, IU, 'HXIS_CAT:HXIS_UVCAT.D80'
openr, /get_lun, IU, catplace + 'HXIS_UVCAT.D80'

UVCAT = assoc(IU, intarr(2))
UVSPREC = UVCAT(REC)            ; Read catalog record
free_lun, IU

YAW   = UVSPREC(1)/10.  &  PITCH = UVSPREC(0)/10.   ; spacecraft yaw and pitch

return & end


;========================================================================