Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > os > by-pkgid > 4b194777eaf705e440bb2ce282d32772 > files > 563

GMT-doc-4.5.3-3.fc14.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 2002-2-1 (1.71)
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>7.18 Volumes and Spatial Selections</TITLE>
<META NAME="description" CONTENT="7.18 Volumes and Spatial Selections">
<META NAME="keywords" CONTENT="GMT_Docs">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="GMT_Docs.css">

<LINK REL="next" HREF="node140.html">
<LINK REL="previous" HREF="node138.html">
<LINK REL="up" HREF="node121.html">
<LINK REL="next" HREF="node140.html">
</HEAD>

<BODY  bgcolor="#ffffff">
<!--Navigation Panel-->
<A NAME="tex2html4602"
  HREF="node140.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html4596"
  HREF="node121.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html4590"
  HREF="node138.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html4598"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html4600"
  HREF="node256.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html4603"
  HREF="node140.html">7.19 Color patterns on</A>
<B> Up:</B> <A NAME="tex2html4597"
  HREF="node121.html">7. Creating GMT Graphics</A>
<B> Previous:</B> <A NAME="tex2html4591"
  HREF="node138.html">7.17 Images clipped by</A>
 &nbsp; <B>  <A NAME="tex2html4599"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html4601"
  HREF="node256.html">Index</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0015180000000000000000"></A>
<A NAME="24551"></A>
<BR>
7.18 Volumes and Spatial Selections
</H1>

<P>
To demonstrate potential usage of the new programs
<A NAME="tex2html1441"
  HREF="../man/grdvolume.html"><I><B>grdvolume</B></I></A><A NAME="25396"></A> and <A NAME="tex2html1442"
  HREF="../man/gmtselect.html"><I><B>gmtselect</B></I></A><A NAME="25401"></A> we extract a subset
of the Sandwell &amp; Smith altimetric gravity field<A NAME="tex2html1439"
  HREF="footnode.html#foot24554"><SUP>7.3</SUP></A>for the northern Pacific and decide to isolate all seamounts that
(1) exceed 50 mGal in amplitude and (2) are within 200 km
of the Pratt seamount.  We do this by dumping the 50 mGal
contours to disk, then making a simple <I>$AWK</I><A NAME="25405"></A> script
<U>center.awk</U> that returns the mean location of the points
making up each closed polygon, and then pass these locations
to <A NAME="tex2html1443"
  HREF="../man/gmtselect.html"><I><B>gmtselect</B></I></A><A NAME="25410"></A> which retains only the points within 200
km of Pratt.  We then mask out all the data outside this
radius and use <A NAME="tex2html1444"
  HREF="../man/grdvolume.html"><I><B>grdvolume</B></I></A><A NAME="25415"></A> to determine the combined
area and volumes of the chosen seamounts.
Our illustration is presented in Figure&nbsp;<A HREF="#fig:GMT_example_18">7.18</A>.

<P>
<BR CLEAR="ALL">
<HR>
<BR>
<PRE>#!/bin/sh
#               GMT EXAMPLE 18
#
# Purpose:      Illustrates volumes of grids inside contours and spatial
#               selection of data
# GMT progs:    gmtset, gmtselect, grdclip, grdcontour, grdgradient, grdimage
# GMT progs:    grdmath, grdvolume, makecpt, pscoast, psscale, pstext, psxy
# Unix progs:   $AWK, cat, rm
#
ps=example_18.ps

# Use spherical projection since SS data define on sphere
gmtset ELLIPSOID Sphere D_FORMAT %lg

# Define location of Pratt seamount
echo "-142.65 56.25" &gt; pratt.d

# First generate gravity image w/ shading, label Pratt, and draw a circle
# of radius = 200 km centered on Pratt.

makecpt -Crainbow -T-60/60/10 -Z &gt; grav.cpt
grdgradient AK_gulf_grav.nc -Nt1 -A45 -GAK_gulf_grav_i.nc
grdimage AK_gulf_grav.nc -IAK_gulf_grav_i.nc -JM5.5i -Cgrav.cpt -B2f1 -P -K -X1.5i -Y5.85i &gt; $ps
pscoast -RAK_gulf_grav.nc -J -O -K -Di -Ggray -Wthinnest &gt;&gt; $ps
psscale -D2.75i/-0.4i/4i/0.15ih -Cgrav.cpt -B20f10/:mGal: -O -K &gt;&gt; $ps
$AWK '{print $1, $2, 12, 0, 1, "LB", "Pratt"}' pratt.d | pstext -R -J -O -K -D0.1i/0.1i &gt;&gt; $ps
$AWK '{print $1, $2, 0, 400, 400}' pratt.d | psxy -R -J -O -K -SE -Wthinnest &gt;&gt; $ps

