Skip to content

Commit 73133cd

Browse files
committed
Cleaning up instructions
1 parent e97485f commit 73133cd

11 files changed

Lines changed: 627 additions & 521 deletions

‎Week_1_arrays/HW_1_data_numpy.ipynb‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@
422422
"outputs": [],
423423
"source": [
424424
"\n",
425-
"# This should be of the form (r,c)\n",
425+
"# This should be of the form (r,c). For the wrist torque channel, the answer is (82, 863)\n",
426426
"row_max_wrist_torque_z = ..."
427427
]
428428
},
@@ -500,6 +500,7 @@
500500
" # Add an x axis label\n",
501501
" # Add a y axis label (using the units in the channel_info)\n",
502502
" #. Add a title (using the name in the channel_info)\n",
503+
" # Add a legend\n",
503504
" # Add horizontal lines for the min/max values (which should be stored in the channel_info now)\n",
504505
" # Example plot command\n",
505506
" axs.plot(ts, ys[0], label=\"x\")\n"
@@ -527,9 +528,9 @@
527528
"source": [
528529
"<!-- END QUESTION -->\n",
529530
"\n",
530-
"## Wee, 2: Problem 1b: Plot Wrist force/torque for min/max wrist torque z\n",
531+
"## Week, 2: Problem 1b: Plot Wrist force/torque for min/max wrist torque z\n",
531532
"\n",
532-
"Find the row that has the maximum (minimum) wrist torqu z value. Plot the minimum one in the top row, the maximum\n",
533+
"Find the row that has the maximum (minimum) wrist torque z value. Plot the minimum one in the top row, the maximum\n",
533534
"one in the bottom row\n",
534535
"\n",
535536
"Your actual plotting code (the function) shouldn't have to change, btw. Just what data you send it.\n",
@@ -680,7 +681,7 @@
680681
"name": "python",
681682
"nbconvert_exporter": "python",
682683
"pygments_lexer": "ipython3",
683-
"version": "3.7.4"
684+
"version": "3.7.3"
684685
},
685686
"otter": {
686687
"OK_FORMAT": true,

‎Week_2_plotting/Lab_2_plotting.ipynb‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@
9191
"metadata": {},
9292
"source": [
9393
"## Part 2 - plot both the wrist force and the wrist torque in the same figure\n",
94-
"Force on the left, Torque on the right. Don't forget labels and titles."
94+
"Force on the left, Torque on the right. Don't forget labels and titles.\n",
95+
"\n",
96+
"You can do this one of two ways; note that in the hwk you'll need to do the 2nd option (with some help), but if you want to try it now, feel free.\n",
97+
"- Option 1: Copy and paste the code from above (twice) and change the relevant data/lines of code (axs[], names/titles, start index) in the second copy\n",
98+
"- Option 2: Encapsulate the plotting part in a function then call that function twice\n",
99+
" - pass in the axes to plot in, along with t values (or create them within the function)\n",
100+
" - do the x,y,z loop inside of the plot"
95101
]
96102
},
97103
{
@@ -176,7 +182,7 @@
176182
"\n",
177183
"Make sure you have run all cells in your notebook in order before running the cell below, so that all images/graphs appear in the output. The cell below will generate a zip file for you to submit. **Please save before exporting!**\n",
178184
"\n",
179-
"Submit just the .ipynb file to Gradescope. Don't change the provided variable names or autograding will fail."
185+
"Submit just the .ipynb file to Gradescope. Don't change the provided variable names or autograding will fail. Make sure you run kernel->restart and run all before turning in and that your plots are visible (otherwise, you will get a zero)"
180186
]
181187
},
182188
{
@@ -216,7 +222,7 @@
216222
"name": "python",
217223
"nbconvert_exporter": "python",
218224
"pygments_lexer": "ipython3",
219-
"version": "3.7.4"
225+
"version": "3.7.3"
220226
},
221227
"otter": {
222228
"OK_FORMAT": true,

‎Week_2_plotting/Lab_2_plotting.py‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,13 @@
4545
# --------------------------- Part 2 -------------------------------
4646
# Plot the Wrist torque data in the second window.
4747
#
48-
# You can do this one of three ways; note that in the hwk you'll need to do the 3rd option (with some help), but
48+
# You can do this one of two ways; note that in the hwk you'll need to do the 2nd option (with some help), but
4949
# if you want to try it now, feel free.
5050
#
51-
# Option 1: Copy and paste the code from above and change the relevant data/lines of code (axs[], names/titles, start index)
51+
# Option 1: Copy and paste the code from above (twice) and change the relevant data/lines of code (axs[], names/titles, start index) in the second copy
5252
# Option 2: Encapsulate the plotting part in a function then call that function twice
5353
# - pass in the axes to plot in, along with t values (or create them within the function)
5454
# - do the x,y,z loop inside of the plot
55-
# Option 3: Write a for loop that loops over all the data channels and plots all of them (see HW 1)
56-
# Note: You will need a second for loop for the dimensions (see HW 1)
57-
# Note: For the axes, you'll need row-column indexing to convert from the channel number back to a row column
5855

5956
# There is a way to add subplots to the current figure, but for this assignment, just close the current figure and
6057
# call subplots again with 1 row and 2 columns

‎Week_3_fitting/Data/week3_Wrist force_summed_failed.csv‎

Lines changed: 128 additions & 128 deletions
Large diffs are not rendered by default.

‎Week_3_fitting/Data/week3_Wrist force_summed_successful.csv‎

Lines changed: 166 additions & 166 deletions
Large diffs are not rendered by default.

‎Week_3_fitting/Lab_3_data_fitting.ipynb‎

Lines changed: 110 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"source": [
2121
"# Lab week 3: Data fitting to see if we can detect a pick success y/n\n",
2222
"\n",
23-
"Can you use the finger 1 stop time and max value to tell the difference between successful and not?\n",
23+
"Can you use the finger 1 stop time and max value to tell the difference between a successful and a failed pick?\n",
2424
"Lab slides: https://docs.google.com/presentation/d/1NtoXYbl2nq1dkIU0KQE8ogjSCfb22wgLigY3JJpHHGI/edit?usp=sharing\n"
2525
]
2626
},
@@ -81,11 +81,11 @@
8181
"source": [
8282
"## Box plot of fitted lines for all data\n",
8383
"\n",
84-
"In the pre-lecture you fitted the line to just one row each of the successful/failed picks. In this lab you'll fit the line to ALL of the picks. For each pick, save the end point (time and y_max value of the motor). You'll be making a box plot of this data to see if it looks different for successful versus failed picks.\n",
84+
"In the pre-lecture you fit a line to just one row (each) of the successful versus failed picks. In this lab you'll fit the line to ALL of the picks. For each pick, save the end point (time at the y_max value and the y_max value). You'll be making a box plot of this data to see if it looks different for successful versus failed picks.\n",
8585
"\n",
8686
"Why a box plot? Box plots are better for visually showing multiple distributions in the same plot, where they can be compared side-by-side\n",
8787
"\n",
88-
"See lab slides for what this should look like when you're done"
88+
"See lab slides for what this should look like when you're done."
8989
]
9090
},
9191
{
@@ -96,10 +96,31 @@
9696
},
9797
"outputs": [],
9898
"source": [
99-
"# from pre_lecture_3_fitting import fit_line_to_middle_bit\n",
100-
"\n",
10199
"...\n",
102100
"\n",
101+
"# TODO: get the fit_line_to_middle_bit function, either by copying it over here, or importing it from a .py file\n",
102+
"#. Optional (import):\n",
103+
"# from pre_lecture_3_fitting import fit_line_to_middle_bit\n",
104+
"# Otherwise, copy function here\n",
105+
"#\n",
106+
"# TODO: Check that it works\n",
107+
"#. - Create t values\n",
108+
"# - Call fit_line_to_middle_bit with the first row of the successful data and see if your answers\n",
109+
"#. match the answers from pre-lecture\n",
110+
"# END PROMPT\"\"\"\n"
111+
]
112+
},
113+
{
114+
"cell_type": "code",
115+
"execution_count": null,
116+
"metadata": {
117+
"tags": []
118+
},
119+
"outputs": [],
120+
"source": [
121+
"\n",
122+
"# TODO:\n",
123+
"# Create a function that computes the \n",
103124
"# nx2 arrays of t, y values of end point of fitted line\n",
104125
"end_times_successful = ... \n",
105126
"end_times_failed = ... \n",
@@ -113,6 +134,47 @@
113134
"cell_type": "code",
114135
"execution_count": null,
115136
"metadata": {
137+
"tags": []
138+
},
139+
"outputs": [],
140+
"source": [
141+
"\n",
142+
"# TODO:\n",
143+
"# Create a function that loops over all of the rows of the data and accumulates the start and end times\n",
144+
"#. in an nx2 array of t (first row) and y (second row)\n",
145+
"# I'd recommend a function that takes both the t values and the data, so you don't have to keep recomputing\n",
146+
"#. the t values\n",
147+
"#. def fit_middle_all(ts, data)\n",
148+
"#. make numpy array to put data in (nx2)\n",
149+
"#. for each row in data\n",
150+
"#. start_pt, end_pt = fit_line_to_middle_bit(ts, current row)\n",
151+
"# copy end_pt information into appropriate row in nx2 output\n",
152+
"#. return nx2 numpy array\n",
153+
"# END PROMPT\"\"\""
154+
]
155+
},
156+
{
157+
"cell_type": "code",
158+
"execution_count": null,
159+
"metadata": {
160+
"tags": []
161+
},
162+
"outputs": [],
163+
"source": [
164+
"# Check that it works properly\n",
165+
"\n",
166+
"# TODO:\n",
167+
"# Create the t values\n",
168+
"#. Call your function twice, once with the successful data, once with the failed\n",
169+
"end_times_successful = ...\n",
170+
"end_times_failed = ...\n",
171+
"# END PROMPT\"\"\""
172+
]
173+
},
174+
{
175+
"cell_type": "code",
176+
"execution_count": null,
177+
"metadata": {
116178
"deletable": false,
117179
"editable": false
118180
},
@@ -129,11 +191,10 @@
129191
},
130192
"outputs": [],
131193
"source": [
132-
"from pre_lecture_3_fitting import fit_line_to_middle_bit\n",
133-
"\n",
194+
"# Two plots\n",
134195
"n_rows = 1\n",
135196
"n_cols = 2\n",
136-
"fig, axs = plt.subplots(n_rows, n_cols)\n",
197+
"fig, axs = plt.subplots(n_rows, n_cols, figsize=(8, 4))\n",
137198
"\n",
138199
"...\n",
139200
"\n",
@@ -147,16 +208,18 @@
147208
"source": [
148209
"<!-- END QUESTION -->\n",
149210
"\n",
150-
"# Part 2: Fitting a curve to the summed wrist force data\n",
211+
"# Part 2: Fitting a curve to the wrist force data\n",
151212
"\n",
152-
"## First step: calculate the data\n",
213+
"## First step: Getting the data\n",
153214
"\n",
154-
"Data to plot: sqrt (sum x,y,z (wrist force data)^2)\n",
155215
"\n",
156-
"Read in wrist force data, sum it, and (optional) write it out to two csv files (one for successful, one for failed)\n",
157-
" Feel free to swipe code from Lecture_3_data_analysis.ipynb to do this\n",
216+
"The wrist force data has three channels (x,y,z). For this assignment, we want to get out the total summed force at the wrist, rather than each channel individually:\n",
158217
"\n",
159-
"The data files are also in the directory, so you can read them in if you're having trouble calculating the data yourself.\n"
218+
"Equation: **sqrt (sum x,y,z (wrist force data)^2)**\n",
219+
"\n",
220+
"Just like the last problem, the data has already been extracted from the proxy_pick_data.csv file and output for you (week3_Wrist force_summed_*.csv). \n",
221+
"\n",
222+
"Optional: Do this extraction yourself. Read in wrist force data, sum it, and write it out to two csv files (one for successful, one for failed). Feel free to swipe code from Lecture_3_data_analysis.ipynb to do this."
160223
]
161224
},
162225
{
@@ -168,8 +231,11 @@
168231
"outputs": [],
169232
"source": [
170233
"\n",
234+
"# TODO: Read in the data from Data/week3_Wrist_force summed*.csv (successful and failed)\n",
235+
"# TODO: Optional: Read in the pick data and its description file, extract out the rows and columns you\n",
236+
"#. care about, and write that data out (should be same as the .csv files)\n",
171237
"data_wrist_force_successful = ...\n",
172-
"data_wrist_force_failed = ,,,\n",
238+
"data_wrist_force_failed = ...\n",
173239
"# END PROMPT\"\"\"\n"
174240
]
175241
},
@@ -191,11 +257,33 @@
191257
"source": [
192258
"<!-- BEGIN QUESTION -->\n",
193259
"\n",
194-
"## Second step: Fit a cubic to the first rows of the successful and failed plots\n",
260+
"## Second step: Fit a cubic to the wrist force data (18 rows each successful/failed)\n",
261+
"\n",
262+
"Split by successful and failed.\n",
263+
"\n",
264+
"TODO: See slides for what the final plots should look like. I've handled the for loop and the plot indexing for you.\n",
265+
"\n",
266+
"At this point, you should have the data in the form ts, ys for both the successful and the failed data. \n",
267+
"\n",
268+
"Where you're headed (pseudo code)\n",
269+
"\n",
270+
"for 18 rows of data\n",
271+
"\n",
272+
" Fit a cubic polynomial to the data\n",
273+
" \n",
274+
" Plot the original data plus the fitted polynomial\n",
275+
" \n",
276+
" First three rows: successful, last three rows: failed\n",
277+
"\n",
278+
"Implementation steps: You could write a function for doing the polynomial fit, but since there already is one (polynomial.polyval) you probably don't need one.\n",
195279
"\n",
196-
"I've copied over the code from Lecture 3 - you just need to fit the polynomial and plot that, too\n",
280+
"Steps\n",
281+
"- Fit polynomial for one row of data\n",
282+
"- Plot it and make sure it looks correct\n",
283+
"- Copy that code into the for loop, adjusting for which row (p) and which subplot (axs[r, c])\n",
284+
"- Repeat for the failed data\n",
197285
"\n",
198-
"plt.close(fig)"
286+
"Note: It can take a few seconds to plot."
199287
]
200288
},
201289
{
@@ -208,7 +296,7 @@
208296
"source": [
209297
"n_rows = 6\n",
210298
"n_cols = 6\n",
211-
"fig, axs = plt.subplots(n_rows, n_rows, figsize=(10, 10))\n",
299+
"fig, axs = plt.subplots(n_rows, n_rows, figsize=(16, 16))\n",
212300
"for p in range(0, (n_rows // 2) * n_cols):\n",
213301
" r, c = p // n_cols, p % n_cols\n",
214302
" axs[r, c].plot(ts, data_wrist_force_successful[p])\n",
@@ -217,7 +305,7 @@
217305
"\n",
218306
"for p in range(0, (n_rows // 2) * n_cols):\n",
219307
" r, c = 3 + p // n_cols, p % n_cols\n",
220-
" axs[r, c].plot(ts, data_failed[p])\n",
308+
" axs[r, c].plot(ts, data_wrist_force_failed[p])\n",
221309
" ...\n",
222310
" axs[r, c].set_title(f\"{ch_name} summed\" + f\" fail {p}\", fontsize=10)\n",
223311
"\n",
@@ -282,7 +370,7 @@
282370
"\n",
283371
"Make sure you have run all cells in your notebook in order before running the cell below, so that all images/graphs appear in the output. The cell below will generate a zip file for you to submit. **Please save before exporting!**\n",
284372
"\n",
285-
"Submit through gradescope, week 3 lab"
373+
"Submit through gradescope, week 3 lab. Turn in just the .ipynb file - we will supply the data files."
286374
]
287375
},
288376
{
@@ -322,7 +410,7 @@
322410
"name": "python",
323411
"nbconvert_exporter": "python",
324412
"pygments_lexer": "ipython3",
325-
"version": "3.7.4"
413+
"version": "3.7.3"
326414
},
327415
"otter": {
328416
"OK_FORMAT": true,

‎Week_3_fitting/Lab_3_data_fitting.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676

7777
for p in range(0, (n_rows // 2) * n_cols):
7878
r, c = 3 + p // n_cols, p % n_cols
79-
axs[r, c].plot(ts, data_failed[p])
79+
axs[r, c].plot(ts, data_wrist_force_failed[p])
8080
# YOUR CODE HERE
8181
axs[r, c].set_title(f"{ch_name} summed" + f" fail {p}", fontsize=10)
8282

0 commit comments

Comments
 (0)