next up previous contents index
Next: 5. GMT Coordinate Transformations Up: 4. General features Previous: 4.17 Embedded grdfile format   Contents   Index


4.18 The NaN data value

For a variety of data processing and plotting tasks there is a need to acknowledge that a data point is missing or unassigned. In the ``old days'' such information was passed by letting a value like -9999.99 take on the special meaning of ``this is not really a value, it is missing''. The problem with this scheme is that -9999.99 (or any other floating point value) may be a perfectly reasonable data value and in such a scenario would be skipped. The solution adopted in GMT is to use the IEEE concept Not-a-Number (NaN) for this purpose. Mathematically, a NaN is what you get if you do an undefined mathematical operation like $0/0$. This value is stored with a particular bit pattern defined by IEEE so that special action can be taken when it is encountered by programs. In particular, a library function called isnan is used to test if a floating point is a NaN. GMT uses these tests extensively to determine if a value is suitable for plotting or processing (if a NaN is used in a calculation the result would become NaN as well). Data points whose value is NaN are not normally plotted (or plotted with the special NaN color given in .gmtdefaults4). Several tools such as xyz2grd, gmtmath, and grdmath can convert user data to NaN and vice versa, thus facilitating arbitrary masking and clipping of data sets. Note that a few computers do not have native IEEE hardware support. At this point, this applies to some of the Cray super-computers. Users on such machines may have to adopt the old `-9999.99'' scheme to achieve the desired results.


next up previous contents index
Next: 5. GMT Coordinate Transformations Up: 4. General features Previous: 4.17 Embedded grdfile format   Contents   Index
Paul Wessel 2004-10-01