hw2_sol - #! /usr/bin/env python # AST5765/4932 2009 HW2...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
# AST5765/4932 2009 HW2 Solutions # 1. # a. import numpy as np x = np.arange(0., 1001, 1, dtype=np.float64) print(x.dtype) # b. pi = np.pi x /= x.max() # This is safe. Some divided by 1000, but some by 1001. .. x *= 2. * pi # *= and /= are in-place operations; no copy of x is made. # c. y = np.sin(x) # 2. # a. # see above # b. import pylab as plt plt.figure(1) plt.plot(x, y) plt.title('y = sin(x)') plt.xlabel('Phase') plt.ylabel('Amplitude') #plt.show() # c. plt.savefig('hw2-sol-prob2-plot1.png') # 3. ramp = np.linspace(-1., 1., 101) # NOTE: final decimal points ramp = np.clip(ramp, -0.5, 0.5) plt.figure(2) plt.plot(ramp) plt.title('Clipped Ramp') plt.xlabel('X') plt.ylabel('Y') #plt.savefig('hw2-sol-prob3a-plot1.png') # screenshot called for plt.show() # screenshot called for import commands commands.getoutput('gnome-panel-screenshot') commands.getoutput('mv ~/Desktop/Screenshot.png ~/ast/teaching/ast5765/hw/hw2/hw2_sol/hw2-sol-prob3b-plot1.png') # 4. nx = 200
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/09/2009 for the course AST 4762 taught by Professor Harrington during the Fall '09 term at University of Central Florida.

Page1 / 2

hw2_sol - #! /usr/bin/env python # AST5765/4932 2009 HW2...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online