1 
2 /*--------------------------------------------------------------------
3  *    The GMT-system:	@(#)gmt_grd.h	3.18  01/13/00
4  *
5  *	Copyright (c) 1991-2000 by P. Wessel and W. H. F. Smith
6  *	See COPYING file for copying and redistribution conditions.
7  *
8  *	This program is free software; you can redistribute it and/or modify
9  *	it under the terms of the GNU General Public License as published by
10  *	the Free Software Foundation; version 2 of the License.
11  *
12  *	This program is distributed in the hope that it will be useful,
13  *	but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *	GNU General Public License for more details.
16  *
17  *	Contact info: www.soest.hawaii.edu/gmt
18  *--------------------------------------------------------------------*/
19 /*
20  * grd.h contains the definition for a GMT-SYSTEM Version >= 2 grd file
21  *
22  * grd is stored in rows going from west (xmin) to east (xmax)
23  * first row in file has yvalue = north (ymax).
24  * This is SCANLINE orientation.
25  *
26  * Author:      Paul Wessel
27  * Date:        26-MAY-1990
28  * Revised:     21-OCT-1998
29  */
30 
31 /* Nodes that are unconstrained are assumed to be set to NaN */
32 
33 #define GRD_COMMAND_LEN	320
34 #define GRD_REMARK_LEN	160
35 #define GRD_TITLE_LEN	 80
36 #define GRD_UNIT_LEN	 80
37 
38 struct GRD_HEADER
39 {
40 
41     int nx;			/* Number of columns */
42     int ny;			/* Number of rows */
43     int node_offset;		/* 0 for node grids, 1 for pixel grids */
44 
45     double x_min;		/* Minimum x coordinate */
46     double x_max;		/* Maximum x coordinate */
47     double y_min;		/* Minimum y coordinate */
48     double y_max;		/* Maximum y coordinate */
49     double z_min;		/* Minimum z value */
50     double z_max;		/* Maximum z value */
51     double x_inc;		/* x increment */
52     double y_inc;		/* y increment */
53     double z_scale_factor;	/* grd values must be multiplied by this */
54     double z_add_offset;	/* After scaling, add this */
55 
56     char x_units[GRD_UNIT_LEN];	/* units in x-direction */
57     char y_units[GRD_UNIT_LEN];	/* units in y-direction */
58     char z_units[GRD_UNIT_LEN];	/* grid value units */
59     char title[GRD_TITLE_LEN];	/* name of data set */
60     char command[GRD_COMMAND_LEN];	/* name of generating command */
61     char remark[GRD_REMARK_LEN];	/* comments re this data set */
62 };
63 
64 /*-----------------------------------------------------------------------------------------
65  *	Notes on node_offset:
66 
67 	Assume x_min = y_min = 0 and x_max = y_max = 10 and x_inc = y_inc = 1.
68 	For a normal node grid we have:
69 		(1) nx = (x_max - x_min) / x_inc + 1 = 11
70 		    ny = (y_max - y_min) / y_inc + 1 = 1
71 		(2) node # 0 is at (x,y) = (x_min, y_max) = (0,10) and represents the surface
72 		    value in a box with dimensions (1,1) centered on the node.
73 	For a pixel grid we have:
74 		(1) nx = (x_max - x_min) / x_inc = 10
75 		    ny = (y_max - y_min) / y_inc = 10
76 		(2) node # 0 is at (x,y) = (x_min + 0.5*x_inc, y_max - 0.5*y_inc) = (0.5, 9.5)
77 		    and represents the surface value in a box with dimensions (1,1)
78 		    centered on the node.
79 -------------------------------------------------------------------------------------------*/
80