;+ ; conv_ti2tt2000 ; ; To convert TIs to CDF_TT2000 times. ; ; Usage: ; IDL> conv_ti2tt2000, ti_arr, eptt2000_arr, s_est_utc ; ti_arr: Array of TI values in unsigned long integer (ulong) to be converted ; eptt2000_arr: the resultant CDF_TT2000 times are stored in long64 ; s_est_utc: Initial guess of UTC in string, e.g., '20170401000000'. Should be a single string. ; ; Caution: ; This procedure calls an executable /home/erg-sc/local/bin/ti2utc_from_file internally. ; The executable is available only on rferg unless compiled by yourself on your own platform. ; If you did, please change the full path of the above command at Line 46. ; ; This procedure (and ti2utc_from_file) will create two text files temporarily in the current ; working directory. Thus you should have a write permission there. ; ; Written by: T. Hori ; $LastChangedBy: c0004hori $ ; $LastChangedDate: 2017-04-25 10:53:59 +0900 (Tue, 25 Apr 2017) $ ; $LastChangedRevision: 756 $ ; $URL: https://ergsc-local.isee.nagoya-u.ac.jp/svn/ergsc_cdf/trunk/satellite/erg/hepe/conv_ti2tt2000.pro $ ;- pro conv_ti2tt2000, tis, eptt2000, s_est_utc, debug=debug if ~keyword_set(debug) then debug = 0 npar = n_params() if npar lt 2 or npar gt 3 then begin print, 'Usage: ' print, ' IDL> conv_ti2tt2000, TI_array, epoch_tt2000' print, ' TI_array: the input array containing TI values in unsigned long decimal number' print, ' epoch_tt2000: a named variable to which the resultant epoch values in TT2000 are returned' return endif if npar le 2 then s_est_utc = '20161220000000' randomstr = strjoin( strsplit(/ext, string( long(systime(/sec)) ) )) fn_tilist = 'ti_list'+randomstr+'.txt' fn_utclist = fn_tilist+'_out' if debug then begin & tm0 = systime(/sec) & print,'tm0=',tm0-tm0 & endif openw, fp, fn_tilist, /get_lun for i=0L, n_elements(tis)-1 do begin printf, fp, tis[i], format='(Z08)' endfor free_lun, fp if debug then begin & tm1 = systime(/sec) & print,'Generating '+fn_tilist+': ',tm1-tm0 & endif cmd = strjoin( $ ;[ '/usr/local/bin/ti2utc_from_file', fn_tilist, s_est_utc ], $ [ '/home/ergsc/ergsc-cdf/local/idl/ti2utc/ti2utc_from_file', fn_tilist, s_est_utc ], $ ' ' ) spawn, cmd, rslt if debug then begin & tm2 = systime(/sec) & print,'spawn+ti2utc: ',tm2-tm1 & endif ;Get the directory path where conv_ti2tt2000.pro and tmpl_utclist.sav exist stack = SCOPE_TRACEBACK(/structure) filename = stack[SCOPE_LEVEL()-1].filename dir = FILE_DIRNAME(filename) restore, dir + '/tmpl_utclist.sav' dat = read_ascii( fn_utclist, templ=tmpl_utclist ) if debug then begin & tm3 = systime(/sec) & print,'Reading utclist file: ',tm3-tm2 & endif yyyy = fix(strmid(dat.utcstr,0,4)) mo = fix(strmid(dat.utcstr,4,2)) dd = fix(strmid(dat.utcstr,6,2)) hh = fix(strmid(dat.utcstr,8,2)) mm = fix(strmid(dat.utcstr,10,2)) ss = fix(strmid(dat.utcstr,12,2)) ms = fix(strmid(dat.utcstr,14,3)) us = fix(strmid(dat.utcstr,17,3)) cdf_tt2000, eptt2000, yyyy,mo,dd,hh,mm,ss,ms,us,0, /compute_epoch file_delete, fn_tilist, /allow_nonexist file_delete, fn_utclist, /allow_nonexist return end