1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 99.2beta8 (1.46)
original version by: Nikos Drakos, CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>6.16 Gridding of data, continued</TITLE>
<META NAME="description" CONTENT="6.16 Gridding of data, continued">
<META NAME="keywords" CONTENT="GMT_Docs">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="LaTeX2HTML v99.2beta8">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="GMT_Docs.css">
<LINK REL="next" HREF="node90.html">
<LINK REL="previous" HREF="node88.html">
<LINK REL="up" HREF="node73.html">
<LINK REL="next" HREF="node90.html">
</HEAD>
<BODY bgcolor="#ffffff">
<!--Navigation Panel-->
<A NAME="tex2html2276"
HREF="node90.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.gif"></A>
<A NAME="tex2html2270"
HREF="node73.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.gif"></A>
<A NAME="tex2html2264"
HREF="node88.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.gif"></A>
<A NAME="tex2html2272"
HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.gif"></A>
<A NAME="tex2html2274"
HREF="node149.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.gif"></A>
<BR>
<B> Next:</B> <A NAME="tex2html2277"
HREF="node90.html">6.17 Images clipped by</A>
<B> Up:</B> <A NAME="tex2html2271"
HREF="node73.html">6. Cook-book</A>
<B> Previous:</B> <A NAME="tex2html2265"
HREF="node88.html">6.15 Gridding, contouring, and</A>
  <B> <A NAME="tex2html2273"
HREF="node1.html">Contents</A></B>
  <B> <A NAME="tex2html2275"
