[Thread Prev][Thread Next][Index]

Reading ASCII files in FERRET: problem solved



Steve Hankin recently solved a problem for me in reading
an ASCII file in FERRET.  He asked me to post his solution
to ferret_users.

The problem involved reading an ASCII data file of the form

 76 85
   -10.492  -42.000  -30.310
   -10.836  -41.000  -30.680
   -11.172  -40.000  -31.041
     .
     .
     .

The file contains three variables in two dimensions.  Each
line after the first is an (X,Y,Z) triple.  The first line is 
the row and column breakdown of the file data, in this case 
76 rows, 85 columns.

I needed to read the first two values in order to set up a grid to 
input the remainder of the data.

Steve's solution was as follows:

define symbol myskip 0            ! could be any value
define axis/x=1:1/npoints=1 one_pt
define grid/x=one_pt gg
file/grid=gg/skip=($myskip)/var=ny,nx ref3d.plt
define symbol nnx `nx`     ! note: grave accents for immediate execution
define symbol nny `ny`
cancel data ref3d.plt

	define symbol myskip `($myskip)+1`     ! increment definition
	DEFINE AXIS/X=1:($nnx):1 xrows
	DEFINE AXIS/Y=1:($nny):1 yrows
	DEFINE GRID/X=xrows/Y=yrows gdata
	FILE/VAR="xs,ys,zs"/GRID=gdata/skip=($myskip) ref3d.plt

In other words:

First, define a dummy grid and read the first two values, which are
stored in symbols nnx and nny.

Then input the data again, this time skipping the first line and
using the values stored in nnx and nny to define the data grid.

This did the trick.  Thanks, Steve.

Kim Rudeen


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / ERL / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement