sag — simple ASCII grid


The sag file format is used by the vfplot(1) program for representing vector fields defined on a grid.

The format is plain ASCII and consists of a single header line followed by a number of data lines

The header line describes the file and the grid it represents.

magic number

the literal string #sag

file format

the version of the sag file format, an integer (this document describes version 1)

grid dimensions

the dimensions of the grid, an integer

vector dimensions

the dimensions of the vectors, an integer

grid samples

the number of samples in each of the dimensions of the grid, one integer for each grid dimension

grid extent

the minimum and maximum values of the grid variable, two floats for each grid dimension


the tolerance to be used when interpreting the grid, a single float.

A data line consists of the grid coordinates and the vector components, separated by whitespace

The data lines are not required to be in any particular order, and there may be no data for some or all of the grid points. When being read, a data line is associated with a grid point if its position is a distance less than the tolerance specified in the header. When there is no such grid point the data line is discarded.


The following file describes a two dimensional 3x3 grid of two dimensional vectors.

#sag 1 2 2 3 3 0.0 1.0 0.0 1.0 0.01
0.0  0.0  3.0  3.0
0.0  0.5  1.2  3.2
0.5  0.5  2.3  3.2
1.0  0.5  1.7  5.1
1.0  1.0  1.1  3.2


J.J. Green ()