# Then draw 10 mGal contours and overlay 50 mGal contour in green

grdcontour AK_gulf_grav.nc -J -C20 -B2f1WSEn -O -K -Y-4.85i \
        -U/-1.25i/-0.75i/"Example 18 in Cookbook" &gt;&gt; $ps
grdcontour AK_gulf_grav.nc -J -C10 -L49/51 -O -K -Dsm -Wcthin,green &gt;&gt; $ps
pscoast -R -J -O -K -Di -Ggray -Wthinnest &gt;&gt; $ps
$AWK '{print $1, $2, 0, 400, 400}' pratt.d | psxy -R -J -O -K -SE -Wthinnest &gt;&gt; $ps
\rm -f sm_*[0-9].xyz    # Only consider closed contours

# Now determine centers of each enclosed seamount &gt; 50 mGal but only plot
# the ones within 200 km of Pratt seamount.

# First determine mean location of each closed contour and
# add it to the file centers.d

\rm -f centers.d
for file in sm_*.xyz; do
        $AWK 'BEGIN{x=0;y=0;n=0};{x+=$1;y+=$2;n++};END{print x/n,y/n}' $file &gt;&gt; centers.d
done

# Only plot the ones within 200 km

gmtselect -C200/pratt.d centers.d -fg | psxy -R -J -O -K -SC0.04i -Gred -Wthinnest &gt;&gt; $ps
psxy -R -J -O -K -ST0.1i -Gyellow -Wthinnest pratt.d &gt;&gt; $ps

# Then report the volume and area of these seamounts only
# by masking out data outside the 200 km-radius circle
# and then evaluate area/volume for the 50 mGal contour

grdmath -R `cat pratt.d` GDIST = mask.nc
grdclip mask.nc -Sa200/NaN -Sb200/1 -Gmask.nc
grdmath AK_gulf_grav.nc mask.nc MUL = tmp.nc
area=`grdvolume tmp.nc -C50 -Sk | cut -f2`
volume=`grdvolume tmp.nc -C50 -Sk | cut -f3`

psxy -R -J -A -O -K -L -Wthin -Gwhite &gt;&gt; $ps &lt;&lt; END
-148.5  52.75
-140.5  52.75
-140.5  53.75
-148.5  53.75
END
pstext -R -J -O &gt;&gt; $ps &lt;&lt; END
-148 53.08 14 0 1 LM Areas: $area km@+2@+
-148 53.42 14 0 1 LM Volumes: $volume mGal\264km@+2@+
END

# Clean up

rm -f grav.cpt sm_*.xyz *_i.nc tmp.nc mask.nc pratt.d center* .gmt*
</PRE>
<BR CLEAR="ALL">
<HR>
<DIV ALIGN="CENTER"><A NAME="fig:GMT_example_18"></A><A NAME="25421"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 7.18:</STRONG>
Volumes and geo-spatial selections.</CAPTION>
<TR><TD>
<DIV ALIGN="CENTER"><IMG
 WIDTH="365" HEIGHT="532" ALIGN="BOTTOM" BORDER="0"
 SRC="img179.png"
 ALT="\includegraphics[scale=0.5]{scripts/example_18}"></DIV></TD></TR>
</TABLE>
</DIV>

<P>
<A NAME="24563"></A>

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html4602"
  HREF="node140.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html4596"
  HREF="node121.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html4590"
  HREF="node138.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html4598"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html4600"
  HREF="node256.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html4603"
  HREF="node140.html">7.19 Color patterns on</A>
<B> Up:</B> <A NAME="tex2html4597"
  HREF="node121.html">7. Creating GMT Graphics</A>
<B> Previous:</B> <A NAME="tex2html4591"
  HREF="node138.html">7.17 Images clipped by</A>
 &nbsp; <B>  <A NAME="tex2html4599"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html4601"
  HREF="node256.html">Index</A></B> 
<!--End of Navigation Panel-->
<ADDRESS>
Paul Wessel
2010-07-14
</ADDRESS>
</BODY>
</HTML>