Data Analysis in Geophysics with Dr. Robert Smalley
Dr. Robert Smalley leads a course on data analysis in geophysics at C.E.R.I. The content covers various aspects of geophysics analysis and mapping techniques using GMT programs. Learn how to create maps with seismic data, plot plate boundaries, faults, and focal mechanisms. The provided commands and details guide you through setting up maps and incorporating different map features effectively.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
C E R I- -8 1 04 D ata A nalysis in G eophysics D r. R obert (B ob) S malley 3 8 9 2 C entral A ve, R oom 1 03 rsmalley@ memphis.edu F all 2 02 3 T u & T h 1 1 :2 0 am 8 1 04 D ata A nalysis in G eophysics D r. R obert (B ob) S malley 3 8 9 2 C entral A ve, R oom 1 03 rsmalley@ memphis.edu F all 2 02 3 T u & T h 1 1 :2 0 am - -1 2 :45 pm C E R I 6 7 8 6 7 8 - -49 2 9 49 2 9 1 2 :45 pm M eeting 1 6 M eeting 1 6 T ue. T ue. O ct 2 4, 2 02 3 O ct 2 4, 2 02 3 C E R I N ew/ L ong B uilding: S tudent C omputer L ab C lass webpage to be announced. M y homepage (has older versions of the course) http:/ / www.ceri.memphis.edu/ people/ smalley/ C E R I N ew/ L ong B uilding: S tudent C omputer L ab C lass webpage to be announced. M y homepage (has older versions of the course) http:/ / www.ceri.memphis.edu/ people/ smalley/
L ast time we made this map with this gmt psxy -R-35/-21/-62/-54.5 -JM15c -BWSen -Baf ssand_eqs.dat -Sc0.25c -W1,black -Gred -P > $0.p command L ast time we made this map with this command
W e made the map with 1 line, albiet W hat if we wanted to plot other things plate boundaries, faults, focal mechanisms, etc. H ow do we do that? L ets set it up so we make a S o now we'll have to make 2 calls, the first for the second to plot the earthquakes. albiet a pretty complicated one. plate boundaries, faults, focal mechanisms, etc. H ow do we do that? basemap and then add the map features. S o now we'll have to make 2 calls, the first for the basemap second to plot the earthquakes. W e made the map with 1 line, W hat if we wanted to plot other things a pretty complicated one. L ets set it up so we make a basemap and then add the map features. basemap and the and the
W e made the map with 1 line, albeit a pretty complicated one. W e made the map with 1 line, albeit a pretty complicated one. N ow we want to make a map that is not a one liner. H eader initialize P lot stuff first part F ollowed by plotting commands F ollowed by a closing section and we now have the pleasure of controlling the initiallization N ow we want to make a map that is not a one liner. H eader - - initialize P lot stuff first part F ollowed by plotting commands F ollowed by a closing section and we now have the pleasure of controlling the initiallization and closing. T he figure shows the postscript file structure. It has an initialization section T he figure shows the postscript file structure. It has an initialization section P lot stuff second part F ooter finish P lot stuff second part F ooter - - finish and closing.
A s our first multiline G M T program let's make a then plot the earthquakes. #!/bin/bash rm $0.ps gmt psbasemap -R-35/-21/-62/-54.5 -JM15c -BWSen -Baf -P -Y5c -X1.5i -K > $0.ps gmt psxy -R -J ssand_eqs.dat -Sc0.25c -W1,black -Gred -O >> $0.ps A s our first multiline G M T program let's make a basemap then plot the earthquakes. basemap first and first and T he stuff in red is new and required. T he K tells G M T to not do the finalization as more stuff follows. T he T he T he stuff in orange is new and just moves the position of the map up 5 cm and to the right 1 .5 inches. T he stuff in red is new and required. tells G M T to not do the finalization as more stuff follows. T he O tells G M T to not do the initialization as I'm adding stuff. T he >> is standard U N IX to add the output to the file named. T he stuff in orange is new and just moves the position of the map up 5 cm and to the right 1 .5 inches. T he tells G M T to not do the initialization as I'm adding stuff. is standard U N IX to add the output to the file named.
S ome more U N IX stuff S ome more U N IX stuff It is a pain to have to keep typing in the command as we modify our shell script, so U N IX offers a number of ways to help T o rerun the last command T o rerun the last command that starts with a " If you have used more than one command that starts with a g then enter " It is a pain to have to keep typing in the command as we modify our shell script, so U N IX offers a number of ways to help T o rerun the last command type " T o rerun the last command that starts with a "g" type " If you have used more than one command that starts with a g then enter "!gm type "!!" " " type "!g<CR> " " gm<CR> " or " " or "!gmt gmt<CR> ", etc. till it is unique. ", etc. till it is unique. T his has worked since the birth of U N IX . T his has worked since the birth of U N IX . W e can now also rerun commands using the arrow keys to move through the history of commands to find the one we want and then W e can now also rerun commands using the arrow keys to move through the history of commands to find the one we want and then
S ome more U N IX stuff S ome more U N IX stuff Y ou can also reference the command history numerically Y ou can also reference the command history numerically !-3<CR> E xecutes the third command back in the history. W e can now also rerun commands using the arrow keys to move through the history of commands to find the one we want and then enter , or E xecutes the third command back in the history. W e can now also rerun commands using the arrow keys to move through the history of commands to find the one we want and then , or <CR>
S ome more U N IX stuff S ome more U N IX stuff W e have already introduced shell scripts W e have already introduced shell scripts files with a program , as opposed to data, in them files with a program , as opposed to data, in them S implest version of a shell script would be a file with just one line S implest version of a shell script would be a file with just one line B ut they usually have more. B ut they usually have more.
gmt6 psxy -R-35/-21/-62/-54.5 -JM15c -BWSen -Baf ssand_ eqs.dat -Sc0.25c -W1,black -Gred > ex1.sh.ps T o make this into a shell script put the line above as the only line in the shell script file. Y ou will then have to make the file change mode E nter T hen execute/ run it. Is most likely not in your P A T H , and you need to precede it with E nter put the line above as the only line in the shell script file. executable, which is done with the change mode command E nter chmod +x ex1.sh<CR> > T hen execute/ run it. Is most likely not in your P A T H , and you need to precede it with ./ E nter ./ex1.sh to run it, and it will make a map. T o make this into a shell script Y ou will then have to make the file executable , which is done with the command to run it, and it will make a map.
A bit more about standard U N IX "features" W hen you run a program in U N IX , the "shell" passes the command line to the program. T he shell language ( provides a way to parse the command line. In this way, the program's behavior can be controlled or modified by the "switches" Inside the shell script $0 is the whole command line ( $1 is the first field, white space defines the breaks $2 is the second field. E tc. A bit more about standard U N IX "features" W hen you run a program in U N IX , the "shell" passes the command line to the program. T he shell language (zsh provides a way to parse the command line. In this way, the program's behavior can be controlled or modified by the "switches" Inside the shell script is the whole command line (0 is the name, is the first field, white space defines the breaks is the second field. E tc. zsh, , sh sh, bash, , bash, csh csh, , tcsh tcsh, , etc etc) ) is the name, $0 returns the value) returns the value)
So in my script, ex1.sh gets substituted for $0 and gmt6 psxy -R-35/-21/-62/-54.5 -JM15c -BWSen -Baf ssand_eqs.dat -Sc0.25c -W1,black -Gred > $0.ps becomes gmt6 psxy -R-35/-21/-62/-54.5 -JM15c -BWSen -Baf ssand_eqs.dat -Sc0.25c -W1,black -Gred > ex1.sh.ps (same as the initial example) and the output file is named ex1.sh.ps. The output file name you give it is arbitrary. I usually use the shell script name as the root of the file name, so I know what shell script made the file.
S o, ex1a.sh gets substituted into the script for #!/bin/bash rm $0.ps gmt psbasemap -R-35/-21/-62/-54.5 -JM15c -BWSen - Baf -P -Y5c -X1.5i -K > $0.ps gmt psxy -R -J ssand_eqs.dat -Sc0.25c -W1,black -Gred -O >> ${0}.ps S o, gets substituted into the script for $0and and the output file is named T he output file name you give it is arbitrary. I usually use the shell script name as the root of the file name, so I know what shell script made the file. T he the output file is named ex1.sh.ps.. T he output file name you give it is arbitrary. I usually use the shell script name as the root of the file name, so I know what shell script made the file. T he pstells me, but more importantly U N IX , it s a postscript file. tells me, but more importantly U N IX , it s a postscript file.
P lotting just circles is great but P lotting just circles is great but not useful enough. not useful enough. S ay we want to plot S ay we want to plot the symbols such that they show the magnitude of the earthquake. the symbols such that they show the magnitude of the earthquake. W hen getting earthquake data, a pretty common format is depth, and magnitude (although our example input sets so far have geen W hen getting earthquake data, a pretty common format is lat depth, and magnitude (although our example input sets so far have geen in in lon, , lat for lat, long, , long, for gmt gmt). ). N ow we need to look at the G M T documentation. N ow we need to look at the G M T documentation.
psxy Plot lines, polygons, and symbols in 2-D Description Reads (x,y) pairs from files [or standard input] and will plot lines, polygons, or symbols at those locations on a map. If a symbol is selected and no symbol size given, then it will interpret the third column of the input data as symbol size. Symbols whose size is <= 0 are skipped. If no symbols are specified then the symbol code (see -S below) must be present as last column in the input. If -S is not used, a line connecting the data points will be drawn instead. To explicitly close polygons, use -L. Select a fill with -G. If -G is set, -W will control whether the polygon outline is drawn or not. If a symbol is selected, -G and -W determines the fill and outline/no outline, respectively.
F irst thing to notice is that the symbol size is to be specified in column 3 and we want to set the size by the magnitude, which is in column 4 (column 3 has the depth). F irst thing to notice is that the symbol size is to be specified in column 3 and we want to set the size by the magnitude, which is in column 4 (column 3 has the depth). -24.7934 -58.8957 21.73 4.8 -26.5665 -59.7692 80.92 5.2 T he non T he non- -U N IX solution is to make a new input file that has the data in the correct input format. U N IX solution is to make a new input file that has the data in the correct input format. -24.7934 -58.8957 4.8 -26.5665 -59.7692 5.2
D oing that, and modifying the D oing that, and modifying the S switch to switch to Sc gmt psxy -R-35/-21/-62/-54.5 -JM15c -BWSen -Baf ssand_4mag.dat -Sc -W1,black -Gred -P -Y5c -X1.5i > $0.ps W W e get this e get this W hich is a good start, but needs some tweaking. W hich is a good start, but needs some tweaking.
S o it looks like we hav S o it looks like we have to do something about the symbol sizes. e to do something about the symbol sizes. I could add fixing the symbol sizes to the program that remade the file to put the magnitude in column 3 I could add fixing the symbol sizes to the program that remade the file to put the magnitude in column 3 or or W e now introduce a new tool W e now introduce a new tool awk and use a pipe to input the data into G M T . In its simplest use, same thing to each line. and use a pipe to input the data into G M T . reads an input file line by line and does the same thing to each line. In its simplest use, awk reads an input file line by line and does the
S o, our one S o, our one- -liner becomes liner becomes awk '{print $1, $2, $4}' ssand_eqs.dat | gmt psxy -R-35/-21/- 62/-54.5 -JM15c -BWSen -Baf -Sc -W1,black -Gred -P -Y5c -X1.5i > $0.ps W hat W hat does awk do? does awk do? It reads each line and prints out the 1st st, 2 , 2nd columns separated by spaces). A lso, and very important, we don't have to make a new file to send to gmt input comes from another program. S o far we get the same output. It reads each line and prints out the 1 nd and 4 and 4th th columns (with the columns (with the columns separated by spaces). A lso, and very important, we don't have to make a new file to send to gmt, we can pipe it in using the U N IX pipe tool " input comes from another program. S o far we get the same output. , we can pipe it in using the U N IX pipe tool "|" where standard " where standard
A W K , however, is a general purpose text processor and we can use it to also fix the symbol size problem. A W K , however, is a general purpose text processor and we can use it to also fix the symbol size problem. A W K can do simple math, with trig, long, etc. functions. A W K can do simple math, with trig, long, etc. functions. C hanging just the awk call we get C hanging just the awk call we get awk '{print $1, $2, $4/10}' ssand_eqs.dat | gmt psxy -R-35/-21/-62/-54.5 -JM15c -BWSen -Baf -Sc - W1,black -Gred -P -Y5c -X1.5i > $0.ps W hich is a lot better W hich is a lot better
O ne common source of seismic data is the U S G S N E IC web page (this is another goal of this course, how/ where to find data) S earch for "neic pde" will bring you to https://earthquake.usgs.gov/earthquakes/search/ and it can return data in a number of formats, the most useful now being csv and kml/z.
T he csv file that it returns looks like this! T he csv file that it returns looks like this! time,latitude,longitude,depth,mag,magT ype,nst,gap,dmin,rms,net,id,updated,place,type,horizontalE rror,depthE rror,magE rror,magN time,latitude,longitude,depth,mag,magT ype,nst,gap,dmin,rms,net,id,updated,place,type,horizontalE rror,depthE rror,magE rror,magN st, st,status,locationS ource,magS ource status,locationS ource,magS ource 2 02 3 2 02 3 - -1 0 1 2 . 3 4 5 1 0- -2 4T 1 0:1 0:07 .6 47 Z , 1 2 . 3 4 5 2 4T 1 0:1 0:07 .6 47 Z ,5 .7 9 8 , 5 .7 9 8 ,- -8 2 .406 6 , 8 2 .406 6 ,1 0 1 0,5 ,5 ,mww,9 2 ,1 46 ,2 .9 9 ,0.6 9 ,us,us7 000l5 yb,2 02 3 ,mww,9 2 ,1 46 ,2 .9 9 ,0.6 9 ,us,us7 000l5 yb,2 02 3 - -1 0 1 0- -2 4T 1 0:2 9 :5 4.040Z ,"2 43 km S S W of R o G rande, P anama",earthquake,9 .42 ,1 .9 3 ,0.09 8 ,1 0,re 2 4T 1 0:2 9 :5 4.040Z ,"2 43 km S S W of R o G rande, P anama",earthquake,9 .42 ,1 .9 3 ,0.09 8 ,1 0,re viewed,us,us viewed,us,us and we can use A W K to fix it and we can use A W K to fix it awk 'BEGIN {FS=","} {print $3, $2, $5/10}' neic_pde_ex.csv which produces the following output which produces the following output longitude latitude mag -82.4066 5.798 0.5 T he T he BEGIN tells tells awk to use the comma (instead of the space) as the field separator and the rest is the same. to use the comma (instead of the space) as the field separator and the rest is the same.
G M T also handles color, so let's color the events by their depth and size them by magnitude. S pecifing G M T also handles color, so let's color the events by their depth and size them by magnitude. S pecifing color modifies the input file color modifies the input file strucutre strucutre (bad program design). (bad program design). If -S is set, symbol fill color will be determined by the z-value in the third column. Additional fields are shifted over by one column (optional size would be 4th rather than 3rd field, etc.). T hese kinds of inconveniences can be easily handled using T hese kinds of inconveniences can be easily handled using AWK..
T o add color, we have to give GMT a color map/ table, which is done with the makecpt data (-T sets this up going through the color table in to I'm also selecting the "jet" color table (G M T has "great" documentation on the commands, but is oftentimes weaker on the meta and non command F or the moment I'm selecting these values. W ith a bit more programming the limits can be made automatically. T o add color, we have to give with the data ( a color map/ table, which is done in which we scale color table to the makecpt module of sets this up going through the color table in 10 steps from to 80 (km) in depth. I'm also selecting the "jet" color table (G M T has "great" documentation on the commands, but is oftentimes weaker on the meta and non command docummentation F or the moment I'm selecting these values. W ith a bit more programming the limits can be made automatically. module of GMT, in which we scale color table to the steps from 0 (km) in depth. docummentation) ) #!/usr/bin/env bash rm $0.ps gmt makecpt -Cjet -Ic -T0/80/10 > my.cpt
N ow to make the map I have to tell table to use, both done with the W e're also introducing a new way to provide input use " you are entering data from the terminal). T he character string " N ote the string to end the input can be anything you want, except something in the input. N ow to make the map I have to tell GMT to color the data and the color table to use, both done with the C flag/ option. W e're also introducing a new way to provide input - - showing how to use "standard-input" from you are entering data from the terminal). T he << END says that everything following this line, until it sees the character string "END" is going to standard N ote the string to end the input can be anything you want, except something in the input. to color the data and the color flag/ option. showing how to inside a shell script " from inside a shell script (this simulates that (this simulates that says that everything following this line, until it sees the " is going to standard- -input. input. gmt psxy -R-35/-21/-62/-54.5 -JM15c -BWSen -Baf -Sc -W1,black -Cmy.cpt -P -Y5c -X1.5i << END> $0.ps `awk '{print $1, $2, $3, $4/10}' ssand_eqs.dat` END
A nd to generate the input we are using the U N IX feature of command substitution T his replaces the output of the command as if it were text in the file. A nd to generate the input we are using the U N IX feature of command substitution.. T his replaces the output of the command as if it were text in the file. gmt psxy -R-35/-21/-62/-54.5 -JM15c -BWSen -Baf -Sc -W1,black -Cmy.cpt -P -Y5c -X1.5i << END> $0.ps `awk '{print $1, $2, $3, $4/10}' ssand_eqs.dat` END It is as if I entered the output of the awk command It is as if I entered the output of the awk command $ awk '{print $1, $2, $3, $4/10}' ssand_eqs.dat -24.7934 -58.8957 21.73 0.48 -26.5665 -59.7692 80.92 0.52
T his is useful if I have multiple datasets from different sources in different formats as you can repeat it. T his is useful if I have multiple datasets from different sources in different formats as you can repeat it. gmt psxy -R-35/-21/-62/-54.5 -JM15c -BWSen -Baf -Sc -W1,black -Cmy.cpt -P -Y5c -X1.5i << END> $0.ps `awk '{print $1, $2, $3, $4/10}' ssand_eqs.dat` `process another data set and feed it to gmt` END
G M T can make very pretty, complex maps. G M T can make very pretty, complex maps. T his shows the A ugust, 2 02 1 , S outh S andwich trench earthquake sequence colored by depth, showing focal mechanisms for events large enough fo automatic determination of the moment tensor, the W adati B enioff zone depth contours, and the local plate boundaries. T his shows the A ugust, 2 02 1 , S outh S andwich trench earthquake sequence colored by depth, showing focal mechanisms for events large enough for r automatic determination of the moment tensor, the W adati- - B enioff zone depth contours, and the local plate boundaries.
W e have been working in mid 1 9 8 0's, it came out while I was a grad student). T here is a new version, known as support for data sets, H ere's a basic map in the new interface (it is still command line and shell scripts). W e have been working in GMT "classic" (it has been around sinc mid 1 9 8 0's, it came out while I was a grad student). T here is a new version, known as GMT "modern" that has much more support for data sets, etc. that came out in the last 5 years. H ere's a basic map in the new interface (it is still command line and shell scripts). "classic" (it has been around since the e the "modern" that has much more etc. that came out in the last 5 years.