COSC 071
Project 2

The California sea otter (enhydra lutris) was hunted almost to extinction along the California coast in the late 1800s and early 1900s because of the desirability of its dense, soft fur. In fact, for many years it was considered extinct along the California coast. In 1938, however, a small group of approximately 50 sea otters was discovered living off a remote section of coastline near Big Sur, California. Since then, they have been protected, and their population has been generally expanding (with a few declines along the way), until they currently number in the few thousands.

As the numbers of otters has climbed, the range which the otter population inhabits has been expanding. This has given biologists who study otters the opportunity to study the sea otter diet in different environments, outside of their primary kelp forest habitat. The Elkhorn slough is a relatively new foraging area for the otters, and marine biologists have been observing the feeding habits of otters moving into the area.

These observations have been made by a researchers from a few different points in the slough. They watch the otters forage through binoculars or telescopes, and record the prey item being consumed, and make an estimate of the item's size by comparing it to the size of the otter's paws.

The biologists field notes have been converted into simple data files that have multiple lines of the following format:

< observer > < food item > < size >

where < observer > is the first initial of the observer who recorded the observation.

< food item > is a code for the food item that was consumed, and is one of:

c Clam
u Urchin
w Worm
s Snail
a Abalone
m Mussel
? Unidentified

and < size > is the size of the food item measured in relation to the sea otter's paw, and is one of:

1 2 paw width of less in size (small food item)

2 2-3 paw widths in size (medium food item)

3 Larger than 3 paw widths in size (large food item)

for example, an 10-entry file may look like:

c c 2
C u 3
c w 2
j s 2
j A 3
j ? 3
J e 2
E a 2
l m 2
a W 1
Because the process of conversion from field notes was inconsistent, the code for observer and food item may be in either upper or lower case.

Assignment

Your job is to write a program that will process these input files and do basic analysis of the data in them. Your program should:

Sample Run

A sample run on the data file shown above is included below.

gusun> p2

This program will process observation data files from
sea otter feeding observations at Elkhorn Slough.

Please enter the name of the file to use for input: p2.data
Please enter the name of the file to use for output: p2.output

Error in item code in line 7

               Small    Medium     Large
     Clams         0         1         0
   Urchins         0         0         1
     Worms         1         1         0
    Snails         0         1         0
  Abalones         0         1         1
   Mussels         0         1         0
   Unknown         0         0         1

gusun> cat p2.output
               Small    Medium     Large
     Clams         0         1         0
   Urchins         0         0         1
     Worms         1         1         0
    Snails         0         1         0
  Abalones         0         1         1
   Mussels         0         1         0
   Unknown         0         0         1

What to turn in

There are two parts to this assignment. After the first part of the assignment has been turned in, I will post here several different data files, based on the results of the field observations, that you may use as you like in testing your programs.