Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > 5764c67416561ab82b35afcf9c650e17 > files > 860

GMT-doc-4.5.2-1.fc13.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>2.1.2 Exercises</TITLE>
<META NAME="description" CONTENT="2.1.2 Exercises">
<META NAME="keywords" CONTENT="GMT_Tutorial">
<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_Tutorial.css">

<LINK REL="next" HREF="node37.html">
<LINK REL="previous" HREF="node35.html">
<LINK REL="up" HREF="node34.html">
<LINK REL="next" HREF="node37.html">
</HEAD>

<BODY  bgcolor="#ffffff">
<!--Navigation Panel-->
<A NAME="tex2html901"
  HREF="node37.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html895"
  HREF="node34.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html889"
  HREF="node35.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html897"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html899"
  HREF="node63.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html902"
  HREF="node37.html">2.1.3 More exercises</A>
<B> Up:</B> <A NAME="tex2html896"
  HREF="node34.html">2.1 General Information</A>
<B> Previous:</B> <A NAME="tex2html890"
  HREF="node35.html">2.1.1 Examples</A>
 &nbsp; <B>  <A NAME="tex2html898"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html900"
  HREF="node63.html">Index</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION00412000000000000000"></A>
<A NAME="894"></A>
<BR>
2.1.2 Exercises
</H2>

<P>

<OL>
<LI>Plot the data as a green-blue polygon instead.

<P>
</LI>
<LI>Try using a predefined pattern.

<P>
</LI>
</OL>
<A NAME="897"></A>

<P>
A common question is : ``How can I plot symbols connected by a line
with psxy?''.  The surprising answer is that we must call <A NAME="tex2html136"
  HREF="../man/psxy.html"><I><B>psxy</B></I></A><A NAME="2174"></A> twice.
While this sounds cumbersome there is a reason for this:  Basically,
polygons need to be kept in memory since they may need to be clipped,
hence computer memory places a limit on how large polygons we may plot.
Symbols, on the other hand, can be plotted one at the time so there
is no limit to how many symbols one may plot.  Therefore, to connect
symbols with a line we must use the overlay approach:
<A NAME="899"></A>

<P>
<PRE> 
psxy data -R -J -B -P -K -Wthinner &gt; plot.ps
psxy data -R -J -O -W -Si0.2i &gt;&gt; plot.ps
</PRE>

<P>
Our final <A NAME="tex2html137"
  HREF="../man/psxy.html"><I><B>psxy</B></I></A><A NAME="2179"></A> example involves a more complicated scenario
in which we want to plot the epicenters of several earthquakes over
the background of a coastline basemap.  We want the symbols to have a
size that reflects the magnitude of the earthquakes, and that their
color should reflect the depth of the hypocenter.  You will find the
two files <U>quakes.ngdc</U> and <U>quakes.cpt</U> in your
directory.  The first few lines in the <U>quakes.ngdc</U> looks
like this:
<P>
<PRE>
Historical Tsunami Earthquakes from the NGDC Database
Year  Mo  Da  Lat+N  Long+E  Dep  Mag
1987  01  04  49.77  149.29  489  4.1
1987  01  09  39.90  141.68  067  6.8
</PRE>

<P>
Thus the file has three header records (including the blank line),
but we are only interested in columns 5, 4, 6, and 7.  In addition to
extract those columns we must also scale the magnitudes into symbols
sizes in inches.  Given their range it looks like multiplying the
magnitude by 0.02 will work well.  Reformatting this file to comply
with the <A NAME="tex2html138"
  HREF="../man/psxy.html"><I><B>psxy</B></I></A><A NAME="2187"></A> input format can be done in a number of ways,
including manual editing, using MATLAB, a spreadsheet program, or <I>UNIX</I> tools.  Here, without further elaboration, we simply use the <I>UNIX</I> tool
<I>awk</I><A NAME="2193"></A> to do the job ($5 refers to the 5'th column etc., and NR
is the current record number):

<P>
<PRE>
awk '{if (NR &gt; 3) print $5, $4, $6, 0.02*$7}' quakes.ngdc &gt; quakes.d
</PRE>

<P>
The <I>awk</I><A NAME="2196"></A> statement is automatically applied to each record,
hence the output file <U>quakes.d</U> should now look like this (try it!):

<P>
<PRE>
149.29  49.77  489  0.082
141.68  39.90  067  0.136
...etc etc
</PRE>

<P>
We will follow conventional color schemes for seismicity and assign red
to shallow quakes (depth 0-100 km), green to intermediate quakes
(100-300 km), and blue to deep earthquakes (depth <IMG
 WIDTH="16" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img25.png"
 ALT="$&gt;$"> 300 km).  The
<U>quakes.cpt</U> file establishes the relationship between depth
and color:

<P>
<PRE>
# color palette for seismicity
#z0  color   z1 color
0    red    100 red
100  green  300 green
300  blue  1000 blue
</PRE>

<P>
Apart from comment lines (starting with #), each record in the cpt file
governs the color of a symbol whose <I>z</I> value falls in the range between
<IMG
 WIDTH="17" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img26.png"
 ALT="$z_0$"> and <IMG
 WIDTH="17" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img27.png"
 ALT="$z_1$">.  If the colors for the lower and upper levels differ
then an intermediate color will be linearly interpolated given the <IMG
 WIDTH="10" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img17.png"
 ALT="$z$">
value.  Here, we have chosen constant color intervals.

<P>
We may now complete our example using the Mercator projection; we throw in a
map scale out of pure generosity:

<P>
<PRE> 
pscoast -R130/150/35/50 -JM6i -B5 -P -Ggray -Lf134/49/42.5/500 -K &gt; map.ps
psxy -R -J -O -Cquakes.cpt quakes.d -Sci -Wthinnest &gt;&gt; map.ps
</PRE>

<P>
where the <B>i</B> appended to the <B>-Sc</B> option ensures that symbols
sizes are interpreted to be in inches.
<HR>
<!--Navigation Panel-->
<A NAME="tex2html901"
  HREF="node37.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html895"
  HREF="node34.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html889"
  HREF="node35.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html897"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html899"
  HREF="node63.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html902"
  HREF="node37.html">2.1.3 More exercises</A>
<B> Up:</B> <A NAME="tex2html896"
  HREF="node34.html">2.1 General Information</A>
<B> Previous:</B> <A NAME="tex2html890"
  HREF="node35.html">2.1.1 Examples</A>
 &nbsp; <B>  <A NAME="tex2html898"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html900"
  HREF="node63.html">Index</A></B> 
<!--End of Navigation Panel-->
<ADDRESS>
Paul Wessel
2010-01-14
</ADDRESS>
</BODY>
</HTML>