Assignment 2 Solved

30.00 $

Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


5/5 - (2 votes)

Assignment 2

This assignment will give you the chance to work with two-dimensional arrays, slicing, plotting, and data-analysis.  The key to success on this assignment is to come to terms with the interpretation of the rows and columns of the data.  In this assignment you will answer various questions about the data.  Some answers will be plots and some will be printed statements.  As with every assignment, it’s important you follow the instructions carefully so that the output of your program is precise.


The modern technological age has given us the power to measure just about everything.  Water is an all-important resource for life and civilization and the ability to monitor critical water levels is a necessity.  Jordan and Falls lakes are the two largest lakes in the immediate vicinity of Chapel Hill.  These lakes and the surrounding rivers serve an important role in the Triangle’s water resources; their levels reflect the levels of available water.  We will be examining data from the USGS for North Carolina,, and more data from the US Army Corps of Engineers,  The data itself is raw and largely incomprehensible.  We will be analyzing and visualizing it to understand it and determine underlying trends.

We will use the following four files:

depth.txt: a 276 X 2 table of depth measurements of Jordan and Falls lakes for each month from January 1985 to December 2007.  When actual data is unavailable the table contains NaN.

rain.txt: a 276 X 2 table of data which records the total rainfall, in inches, for each month at each lake.

hawgage.txt: a 365 X 4 matrix of daily average river/lake heights, in feet, at Haw River, Bynum and above and below the Jordan Lake Dam by Moncure.

hawrain.txt: a 365 X 2 matrix of daily rainfall, in inches, measured at two rain gauges from Aug. 29, 2007 – Aug. 28, 2008.

The problems posed in the assignment can be answered by examining these files.

Assignment Description

As in previous assignments, for this assignment you will edit a provided file.  There are 8 questions commented out in the given file.  The comments provide the specific details of the question you should answer.  This page is merely an overview of the whole.  As is before, when the homework is graded, we will copy your script to an alternative location, and run it.  If it doesn’t produce the desired output, you will lose points.

  1. Plot a line graph of depths for both lakes.  You should end up with a single saved figure with two plots–one for each lake spanning the entire time range.  This uses the data in depth.txt.
  2. How many months was each lake’s depth more than its target depth?  The output of this will be a printed statement of the format: “Months Jordan lake exceeded its target depth: ##” and “Months Falls Lake exceeded its target depth: ##”.  This uses the data in depth.txt.
  3. Plot the rain in August over all the years as a line graph for both lakes.  The result of this will be a single saved figure with two line plots.  This uses the data in rain.txt.
  4. Show the average deviation from target depth for Falls Lake for each month over the years of data as a bar chart and draw the deviation from target depth for 2007.  The output of this is a figure with two kinds of plots in the same figure.  A bar chart with a line plot on top.  This uses the data in depth.txt. Note: height relative to target allows for negative numbers; the lake is sometimes below its target.
  5. How many days had more than an inch of rain at both site?  How many days had less than 1/4 inch?  The output will be print statements of the form, “Number of days both lakes had more than one inch: ##” and “Number of days both lakes had less than 1/4 inch: ##”.  This uses the data in hawrain.txt.  Hint: You will need logical_and.
  6. Show a plot of the cumulative rain at both sites.  Which site had more rain?  The plot will be a saved figure showing two line plots.  The question of which site has more rain will be a print statement of the form: “The site with more total rain: #” (where # should be 1 or 2).  This uses the data in hawrain.txt. Hint: You will need cumsum.
  7. Find the lowest height for each gauge and produce an array of adjusted heights by subtracting the corresponding lowest heights.  Plot these adjusted heights as a line graph.  The output is a single, saved figure with four line plots on it.  This uses hawgage.txt.
  8. Determine the maximum increase and maximum decrease in height from one day to another for each of the four gauges in hawgage.txt.  The output of this will be two print statements. Hint: You will find diff