First-Week Lab Instructions

Note: If your monitor shows a Mac login screen, let Steve Goryl or me know right away so we can fix it.

The purpose of this lab is to

  1. Get familiar with our Linux computers

  2. Get familar with NumPy and matplotlib

  3. Make sure we can use Sakai turnins
The deliverable for this lab will be a single PDF document, copied into your Sakai turnin folder.

If you're reading this, you've probably already logged into one of the Linux computers in the lab. Move your mouse to a free area on the desktop, click the right mouse button, and choose New Folder. Create a folder called lab1 and double-click on it to open it. Inside this folder, click the right mouse button again, but this time choose Open in Terminal. A little terminal (command window) should pop up. Inside this window, type idle3 and hit Enter. You are now ready to type your first Python commands.

Here are the commands to make a simple sine-wave plot. Note that the triple-arrow >>> is the Python prompt, which you should not include when typing in your commands. (Pro tip: Copying-and-pasting commands is usally less error-prone than trying to type them yourself: left-drag to highlight; right-click/copy; move to IDLE; right-click/paste; Enter)

>>> from numpy import *
>>> from matplotlib.pyplot import *
>>> x = linspace(0, 2*pi, 1000)
>>> y = sin(x)
>>> plot(x, y)
>>> show()

Once you're comfortable typing commands, you'll want to add a couple of keyboard shortcuts to save time re-typing. At the top of the IDLE3 window, choose Options/Configure IDLE. A little dialog window will pop up with a bunch of tabs at the top. Choose the Keys tab. In the white area toward the bottom you'll see an alphabetized list of Custom Key Bindings. Scroll down to history-next, and select it. Then click the big button Get New Keys for Selection. (If you're asked for a name under which to save the custom bindings, enter something simple like custom.) Another little dialog will pop up, allowing you scroll to the name of the key you want. Choose Down Arrow. Click Ok, then repeat this process for the history-previous key, for which you should choose Up Arrow. Once you've set up these two keys, choose Ok to exit the main dialog.

Once you've got a nice plot to show off, go to the figure window (usually titled Figure 1), and click the little floppy-disk buttton at the bottom of the figure to save the plot in PNG format. Make sure to save it in the lab1 folder that you created for this lab, and call it something sensible, like sineplot.png.

To produce your writeup, look in the Applications menu in the upper-left part of the desktop. Under that menu, go to Office, and choose Libre Office Writer, which is a free / open-source version of Microsoft Word. The first thing you should do is put your name, the date, and other identifying information (name of this class, Lab #1) at the top. Then save this document in the same lab1 folder, naming it (of course) lab1. Drag your figure PNG into the document, then right-click on it to add a little caption. To finish up, add a brief explanation of the linspace function that you used to generate the x values. You can get the explanation by doing

>>> help(linspace)
in the Python shell, or by goolging linspace.

Once you've got a nice-looking writeup, export the document to PDF format and upload it to Sakai. Make sure you only upload this PDF: you will get no credit for a document in any other format.