pro rdascii,flnm ; ; Read data from ascii file flnm: ; file = dialog_pickfile() print,' ' print,'file=',file print,' ' openr,lu,file,/get_lun ; on_ioerror,bad hdr = strarr(4) line = '' line = string(line,format="(a80)") ; next_frame: nx=1 & ny=1 ; ; Read and print 4-line header: ; print,' ' for i=0,3 do begin readf,lu,line hdr(i) = strtrim(line,2) print,hdr(i) endfor print,' ' ; ; nx, xx: ; xlab = '' readf,lu,line nx = 0 reads,line,nx,xlab,format="(3x,i4,5x,a)" xlab = strtrim(xlab) xx = fltarr(nx) if nx gt 1 then begin readf,lu,xx endif ; ; ny, yy: ; ylab = '' readf,lu,line ny = 0 reads,line,ny,ylab,format="(3x,i4,5x,a)" ylab = strtrim(ylab) yy = fltarr(ny) if ny gt 1 then readf,lu,yy ; ; Now the data: ; zz = fltarr(nx,ny) readf,lu,zz print,' ' answer = '' read,answer,prompt='Print this frame? (y/n/q): ' if (answer eq 'q') then return if (answer eq 'y') then begin print,'nx = ',nx,' xx = ' print,xx if (ny gt 1) then begin print,'ny = ',ny,' yy = ' print,yy endif print,'Data = ' print,zz endif read,answer,prompt='Plot this frame? (y/n/q): ' if (answer eq 'q') then return if (answer eq 'y') then begin if (ny eq 1) then begin plot,xx,zz,title=hdr(0)+' '+hdr(1),$ yrange=[min(zz),max(zz)],$ xtitle=xlab,ytitle=ylab,xstyle=1,ystyle=1 endif else if (nx eq 1) then begin plot,zz,yy,title=hdr(0)+' '+hdr(1),$ xrange=[min(zz),max(zz)],$ xtitle=xlab,ytitle=ylab,xstyle=1,ystyle=1 endif else begin help,zz contour,zz,xx,yy,title=hdr(0)+' '+hdr(1),$ xtitle=xlab,ytitle=ylab,xstyle=1,ystyle=1 endelse endif ; goto,next_frame bad: print,'>>> rdascii: i/o error reading from file ',flnm return end