February 5th, 2013, 12:42 AM
Some Python HW help
here is the section of the assignment and what I have so far. I dont have a very good grasp of reshaping arrays so I feel like I'm just plug and chugging at this point
4. Compute the average height that Falls Lake is relative to its target
# for each month over the 23 years from 1985-2007, and display as bar
# chart with a bar for each month. Plot the line for 2007 in red on
# top of this bar chart.
# start a new figure for the this part
# put code here to compute FallsByMonth
numRows = depth.shape / 23
qData = np.reshape( depth[:,0]-251.5, (numRows, -1), order = 'F')
FallsByMonth = np.mean( qData, axis = 0 )
FallsByMonth = np.reshape( FallsbyMonth, (-1,12), order='F')
# then you can create a bar chart of it like this:
# pylab.bar(np.arange(1,13), FallsByMonth, align='center')
pylab.bar(np.arange(1,13) , FallsByMonth, align = 'center')
# then plot a line in red on top of that with a call to plot like this:
# pylab.plot(np.range(1,13), something_goes_here, 'r')
pylab.plot(np.range(1,13), FallsByMonth, 'r')
pylab.title('Average Falls lake depth 85-07, and line for 2007')
pylab.ylabel('Height above target(ft)')
February 5th, 2013, 11:49 AM
I'll admit to having found
average height that Falls Lake but it would be better if you showed a complete program (with imports) and the data.
You asked about reshape, and reshape requires that the product of the axes lengths matches the the length of the flattened data. So it's important to know exactly what you've got.
[/code] are essential for python code and Makefiles!