;+ ;Procedure: tplot_ascii ;Purpose: ; Creates an ascii file for selected tplot variables. ;Input: ; Names names of tplot variables. May use glob patterns to specify ; a set of variables. ;Keywords: ; Ext: by default, a separate file will be created in the ; current directory with name tplot_name.txt. Use this ; keyword to set the .txt extension to a different extension. ; dir: Put output in dir as opposed to current working directory. ; precise: increases precision to maximum ;trange: array[2] of double or string. Specify time range for output. ;- pro tplot_ascii,names,trange=trange,ext=ext, dir=dir,precise=precise if not keyword_set(ext) then ext = '.txt' if not keyword_set(dir) then dir = '' else dir += '/' tvar=tnames(names) nv = n_elements(tvar) for n=0,nv-1 do begin nam=tvar[n] get_data,nam,data=d if keyword_set(d) then begin time = d.x data = d.y if keyword_set(trange) then begin tr=time_double(trange) w=where(time ge tr[0] and time le tr[1],c) time =time[w] data = data[w,*] endif else c=n_elements(time) openw,/get_lun,lun,dir+nam+ext,width=800 for i=0l,c-1 do begin printf,lun,time_string(time[i],precision=3),' ',reform(data[i,*]) endfor close,lun free_lun,lun endif endfor end