HWR 597A -- Assignment 3

Reading:

Objectives:


Homework exercises (due 10:00 am, March 24, 2000):

1. Make a directory called ~/h597/3. Set protection so only you can read and write in this directory.

2. For this assignment, we will continue to process the monthly sea-level air pressure data taken at three sites: Iceland, Azores and Gibraltar. Recall that your Homework 2 assignment (do_nao) stripped out the first two columns of nao_ice.dat and (nao_azo.dat or nao_gib.dat). We will now calculate the NAO indices for these two columns of data which is the normalized difference between the air pressures.

3. You will modify your solution for Homework 2, call it: "calc_nao".

4. Your script should first check that you have the correct number of command-line arguments, in this case: 2. The first argument should always be: "nao_ice.dat". The second argument can either be "nao_azo.dat" or "nao_gib.dat". Your script should complain and exit if these filenames are not given in the correct order or are mispelled.

5. Your script should then check that these files indeed do exist and should complain and exit if they do not.

6. Your script should then prompt the user for an output filename and read that in.

7. Your script should then use the join command to join the two files based on their common field (field 1). See ~ray/help/help_join for help on the join command. It should output 3 columns: Year (column 1 from nao_ice.dat) (column 1 from nao_gib.dat or nao_azo.dat).

Here are the calculations you will need to obtain the NAO for Iceland and Gibraltar:
yr   ice   meanice sdice   normice    gib   meangib sdgib   normgib   NAO (normgib - normice)
1823 10175 9986.81 94.5458 1.99045    10146 10215.1 37.0143 -1.86723  -3.85768
1824 9957  9986.81 94.5458 -0.315312  10177 10215.1 37.0143 -1.02972  -0.714407
1825 9978  9986.81 94.5458 -0.0931974 10182 10215.1 37.0143 -0.894636 -0.801438
1826 10086 9986.81 94.5458 1.04911    10127 10215.1 37.0143 -2.38055  -3.42966
1827 10026 9986.81 94.5458 0.414493   10191 10215.1 37.0143 -0.651486 -1.06598
1828 9980  9986.81 94.5458 -0.0720437 10231 10215.1 37.0143 0.429178  0.501222
1829 10073 9986.81 94.5458 0.911606   10141 10215.1 37.0143 -2.00232  -2.91392
1830 10103 9986.81 94.5458 1.22891    10156 10215.1 37.0143 -1.59707  -2.82598

where:

yr = Year
ice = column 1 from nao_ice.dat
meanice = mean of column 1 from nao_ice.dat
sdice = standard deviation of column 1 from nao_ice.dat
normice = normalized value of column 1 from nao_ice.dat (value - mean)/stddev

gib = column 1 from nao_gib.dat
meangib = mean of column 1 from nao_gib.dat
sdgib = standard deviation of column 1 from nao_gib.dat
normgib = normalized value of column 1 from nao_gib.dat (value - mean)/stddev

Here is a sample running of the program "calc_nao"

% calc_nao nao_ice.dat nao_gib.dat
Please input name for output file:
junk.out
Processing input files: nao_ice.dat nao_gib.dat
Output stored in file: junk.out
plot data? (y/n)
y
% head junk.out
1823 -3.85768
1824 -0.714407
1825 -0.801438
1826 -3.42966
1827 -1.06598
1828 0.501222
1829 -2.91392
1830 -2.82598
1831 -3.36643
1832 -0.601626
8. Your script should be well-commented and robust. Make sure you test it out with bad data. I will test it when I grade it.

9. turnin hw3 calc_nao