Skip to content

Commit 79239cb

Browse files
committed
Started lab 1
1 parent f9bcb9c commit 79239cb

3 files changed

Lines changed: 75 additions & 24 deletions

File tree

‎Week_1_data_structures/.OTTER_LOG‎

1012 Bytes
Binary file not shown.

‎Week_1_data_structures/Lab_1_data_analysis.ipynb‎

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 10,
66
"metadata": {
77
"deletable": false,
88
"editable": false
@@ -48,7 +48,7 @@
4848
},
4949
{
5050
"cell_type": "code",
51-
"execution_count": null,
51+
"execution_count": 11,
5252
"metadata": {},
5353
"outputs": [],
5454
"source": [
@@ -74,23 +74,34 @@
7474
},
7575
{
7676
"cell_type": "code",
77-
"execution_count": null,
77+
"execution_count": 15,
7878
"metadata": {
7979
"tags": [
8080
"otter_answer_cell"
8181
]
8282
},
83-
"outputs": [],
83+
"outputs": [
84+
{
85+
"name": "stderr",
86+
"output_type": "stream",
87+
"text": [
88+
"<>:3: SyntaxWarning: invalid escape sequence '\\S'\n",
89+
"<>:3: SyntaxWarning: invalid escape sequence '\\S'\n",
90+
"C:\\Users\\HunterJi\\AppData\\Local\\Temp\\ipykernel_30872\\2403592241.py:3: SyntaxWarning: invalid escape sequence '\\S'\n",
91+
" clap_data = np.loadtxt(\"Data\\S01C01.csv\", dtype=\"float\", delimiter=\",\")\n"
92+
]
93+
}
94+
],
8495
"source": [
8596
"\n",
8697
"# TODO - put the code to load the data \n",
8798
"# Make sure you save it into the variable name given - clap_data - or the autograder won't work.\n",
88-
"clap_data = ..."
99+
"clap_data = np.loadtxt(\"Data\\S01C01.csv\", dtype=\"float\", delimiter=\",\")"
89100
]
90101
},
91102
{
92103
"cell_type": "code",
93-
"execution_count": null,
104+
"execution_count": 16,
94105
"metadata": {
95106
"tags": [
96107
"otter_answer_cell"
@@ -128,30 +139,48 @@
128139
},
129140
{
130141
"cell_type": "code",
131-
"execution_count": null,
142+
"execution_count": 21,
132143
"metadata": {
133144
"tags": [
134145
"otter_answer_cell"
135146
]
136147
},
137-
"outputs": [],
148+
"outputs": [
149+
{
150+
"name": "stdout",
151+
"output_type": "stream",
152+
"text": [
153+
"Number of time steps: 101\n"
154+
]
155+
}
156+
],
138157
"source": [
139158
"# TODO\n",
140159
"# - set the n_time_steps variable. Do NOT just put in a number - use the variable clap_data to calculate this.\n",
141160
"# - change the print line to print out the number of time steps\n",
142-
"n_time_steps = ...\n",
143-
"print(f\"Number of time steps: {}\")"
161+
"n_time_steps = np.shape(clap_data)[0]\n",
162+
"print(f\"Number of time steps: {n_time_steps}\")"
144163
]
145164
},
146165
{
147166
"cell_type": "code",
148-
"execution_count": null,
167+
"execution_count": 22,
149168
"metadata": {
150169
"tags": [
151170
"otter_answer_cell"
152171
]
153172
},
154-
"outputs": [],
173+
"outputs": [
174+
{
175+
"name": "stdout",
176+
"output_type": "stream",
177+
"text": [
178+
"Third column: [11.92438773 12.83811787 12.74563683 18.88675076 15.89095011]\n",
179+
"How many numbers are above 0.5? 5\n",
180+
"Sum of array as double 5.0 and integer 5\n"
181+
]
182+
}
183+
],
155184
"source": [
156185
"# EXAMPLE CODE\n",
157186
"# Remember you want all of the rows - that's what the : is for\n",
@@ -173,23 +202,32 @@
173202
},
174203
{
175204
"cell_type": "code",
176-
"execution_count": null,
205+
"execution_count": 25,
177206
"metadata": {
178207
"tags": [
179208
"otter_answer_cell"
180209
]
181210
},
182-
"outputs": [],
211+
"outputs": [
212+
{
213+
"name": "stdout",
214+
"output_type": "stream",
215+
"text": [
216+
"Number of datapoints with positive z: 53\n",
217+
"Number of datapoints with negative z: 48\n"
218+
]
219+
}
220+
],
183221
"source": [
184222
"# TODO - set the variables n_pos_z and n_neg_z and print them out. Do NOT just put in a number - use the variable\n",
185223
"# clap_data.\n",
186224
"\n",
187225
"\n",
188-
"n_pos_z = ...\n",
189-
"print(f\"Number of datapoints with positive z: {}\")\n",
226+
"n_pos_z = np.count_nonzero(clap_data[:,3] > 0) \n",
227+
"print(f\"Number of datapoints with positive z: {n_pos_z}\")\n",
190228
"\n",
191-
"n_neg_z = ...\n",
192-
"print(f\"Number of datapoints with negative z: {}\")"
229+
"n_neg_z = np.count_nonzero(clap_data[:,3] < 0) \n",
230+
"print(f\"Number of datapoints with negative z: {n_neg_z}\")"
193231
]
194232
},
195233
{
@@ -936,7 +974,7 @@
936974
"name": "python",
937975
"nbconvert_exporter": "python",
938976
"pygments_lexer": "ipython3",
939-
"version": "3.11.7"
977+
"version": "3.12.7"
940978
},
941979
"otter": {
942980
"OK_FORMAT": true,

‎Week_1_data_structures/a_tutorial_numpy.ipynb‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
{
2525
"cell_type": "code",
26-
"execution_count": null,
26+
"execution_count": 1,
2727
"metadata": {},
2828
"outputs": [],
2929
"source": [
@@ -114,9 +114,22 @@
114114
},
115115
{
116116
"cell_type": "code",
117-
"execution_count": null,
118-
"metadata": {},
119-
"outputs": [],
117+
"execution_count": 2,
118+
"metadata": {},
119+
"outputs": [
120+
{
121+
"name": "stdout",
122+
"output_type": "stream",
123+
"text": [
124+
"Size of csv data (660, 13)\n",
125+
"Element in first row, first column: -0.766481911\n",
126+
"Element in first row, second column: 5.317314204\n",
127+
"Element in second row, first column: -2.597236044\n",
128+
"Element in last row, last column: 269.9840088\n",
129+
"Element in third row, last column: 299.9920044\n"
130+
]
131+
}
132+
],
120133
"source": [
121134
"# This creates a variable file_name that is a string. You could just put the string into loadtext\n",
122135
"# instead of creating a variable, but using a variable means you can ask what the filename is later - for example,\n",
@@ -712,7 +725,7 @@
712725
"name": "python",
713726
"nbconvert_exporter": "python",
714727
"pygments_lexer": "ipython3",
715-
"version": "3.9.6"
728+
"version": "3.12.7"
716729
}
717730
},
718731
"nbformat": 4,

0 commit comments

Comments
 (0)