Slideshow associated with the lab

advertisement
Intro to shells and GMT
Rob Porritt
UC Berkeley PhD candidate
[email protected]
Objective
 Be comfortable working on a linux/unix terminal
 Craft some simple shell scripts
 Identify various plotting packages when you see the
results
 Create high quality figures for your impending
AGU/SSA poster/presentation
Working on a terminal
History of shells
 1977 by Stephen Bourne (nerdy uncle of Jason
Bourne) at AT&T Bell Labs – the bourne shell (/bin/sh)
 1978 team at Berkeley – the C-shell (/bin/csh)
 Bourne shell updated to the bourne again shell
(/bin/bash)
 C-shell updated to the TCSH shell (/bin/tcsh)
 Many more, but these are the most common
Using shells
 Anytime you use a terminal your are explicitly using a
shell
Scripts
 But you can also put a bunch of commands into a script
to run repeatedly!
Making a script
 First line:
#!/bin/tcsh
Tells the default shell to use the interpreter located at
/bin/tcsh
 Write a series of commands and #defines comments
 chmod +x filename
 ./filename
Useful commands
 ssh – login to a remote computer (for windows
computers google “Putty ssh”)
 set – make a variable which can be returned with $var
 foreach (tcsh)
 for var in a b c d…; do …; …; done (bash)
 screen – run a process not connected to a terminal (ctrl
+ a + d to detach. screen –r to reattach)
How do you like to plot?
 Excel
 ArcGIS
 Google
 Matlab
 But to make a professional
looking chart, GMT is a tool
we use all the time
Same data, multiple plot
packages
GMT
 Paint by numbers
 Start with example scripts and edit for new purposes
 Rest of the time we’ll spend making a script to make a
map of our broadband stations
 You can use this script for future plots – just copy,
paste, edit
 You can work independently using the worksheet
Tips
 Plan ahead
 I like to sketch the plots either in the plot script (ascii
artwork) or on paper.
 Look back
 Use old scripts as examples to go forward.
 The script for this exercise is available.
 http://seismo.berkeley.edu/~rob/plot_socorro/
 Get used to the syntax via command line
 Single line plots are good ways to learn.
General GMT syntax
 gmtcommand (data_file or standard in) –A –B > file.ps
 Example:
 psbasemap –R0/1/0/1 –JX8.5i/11i –Ba1f1/a1f1NSEW –P
> new.ps
This will create a new file (new.ps) with post script text to
plot a blank map over the Region from 0-1 in the x and 01 in the y with an X-Y projection over 8.5inches in x and
11 inches in y in Portrait mode.
The previous slide’s basemap
A second gmt example
 psxy dat.xy –R0/10/0/10 –JX5i/5i –P > new.ps
 Example contents of file dat.xy
0
1
2
3
4
5
6
7
8
9
10
2
2
1
0
5
3
4
9
8
4
6
GMT
 Remember, GMT is a computer program. It will do
exactly what you tell it, nothing more, nothing less
 The squiggly line to the right
is the previous slide’s
command. I gave no
boundary information, no
color information, just random
x-y points.
Where did the data come
from?
 http://edcnts12.cr.usgs.gov/ned
 30 meter DEM for the United States
 I got it from my advisor’s map database. Your host or
grad students may have something similar. Save time
and ask around
 Also check out opentopography.org
Basemap
Topography
With Shading
With contours
Text and points
With scale bar
Location Map
Final map product
Determination
Download