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.
The first thing you'll do is create a directory for this course and for this lab
hare:~> cd ~
hare:~> mkdir geodesy
hare:~> mkdir geodesy/lab01
hare:~> cd geodesy/lab01
pwd
you should get /home/USERNAME/geodesy/lab01
where USERNAME is your user name.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
).
hare:~> gedit ~/.bash_profile &
.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.
GEODESY=$HOME/geodesy export GEODESYThis 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:
hare:~> source ~/.bash_profile
hare:~> cd $GEODESY
hare:~> ls
hare:~> cd $GEODESY
$GEODESY
a lot in future labs.
Type these commands and follow the output on the screen. I want you to get to know this world a bit better:
> cd /usr/bin
> ls
> ls | more
> man more
> man man
> cd ~
> pwd
> whoami
> echo $USER
> cd $GEODESY
> matlab &
&
pushes the new process in the background which allows you to continue using this terminal window.
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
Execute this sequence of commands, to create a directory in your workspace to work in for this lab:
> cd $GEODESY/lab01
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
.
> wget http://grapenthin.org/teaching/geodesy/lab01/FAIR.pfiles
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:
command | useful options | explanation |
ls | -l, -s, -t, -r | list 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 |
diff | compare files line by line | |
sort | -n -r -k | sort lines of text files |
history | none. | lists history of commands |
df / du | -k -h | show available disk-space / space used by files |
cat | display / concatenate files | |
top | -n | show process statistics, for piping use top -n 1 as it keeps running otherwise |
Type ...
> less FAIR.pfiles
> wc -l FAIR.pfiles
wc
stands for wordcount, but it does more):
> grep -v "#" FAIR.pfiles | wc -l
#
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:
> grep -v "#" FAIR.pfiles | awk '{print $1,$4,$5,$6}' > FAIR.plot
#
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:
> scp USERNAME@badger.giseis.alaska.edu:/home/USERNAME/geodesy/lab01/FAIR.plot .
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.
textread
: read a text filetextscan
: read a text file differentlyfigure
: creates a canvas which to draw onsubplot
: creates "tiling" of the canvas, so you can have multiple plots in 1 figureplot
: plots one data set over the other.xlabel
: label x-axisylabel
: guess!title
: guess again!FAIR.plot
file you createdrg <at> nmt <dot> edu | Last modified: September 04 2019 21:32.