New Mexico Tech
Earth and Environmental Science

ERTH 455 / GEOP 555 - Geodetic Methods

Lab 1: Setup, Shell, Plotting

"I like my crust deformed."
UNAVCO bumper sticker

Introduction

This lab is mainly about getting you set up for the rest of the semester. I'll get you somewhat familiarized with the shell environment, but encourage you to explore on your own - this will only help you in your (grad) student careers.

Exercise -1: Change Operating System

Restart your lab computer into Debian (Windows: shut down, restart).

Exercise 0: Password exchange

You will be working on a machine that is called redoubt.ees.nmt.edu. It sits in my office and has all the software required for this class installed and running. I created logins for you. These should be tested now:

Note that you don't have to be in an ITC lab to log into this machine. If you feel so inclined, you can log into this machine from your own laptop at home (unless it's down for some reason, then you should send me an email and let me know about it).

Note also, that this system is currently backup up daily, but I recommend saving scripts etc, you're working on to a different machine (Dropbox should work, Google Drive should work, scp to your local machine is a good idea)

Exercise I: Setting up your environment

The first thing you'll do is copy a some default settings into your home directory:

The first line copies a file with a bunch of settings into your home directory (~ or /home/USERNAME, note that the command cd without any parameters always gets you back $HOME). The file .tcshrc is basically a SHELL script that is executed on each login to set your environment. The second line sources that file, i.e. it's being executed. A lot of environment variables are being set and programs are now in your PATH and hence directly accessible to you form the command line.

You should now be able to execute redoubt:~> gd2p.pl . That's a command line front-end we'll use for GPS processing later. Copy the LAST 2 lines of the output into your lab report file In addition, try executing insarApp.py --help and copy the FIRST 2 lines of output into your lab report file.

Note that you can add things to your copy of .tcshrc: This may take a little while, but opens .tcshrc in a text editor (gedit). If you are experienced with other editors such as vi, emacs feel free to use these. I won't have time to explain how they work to you, though. The & sends the editor process in the background and you still can use your terminal.

Now add this line setenv GEOP555 /data/GEOP555 to the file. This creates a new environment variable GEOP555 and sets its value to the directory /data/GEOP555. Save the file, go to the command line and activate the changes through: Now you should be able to use the variable to get to this directory: Once you're there: and copy the output into the lab report. After that: This will create a directory that is named after your user name (stored in the variable $USER, don't forget the '$'). Copy the output of the ls command into the report file. This new directory will be your working directory for this class. In ~/.tcshrc change this line setenv GEOP555 /data/GEOP555 to setenv GEOP555 /data/GEOP555/$USER so you will be able to cd directly into this directory via: I'll verify this, because I'll be using $GEOP555 a lot in future labs.

Exercise 2: Some more SHELL exercises.

Type these commands and follow the output on the screen. I want you to get to know this world a bit better:

A useful thing to know is that with the up and down arrows you can browse through the history of your commands. Quite handy if you just typed a very long command and you want to do something quite similar again (Well, it that case it might be time for some shell scripting).

You can learn more about existing environment variables by using env | more.

Copy the output from the history command into your lab report

Exercise 3: Commands, Piping and Plotting

Execute this sequence of commands, to create a directory in your workspace to work in for this lab:

Below I give a list of UNIX commands which I find useful and you'll use some of these now. Download the file FAIR.pfiles while in $GEOP555 using wget (You could create a subdirectory mkdir lab01, if you wanted to be organized):

Each of the commands given in the tables below does something and creates output that that can be piped into the others (multiple pipes are perfectly fine: command1 | command2 | command3 | ... | commandN). The general syntax of Unix commands given in the man-pages is generally something like command [options] file(s). This means you write the command name on the command line, you get to chose whether you want to use any of the options the command offers (square brackets usually indicate that things can be left out), and then you operate on one or more files. Here are the commands:

commanduseful optionsexplanation
ls -l, -s, -t, -rlist files in current directory
wc -l, -c, -w count lines, characters (bytes), words
head -#### (### represents number) output first part of a file
tail -#### (### represents number) output last part of a file
diffcompare files line by line
sort-n -r -ksort lines of text files
historynone.lists history of commands
df / du-k -hshow available disk-space / space used by files
catdisplay / concatenate files
top-n show process statistics, for piping use top -n 1 as it keeps running otherwise

Type ...

... and inspect the file. It comes with a header line that tells you what the columns mean. How many data points are in there, you wonder? (type 'q' to get out of less): gives you all lines, but remember there is a header line (wc stands for wordcount, but it does more): This command "grabs" all lines that don't have a # sign in them, then we pipe (|) it into wc, which gives us the number of data points. Give me the number of data points in your report.

OK, one last thing before the plotting: This does the same as above, omit lines with # in them, then we pipe it into awk and print columns 1,4,5, and 6. The output gets redirected into a new file FAIR.plot via the output redirection >. You can omit > FAIR.plot and everything ends up in you console again.

Now, use any tool you are comfortable with (matlab, python, gnuplot, ...) to write a short script that loads FAIR.plot and provides a figure with 3 subplots of, respectively, column 2,3,4 (in FAIR.plot) over column 1. What are the columns again? Label your axes! Make sure NOT to plot continuous lines, but circles/dots for each data point.

If you're into Matlab, here is a list of functions that might be of help (Python's matplotlib uses the same function names and syntax.).

Deliverables: (submit via canvas!)

rg <at> nmt <dot> edu | Last modified: August 23 2017 19:00.