FUNCTION get_slcorfact_raw, input
;
; This routine returns the Ti_poly phase 1 stray light correction 
;  factor of the nearest time. 
;
; IDL> factor=get_slcorfact_raw(XRT_index)
; IDL> factor=get_slcorfact_raw('19-feb-2013 12:00')
;
; HISTORY : 2-Mar-2015 : initial version. (9-may-2012 -- 31-dec-2014)
;           23-Sep-2015 : data updated for the whole phase 1
;                         (9-may-2012 -- 14-jun-2015).
;           19-Feb-2019 : modified to a function to get the nearest 
;                           time value found in the genx file. 
chk=size(input)
dtype= chk[chk[0]+1]
if dtype eq 8 then tt1=anytim(input.date_obs,/sec)-1e9 $
              else tt1=anytim(input,/sec)-1e9     
;** Note: -1e9 : use smaller number to avoid losing lower digits. **
;
if n_params() eq 1 then begin
   ps = path_sep()
   dir_util = get_logenv('$SSW_XRT') + ps + 'idl' + ps + 'util' + ps
   restgen,file=dir_util+'coef_arr1',index,factor
;  help,index,factor
endif
;
secarr=anytim(index.date_obs,/sec)-1e9
abs_dif=abs(secarr-tt1)
dummy=min(abs_dif,ss_min)
out_factor=factor(ss_min(0))
;
return,out_factor
;
FIN:
end
