Mandatory Tutorial 1 - Python and Plotting
September 16, 2024
1 Mandatory Tutorial 1
1.1 Python and Plotting
Welcome to our first mandatory tutorial! This tutorial will be completed and handed in by the
end of class and graded for correctness. Follow the instructions below – we’ll walk you through the
tutorial and get you plotting and exploring drag. By the end, we expect you to have a completet
Jupyter notebook answering all the questions that you will download as a PDF file for submission
via Canvas.
1.2 Step 0
First, we need to make sure you are able to run Python Jupyter notebooks. If you’re comfortable
with that already, skip ahead to Step 1; if not: * If you don’t already have Anaconda installed, you
can download it from here: [Link] * Install it – it might
take a while * Check it works by opening up Jupyter Notebook (Anaconda 3), which should open
a new tab in your browser, ready to go for you.
1.3 Step 1
We’ll provide you with a starting Jupyter Notebook (this one right here – you can get it at Canvas:
[Link] Open it up and work throught the
following steps.
1.4 Step 2
We’re going to focus on plotting in this tutorial. Here’s some code that plots a simple function:
[3]: import numpy as np
import [Link] as plt
def simple_function(x):
return x*[Link](x)
# make some arrays to hold data
x = [Link](0, 30, 100)
f = simple_function(x)
# a quick plot
1
[Link](x, f)
[3]: [<[Link].Line2D at 0x7f78c4248750>]
Make sure that you can run that code block with no problems, and then do the following:
1. Add an x label and ylabel
2. Change the function to something else – something that looks cool when plotted
1.5 Step 3
One last thing before we get started on the real tutorial. It’s often necessary to read in data from a
file; download the file “test_data.csv” from Canvas and put it in the same folder that this Jupyter
notebook is in. Here’s how you read that file in and plot the data:
[9]: x, f = [Link]("test_data.csv", delimiter=',', unpack=True)
[Link](x, f, "o")
[9]: [<[Link].Line2D at 0x7f7904429bd0>]
2
Notice that I plotted the data points as actually points rather than connecting them with a line;
that’s how it should be.
1.6 Step 4
Okay, now let’s get on to the actual tutorial!
I taped my phone to a pillow and dropped it from the ceiling – there are better ways of getting data
(you’ll see one in lab later), but this will do. My phone, using the “phyphox” app, recorded the ac-
celeration data for me. You can download that data from Canvas as well (“accel_data_pillow.csv”).
The columns of data are as follows: time, 𝑎𝑥 , 𝑎𝑦 , 𝑎𝑧 , |𝑎|. You’ll want to look at the magnitude of
𝑎 for this.
Now, it turns out that for linear motion under some circumstances, the acceleration is given by
𝑎(𝑡) = 𝑔𝑒−𝑡/𝜏 ,
where 𝜏 is called a “characteristic time” and is related to the terminal speed 𝑣𝑡 by
𝑣𝑡 = 𝑔𝜏 .
You goal for this tutorial is to estimate the terminal speed of the pillow. Do so by plotting the
data along with the theoretical function for 𝑎(𝑡) and adjust 𝜏 until the data is fit.
You’ll submit, when done, a new Jupyter notebook containing both code and explanations (using
markdown blocks). Have your code clearly print out the values of 𝜏 and 𝑣𝑡 that you think are best,
and discuss the values – are they reasonable? Is the fit okay or could it be better? Is there a better
way of finding best-fit values?