HREF="node149.html">Index</A></B>
<BR>
<BR>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION0014160000000000000000"></A>
<A NAME="11565"></A>
<BR>
6.16 Gridding of data, continued
</H1>
<P>
<A NAME="tex2html441"
HREF="../pscontour.html"><I><B>pscontour</B></I></A><A NAME="11597"></A> (for contouring) and <A NAME="tex2html442"
HREF="../triangulate.html"><I><B>triangulate</B></I></A><A NAME="11606"></A>
(for gridding) use the simplest method of interpolating
data: a Delaunay triangulation (see Example 12) which
forms <IMG
WIDTH="43" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="img119.gif"
ALT="$z(x, y)$"> as a union of planar triangular facets.
One advantage of this method is that it will not extrapolate
<IMG
WIDTH="43" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="img119.gif"
ALT="$z(x, y)$"> beyond the convex hull of the input (<I>x, y</I>)
data. Another is that it will not estimate a <I>z</I> value
above or below the local bounds on any triangle.
A disadvantage is that the <IMG
WIDTH="43" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="img119.gif"
ALT="$z(x, y)$"> surface is not
differentiable, but has sharp kinks at triangle edges and
thus also along contours. This may not look physically
reasonable, but it can be filtered later (last panel below).
<A NAME="tex2html443"
HREF="../surface.html"><I><B>surface</B></I></A><A NAME="11615"></A> can be used to generate a higher-order
(smooth and differentiable) interpolation of <IMG
WIDTH="43" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="img119.gif"
ALT="$z(x, y)$"> onto
a grid, after which the grid may be illustrated (<A NAME="tex2html444"
HREF="../grdcontour.html"><I><B>grdcontour</B></I></A><A NAME="11624"></A>,
<A NAME="tex2html445"
HREF="../grdimage.html"><I><B>grdimage</B></I></A><A NAME="11633"></A>, <A NAME="tex2html446"
HREF="../grdview.html"><I><B>grdview</B></I></A><A NAME="11642"></A>). <A NAME="tex2html447"
HREF="../surface.html"><I><B>surface</B></I></A><A NAME="11651"></A> will interpolate
to all (<I>x, y</I>) points in a rectangular region, and thus
will extrapolate beyond the convex hull of the data. However,
this can be masked out in various ways (see Example 15).
<P>
A more serious objection is that <A NAME="tex2html448"
HREF="../surface.html"><I><B>surface</B></I></A><A NAME="11660"></A> may estimate
<I>z</I> values outside the local range of the data (note area
near <I>x</I> = 0.8, <I>y</I> = 5.3). This commonly happens when
the default tension value of zero is used to create a ``minimum
curvature'' (most smooth) interpolant. <A NAME="tex2html449"
HREF="../surface.html"><I><B>surface</B></I></A><A NAME="11669"></A> can be
used with non-zero tension to partially overcome this problem.
The limiting value <IMG
WIDTH="78" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img120.gif"
ALT="$tension = 1$"> should approximate the triangulation,
while a value between 0 and 1 may yield a good compromise between
the above two cases. A value of 0.5 is shown here
(Figure <A HREF="node89.html#fig:GMT_example_16">6.16</A>). A side
effect of the tension is that it tends to make the contours turn
near the edges of the domain so that they approach the edge from
a perpendicular direction. A solution is to use <A NAME="tex2html450"
HREF="../surface.html"><I><B>surface</B></I></A><A NAME="11678"></A>
in a larger area and then use <A NAME="tex2html451"
HREF="../grdcut.html"><I><B>grdcut</B></I></A><A NAME="11687"></A> to cut out the desired
smaller area. Another way to achieve a compromise is to
interpolate the data to a grid and then filter the grid using
<A NAME="tex2html452"
HREF="../grdfft.html"><I><B>grdfft</B></I></A><A NAME="11696"></A> or <A NAME="tex2html453"
HREF="../grdfilter.html"><I><B>grdfilter</B></I></A><A NAME="11705"></A>. The latter can handle grids
containing ``NaN'' values and it can do median and mode filters
as well as convolutions. Shown here is <A NAME="tex2html454"
HREF="../triangulate.html"><I><B>triangulate</B></I></A><A NAME="11714"></A> followed
by <A NAME="tex2html455"
HREF="../grdfilter.html"><I><B>grdfilter</B></I></A><A NAME="11723"></A>. Note that the filter has done some
extrapolation beyond the convex hull of the original <I>x, y</I>
values. The ``best'' smooth approximation of <IMG
WIDTH="43" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="img119.gif"
ALT="$z(x, y)$"> depends
on the errors in the data and the physical laws obeyed by <I>z</I>.
<A NAME="tex2html456"
HREF="http://www.soest.hawaii.edu/gmt"><B>GMT</B></A> cannot always do the ``best'' thing but it offers great
flexibility through its combinations of tools. We illustrate all
four solutions using a cpt file that contains color fills,
patterns, and a ``skip slice'' request for <IMG
WIDTH="97" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img121.gif"
ALT="$700 < z < 725$">.
<P>
<P>
<BR>
<P>
<BR CLEAR="ALL">
<HR>
<BR>
<PRE>
gmtset MEASURE_UNIT INCH ANOT_FONT_SIZE 9
pscontour -R0/6.5/-0.2/6.5 -Jx0.45i -P -K -Y5.5i -Ba2f1WSne table_5.11 -Cex16.cpt -I \
>! example_16.ps
echo "3.25 7 18 0 4 CB pscontour (triangulate)" | pstext -R -Jx -O -K -N >> example_16.ps
surface table_5.11 -R -I0.1 -Graws0.grd
grdview raws0.grd -R -Jx -Ba2f1WSne -Cex16.cpt -Qs -O -K -X3.5i >> example_16.ps
echo "3.25 7 18 0 4 CB surface (tension = 0)" | pstext -R -Jx -O -K -N >> example_16.ps
surface table_5.11 -R -I0.1 -Graws5.grd -T0.5
grdview raws5.grd -R -Jx -Ba2f1WSne -Cex16.cpt -Qs -O -K -Y-3.75i -X-3.5i >> example_16.ps
echo "3.25 7 18 0 4 CB surface (tension = 0.5)" | pstext -R -Jx -O -K -N >> example_16.ps
triangulate table_5.11 -Grawt.grd -R -I0.1 > /dev/null
grdfilter rawt.grd -Gfiltered.grd -D0 -Fc1
grdview filtered.grd -R -Jx -Ba2f1WSne -Cex16.cpt -Qs -O -K -X3.5i >> example_16.ps
echo "3.25 7 18 0 4 CB triangulate @~\256@~ grdfilter" | pstext -R -Jx -O -K -N >> example_16.ps
echo "3.2125 7.5 32 0 4 CB Gridding of Data" | pstext -R0/10/0/10 -Jx1i -O -K -N -X-3.5i >> example_16.ps
psscale -D3.21/0.35/5/0.25h -Cex16.cpt -O -U"Example 16 in Cookbook" -Y-0.75i >> example_16.ps
\rm -f *.grd .gmtcommands
</PRE>
<P>
<BR>
<BR>
<P>
<BR CLEAR="ALL">
<HR>
<P></P>
<DIV ALIGN="CENTER"><A NAME="fig:GMT_example_16"></A><A NAME="11811"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 6.16:</STRONG>
More ways to grid data</CAPTION>
<TR><TD><IMG
WIDTH="386" HEIGHT="500" BORDER="0"
SRC="img122.gif"
ALT="\begin{figure}\centering\epsfig{figure=eps/GMT_example_16.eps}\end{figure}"></TD></TR>
</TABLE>
</DIV><P></P>
<P>
<A NAME="11799"></A>
<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html2276"
HREF="node90.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.gif"></A>
<A NAME="tex2html2270"
HREF="node73.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.gif"></A>
<A NAME="tex2html2264"
HREF="node88.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.gif"></A>
<A NAME="tex2html2272"
HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.gif"></A>
<A NAME="tex2html2274"
HREF="node149.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.gif"></A>
<BR>
<B> Next:</B> <A NAME="tex2html2277"
HREF="node90.html">6.17 Images clipped by</A>
<B> Up:</B> <A NAME="tex2html2271"
HREF="node73.html">6. Cook-book</A>
<B> Previous:</B> <A NAME="tex2html2265"
HREF="node88.html">6.15 Gridding, contouring, and</A>
  <B> <A NAME="tex2html2273"
HREF="node1.html">Contents</A></B>
  <B> <A NAME="tex2html2275"
HREF="node149.html">Index</A></B>
<!--End of Navigation Panel-->
<ADDRESS>
Paul Wessel
2001-04-18
</ADDRESS>
</BODY>
</HTML>
|