University of Alaska Fairbanks
Department of Geosciences

GEOS F493 / F693 - 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 you will have to explore on your own - this will only help you in your (grad) student careers.

Log into the machines and reset your password as described on Blackboard.

Exercise I: Setting up your environment

The first thing you'll do is create a directory for this course and for this lab

If you now type pwd you should get /home/USERNAME/geodesy/lab01 where USERNAME is your user name.
The first line gets you to your home directory (echo $HOME), the second line creates a directory "geodesy", the third line creates a subdirectory "lab01" in "geodesy" and the fourth line "changes directories (cd)" into geodesy/lab01. Note that the command cd without any parameters always gets you back $HOME).

Now open your bash profile (sets up your environment) in vi (a text editor): This may take a little while, but opens .bash_profile 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 these lines to the file:
        GEODESY=$HOME/geodesy
        export GEODESY
		
This creates a new environment variable GEODESY and sets its value to the directory $HOME/geodesy. 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. Now you will always be able to "cd" into this directory for the class via: I'll verify this, because I'll be using $GEODESY 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 $GEODESY using wget.

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.

If you're in the WRRB 004 lab on a Windows machine, X11 forwarding does not work. So you can't see any GUIs. You can work locally on these Windows machines with Matlab or Python to do the plotting. Retrieve the file you just created with (in a Windows Command Prompt:

You should now have the FAIR.plot file in your local directory.

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.). Note that I will begin working with Python notebooks starting next week. Familiarizing with that syntax will reap benefits then.

Deliverables: (submit via blackboard!)

rg <at> nmt <dot> edu | Last modified: September 04 2019 21:32.