
February 4th, 2013, 11:42 PM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 1
Time spent in forums: 6 m 40 sec
Reputation Power: 0
|
|
|
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
pylab.figure(4)
# put code here to compute FallsByMonth
numRows = depth.shape[1] / 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[13], 'r')
pylab.title('Average Falls lake depth 85-07, and line for 2007')
pylab.ylabel('Height above target(ft)')
pylab.xlabel('Month')
pylab.savefig('Fig3.png')
pylab.show(4)
|