; NAME: ; time_translate.pro (v1.0) ; ; ; PURPOSE: ; Reads the temperature log file created by the Lakeshore during a cooldown, ; converts the Lakeshore time into a value in seconds and writes out a new ; file with an additional column for the calculated time in seconds. ; ; CALLING SEQUENCE: ; time_translate, infile, outfile ; ; ; INPUTS: ; infile full path name of the input data file ; outfile full path name of the new output data file ; ; ; KEYWORD PARAMETERS: ; none ; ; ; OUTPUTS: ; none ; ; ; EXAMPLE: ; IDL> time_translate, './file1.txt', './file2.txt' ; ; ; MODIFICATION HISTORY: ; Created by: ; Ernie Morse, IDTL, October 9, 2003 ; Pro time_translate, infile, outfile ; read in the timing file readcol, infile, lst, c1, d1, d2, d3, d4, c2, c3, c4, a, b, heat, c1rate, $ d1rate, format='(A, F, F, F, F, F, F, F, F, F, F, F, F, F)' ; loop over the Lakeshore times, converting each one to a Julian day and ; then converting that to a value in seconds. ; but first, create an array to hold the Julian day values jday = dblarr(n_elements(lst)) for tcount = 0l, n_elements(lst) - 1 do begin time_fields = strsplit(lst[tcount], ',', /extract) ; time_fields array elements are month, day, year, hour, minutes, ; seconds, millisconds, in that order. The first 6 are needed as input ; to the julday function m = double(time_fields[0]) d = double(time_fields[1]) y = double(time_fields[2]) h = double(time_fields[3]) mn = double(time_fields[4]) s = double(time_fields[5]) jday[tcount] = julday(m, d, y, h, mn, s) endfor ; convert day to seconds time_s = jday * 24d * 60d * 60d ; only relative time is needed, so first time will be taken as zero and ; all other times will be relative to that. time_s = time_s - time_s[0] ; open the output file for writing openw, outlun, outfile, /get_lun ; write the values back out to the file, adding a column for the time in ; seconds. colheaders = string('LST', format = '(A13)') + $ string('T_S', format = '(A19)') + $ string('C1', format = '(A8)') + $ string('D1', format = '(A10)') + $ string('D2', format = '(A10)') + $ string('D3', format = '(A10)') + $ string('D4', format = '(A10)') + $ string('C2', format = '(A10)') + $ string('C3', format = '(A10)') + $ string('C4', format = '(A10)') + $ string('A', format = '(A10)') + $ string('B', format = '(A10)') + $ string('Heat %', format = '(A13)') + $ string('C1Rate', format = '(A10)') + $ string('D1Rate', format = '(A10)') printf, outlun, colheaders for i = 0, n_elements(lst) - 1 do begin outline = lst[i] + string(time_s[i], format='(F10.1)') + $ string(c1[i], format='(F10.3)') + $ string(d1[i], format='(F10.3)') + $ string(d2[i], format='(F10.3)') + $ string(d3[i], format='(F10.3)') + $ string(d4[i], format='(F10.3)') + $ string(c2[i], format='(F10.3)') + $ string(c3[i], format='(F10.3)') + $ string(c4[i], format='(F10.3)') + $ string(a[i], format='(F10.3)') + $ string(b[i], format='(F10.3)') + $ string(heat[i], format='(F10.3)') + $ string(c1rate[i], format='(F10.3)') + $ string(d1rate[i], format='(F10.3)') printf, outlun, outline endfor free_lun, outlun End