Jeong Geol Kim преди 3 години
родител
ревизия
d7c68f2793
променени са 2 файла, в които са добавени 0 реда и са изтрити 725 реда
  1. 0
    44
      toysnippet/moduleimprot.ipynb
  2. 0
    681
      toysnippet/sandbox.ipynb

+ 0
- 44
toysnippet/moduleimprot.ipynb Целия файл

@@ -1,44 +0,0 @@
1
-{
2
- "cells": [
3
-  {
4
-   "cell_type": "code",
5
-   "execution_count": 1,
6
-   "metadata": {},
7
-   "outputs": [],
8
-   "source": [
9
-    "import sys\n",
10
-    "sys.path.append('..')\n",
11
-    "import modules.coordsi as csi"
12
-   ]
13
-  },
14
-  {
15
-   "cell_type": "code",
16
-   "execution_count": null,
17
-   "metadata": {},
18
-   "outputs": [],
19
-   "source": []
20
-  }
21
- ],
22
- "metadata": {
23
-  "kernelspec": {
24
-   "display_name": "Python 3",
25
-   "language": "python",
26
-   "name": "python3"
27
-  },
28
-  "language_info": {
29
-   "codemirror_mode": {
30
-    "name": "ipython",
31
-    "version": 3
32
-   },
33
-   "file_extension": ".py",
34
-   "mimetype": "text/x-python",
35
-   "name": "python",
36
-   "nbconvert_exporter": "python",
37
-   "pygments_lexer": "ipython3",
38
-   "version": "3.8.0"
39
-  },
40
-  "orig_nbformat": 4
41
- },
42
- "nbformat": 4,
43
- "nbformat_minor": 2
44
-}

+ 0
- 681
toysnippet/sandbox.ipynb Целия файл

@@ -1,681 +0,0 @@
1
-{
2
- "cells": [
3
-  {
4
-   "cell_type": "code",
5
-   "execution_count": 1,
6
-   "metadata": {},
7
-   "outputs": [],
8
-   "source": [
9
-    "import os, sys\n",
10
-    "import pandas as pd\n",
11
-    "import numpy as np\n",
12
-    "sys.path.append('../')\n",
13
-    "import modules.coordsi as csi\n",
14
-    "import math\n",
15
-    "import time"
16
-   ]
17
-  },
18
-  {
19
-   "attachments": {},
20
-   "cell_type": "markdown",
21
-   "metadata": {},
22
-   "source": [
23
-    "A brief summary of each original coordinate"
24
-   ]
25
-  },
26
-  {
27
-   "cell_type": "code",
28
-   "execution_count": 2,
29
-   "metadata": {},
30
-   "outputs": [
31
-    {
32
-     "name": "stdout",
33
-     "output_type": "stream",
34
-     "text": [
35
-      "Warning: ./List_Data_Call/21002290020230321/cam1.csv is not exist.\n",
36
-      "                                    approx_total_frame  x_min   x_max  y_min   \n",
37
-      "./List_Data_Call/21004038220221101            478800.0   -3.0  1900.0   -2.0  \\\n",
38
-      "./List_Data_Call/21001264420230215            219600.0   -4.0  1901.0   -6.0   \n",
39
-      "./List_Data_Call/21001555320230216            349200.0   -5.0  1884.0   -3.0   \n",
40
-      "./List_Data_Call/21004030420221004            666000.0   -4.0  1902.0   -3.0   \n",
41
-      "./List_Data_Call/21004008220221017            219600.0   -8.0  1883.0   -2.0   \n",
42
-      "\n",
43
-      "                                     y_max     z_min     z_max  \n",
44
-      "./List_Data_Call/21004038220221101  1051.0  0.923129  4.137998  \n",
45
-      "./List_Data_Call/21001264420230215  1055.0  0.953854  4.400389  \n",
46
-      "./List_Data_Call/21001555320230216  1057.0  0.840809  3.938679  \n",
47
-      "./List_Data_Call/21004030420221004  1057.0  0.933506  4.356071  \n",
48
-      "./List_Data_Call/21004008220221017  1058.0  0.897373  4.207281  \n"
49
-     ]
50
-    }
51
-   ],
52
-   "source": [
53
-    "# initialize root path\n",
54
-    "root = './List_Data_Call/'\n",
55
-    "\n",
56
-    "summary_1 = csi.summaryOriginCoord(root, camid=1)\n",
57
-    "print(summary_1.head())"
58
-   ]
59
-  },
60
-  {
61
-   "cell_type": "code",
62
-   "execution_count": 3,
63
-   "metadata": {},
64
-   "outputs": [
65
-    {
66
-     "name": "stdout",
67
-     "output_type": "stream",
68
-     "text": [
69
-      "./List_Data_Call/21004038220221101 64.0459258556366\n",
70
-      "./List_Data_Call/21001264420230215 34.23401594161987\n",
71
-      "./List_Data_Call/21001555320230216 55.52943301200867\n",
72
-      "./List_Data_Call/21004030420221004 106.67347645759583\n",
73
-      "./List_Data_Call/21004008220221017 31.72646999359131\n",
74
-      "./List_Data_Call/21004056620230120 19.501684188842773\n",
75
-      "./List_Data_Call/21001057620230126 53.51554536819458\n",
76
-      "./List_Data_Call/21003885420220721 76.24831080436707\n",
77
-      "./List_Data_Call/21004107920230313 97.09525084495544\n",
78
-      "./List_Data_Call/21003975920220723 36.387489318847656\n",
79
-      "./List_Data_Call/21004102020230228 31.510535717010498\n",
80
-      "./List_Data_Call/21004036420221013 63.18059492111206\n",
81
-      "./List_Data_Call/21003962420220712 36.284823179244995\n",
82
-      "./List_Data_Call/21004048220221029 50.87060260772705\n",
83
-      "./List_Data_Call/21003992420230119 49.36880159378052\n",
84
-      "./List_Data_Call/21001418920220921 35.04419279098511\n",
85
-      "./List_Data_Call/21004108620230225 94.45536732673645\n",
86
-      "./List_Data_Call/21004095420230303 7.877222776412964\n",
87
-      "./List_Data_Call/21003655120230207 22.74891757965088\n",
88
-      "./List_Data_Call/21003817020230107 24.885369300842285\n",
89
-      "./List_Data_Call/21003981020220923 36.27069091796875\n",
90
-      "./List_Data_Call/21004033920221007 86.56228399276733\n",
91
-      "./List_Data_Call/21004074720230104 37.52795934677124\n",
92
-      "./List_Data_Call/21004037520230324 30.00572395324707\n",
93
-      "./List_Data_Call/21004040420221103 90.27121639251709\n",
94
-      "./List_Data_Call/21004026620221007 69.01991891860962\n",
95
-      "./List_Data_Call/21001870620230315 39.85080003738403\n",
96
-      "./List_Data_Call/21004068020230102 7.841302871704102\n",
97
-      "./List_Data_Call/21004094420230206 100.37451100349426\n",
98
-      "./List_Data_Call/21004097420230304 84.17479515075684\n",
99
-      "./List_Data_Call/21004047820221028 89.44327425956726\n",
100
-      "./List_Data_Call/21004051720230228 9.743078708648682\n",
101
-      "./List_Data_Call/21004076520230204 76.26534867286682\n",
102
-      "./List_Data_Call/21002591020230218 88.18855333328247\n",
103
-      "./List_Data_Call/21004105820230311 59.186476945877075\n",
104
-      "./List_Data_Call/21004037520230317 54.6233925819397\n",
105
-      "./List_Data_Call/21003993520220917 95.81168413162231\n",
106
-      "./List_Data_Call/21003967920220714 36.98200988769531\n",
107
-      "./List_Data_Call/21004043620221025 25.73115038871765\n",
108
-      "./List_Data_Call/21004097520230208 93.56520891189575\n",
109
-      "./List_Data_Call/21004092020230127 89.9213137626648\n",
110
-      "./List_Data_Call/21004026220220928 81.38130640983582\n"
111
-     ]
112
-    },
113
-    {
114
-     "ename": "ValueError",
115
-     "evalue": "Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required.",
116
-     "output_type": "error",
117
-     "traceback": [
118
-      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
119
-      "\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)",
120
-      "Cell \u001b[0;32mIn[3], line 6\u001b[0m\n\u001b[1;32m      4\u001b[0m start_time \u001b[39m=\u001b[39m time\u001b[39m.\u001b[39mtime()\n\u001b[1;32m      5\u001b[0m df \u001b[39m=\u001b[39m csi\u001b[39m.\u001b[39mreadCam(os\u001b[39m.\u001b[39mpath\u001b[39m.\u001b[39mjoin(index,\u001b[39m'\u001b[39m\u001b[39mcam1.csv\u001b[39m\u001b[39m'\u001b[39m))\n\u001b[0;32m----> 6\u001b[0m df \u001b[39m=\u001b[39m csi\u001b[39m.\u001b[39;49mconvertToSI(df, \u001b[39m3.5\u001b[39;49m, \u001b[39m1.5\u001b[39;49m, \u001b[39m3.4\u001b[39;49m)\n\u001b[1;32m      7\u001b[0m df \u001b[39m=\u001b[39m csi\u001b[39m.\u001b[39mgetVelocity(df)\n\u001b[1;32m      8\u001b[0m df \u001b[39m=\u001b[39m csi\u001b[39m.\u001b[39mgetAcceleration(df)\n",
121
-      "File \u001b[0;32m~/workspace/equation20/coordsi.py:62\u001b[0m, in \u001b[0;36mconvertToSI\u001b[0;34m(origin, w, l, h)\u001b[0m\n\u001b[1;32m     60\u001b[0m df \u001b[39m=\u001b[39m origin\u001b[39m.\u001b[39mcopy()\n\u001b[1;32m     61\u001b[0m \u001b[39m#normailze dataframe[0] from -1 to 1\u001b[39;00m\n\u001b[0;32m---> 62\u001b[0m df[\u001b[39m'\u001b[39m\u001b[39mx\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m=\u001b[39m preprocessing\u001b[39m.\u001b[39;49mminmax_scale(df[\u001b[39m'\u001b[39;49m\u001b[39mx\u001b[39;49m\u001b[39m'\u001b[39;49m], feature_range\u001b[39m=\u001b[39;49m(\u001b[39m-\u001b[39;49m(w\u001b[39m/\u001b[39;49m\u001b[39m2\u001b[39;49m), (w\u001b[39m/\u001b[39;49m\u001b[39m2\u001b[39;49m)), axis\u001b[39m=\u001b[39;49m\u001b[39m0\u001b[39;49m, copy\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m)\n\u001b[1;32m     63\u001b[0m \u001b[39m#normailze dataframe[1] from -0.75 to 0.75\u001b[39;00m\n\u001b[1;32m     64\u001b[0m df[\u001b[39m'\u001b[39m\u001b[39my\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m=\u001b[39m preprocessing\u001b[39m.\u001b[39mminmax_scale(df[\u001b[39m'\u001b[39m\u001b[39my\u001b[39m\u001b[39m'\u001b[39m], feature_range\u001b[39m=\u001b[39m(\u001b[39m-\u001b[39m(l\u001b[39m/\u001b[39m\u001b[39m2\u001b[39m), (l\u001b[39m/\u001b[39m\u001b[39m2\u001b[39m)), axis\u001b[39m=\u001b[39m\u001b[39m0\u001b[39m, copy\u001b[39m=\u001b[39m\u001b[39mTrue\u001b[39;00m)\n",
122
-      "File \u001b[0;32m~/.local/lib/python3.8/site-packages/sklearn/preprocessing/_data.py:624\u001b[0m, in \u001b[0;36mminmax_scale\u001b[0;34m(X, feature_range, axis, copy)\u001b[0m\n\u001b[1;32m    550\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\"Transform features by scaling each feature to a given range.\u001b[39;00m\n\u001b[1;32m    551\u001b[0m \n\u001b[1;32m    552\u001b[0m \u001b[39mThis estimator scales and translates each feature individually such\u001b[39;00m\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    620\u001b[0m \u001b[39m<sphx_glr_auto_examples_preprocessing_plot_all_scaling.py>`.\u001b[39;00m\n\u001b[1;32m    621\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m    622\u001b[0m \u001b[39m# Unlike the scaler object, this function allows 1d input.\u001b[39;00m\n\u001b[1;32m    623\u001b[0m \u001b[39m# If copy is required, it will be done inside the scaler object.\u001b[39;00m\n\u001b[0;32m--> 624\u001b[0m X \u001b[39m=\u001b[39m check_array(\n\u001b[1;32m    625\u001b[0m     X, copy\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m, ensure_2d\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m, dtype\u001b[39m=\u001b[39;49mFLOAT_DTYPES, force_all_finite\u001b[39m=\u001b[39;49m\u001b[39m\"\u001b[39;49m\u001b[39mallow-nan\u001b[39;49m\u001b[39m\"\u001b[39;49m\n\u001b[1;32m    626\u001b[0m )\n\u001b[1;32m    627\u001b[0m original_ndim \u001b[39m=\u001b[39m X\u001b[39m.\u001b[39mndim\n\u001b[1;32m    629\u001b[0m \u001b[39mif\u001b[39;00m original_ndim \u001b[39m==\u001b[39m \u001b[39m1\u001b[39m:\n",
123
-      "File \u001b[0;32m~/.local/lib/python3.8/site-packages/sklearn/utils/validation.py:931\u001b[0m, in \u001b[0;36mcheck_array\u001b[0;34m(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator, input_name)\u001b[0m\n\u001b[1;32m    929\u001b[0m     n_samples \u001b[39m=\u001b[39m _num_samples(array)\n\u001b[1;32m    930\u001b[0m     \u001b[39mif\u001b[39;00m n_samples \u001b[39m<\u001b[39m ensure_min_samples:\n\u001b[0;32m--> 931\u001b[0m         \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\n\u001b[1;32m    932\u001b[0m             \u001b[39m\"\u001b[39m\u001b[39mFound array with \u001b[39m\u001b[39m%d\u001b[39;00m\u001b[39m sample(s) (shape=\u001b[39m\u001b[39m%s\u001b[39;00m\u001b[39m) while a\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m    933\u001b[0m             \u001b[39m\"\u001b[39m\u001b[39m minimum of \u001b[39m\u001b[39m%d\u001b[39;00m\u001b[39m is required\u001b[39m\u001b[39m%s\u001b[39;00m\u001b[39m.\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m    934\u001b[0m             \u001b[39m%\u001b[39m (n_samples, array\u001b[39m.\u001b[39mshape, ensure_min_samples, context)\n\u001b[1;32m    935\u001b[0m         )\n\u001b[1;32m    937\u001b[0m \u001b[39mif\u001b[39;00m ensure_min_features \u001b[39m>\u001b[39m \u001b[39m0\u001b[39m \u001b[39mand\u001b[39;00m array\u001b[39m.\u001b[39mndim \u001b[39m==\u001b[39m \u001b[39m2\u001b[39m:\n\u001b[1;32m    938\u001b[0m     n_features \u001b[39m=\u001b[39m array\u001b[39m.\u001b[39mshape[\u001b[39m1\u001b[39m]\n",
124
-      "\u001b[0;31mValueError\u001b[0m: Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required."
125
-     ]
126
-    }
127
-   ],
128
-   "source": [
129
-    "#make a loop for each index\n",
130
-    "for index, row in summary_1.iterrows():\n",
131
-    "    timestamp = []\n",
132
-    "    start_time = time.time()\n",
133
-    "    df = csi.readCam(os.path.join(index,'cam1.csv'))\n",
134
-    "    df = csi.convertToSI(df, 3.5, 1.5, 3.4)\n",
135
-    "    df = csi.getVelocity(df)\n",
136
-    "    df = csi.getAcceleration(df)\n",
137
-    "    df = csi.getFullTrace(df,row['approx_total_frame'] )\n",
138
-    "    df = csi.addValidDetection(df, 25.0)\n",
139
-    "    df.to_csv(os.path.join('./handletrace/', index[17:]+'.csv'), index=False)\n",
140
-    "    #save spend time and index of summary_1 in timestamp list    \n",
141
-    "    timestamp.append([index, time.time() - start_time])\n",
142
-    "#save timestamp list to csv file\n",
143
-    "pd.DataFrame(timestamp, columns=['index', 'time']).to_csv('./handletrace/timestamp.csv', index=False)\n",
144
-    "\n"
145
-   ]
146
-  },
147
-  {
148
-   "attachments": {},
149
-   "cell_type": "markdown",
150
-   "metadata": {},
151
-   "source": [
152
-    "import a origin coord and convert"
153
-   ]
154
-  },
155
-  {
156
-   "cell_type": "code",
157
-   "execution_count": 3,
158
-   "metadata": {},
159
-   "outputs": [],
160
-   "source": [
161
-    "arr_1 = csi.readCam(os.path.join(summary_1.index[0],'cam1.csv'))\n",
162
-    "si_1 = csi.convertToSI(arr_1, 3.5, 1.5, 3.4)\n",
163
-    "#cartesian coordinate system\n",
164
-    "#구면 좌표계로 변경도 해보자...나중에...\n",
165
-    "#meter/(1/30)s\n",
166
-    "si_1['positionvectorvalue'] = (si_1['x']**2 + si_1['y']**2 + si_1['z']**2)"
167
-   ]
168
-  },
169
-  {
170
-   "cell_type": "code",
171
-   "execution_count": 4,
172
-   "metadata": {},
173
-   "outputs": [],
174
-   "source": [
175
-    "cal_buffer_1, cal_buffer_2 = si_1['positionvectorvalue'].copy(),  si_1['positionvectorvalue'].copy()\n",
176
-    "#print(cal_buffer_1,'\\n',cal_buffer_2)\n",
177
-    "cal_buffer_1, cal_buffer_2= cal_buffer_1.to_frame(), cal_buffer_2.to_frame()\n",
178
-    "cal_buffer_1 = list(cal_buffer_1.loc[:, 'positionvectorvalue'])\n",
179
-    "cal_buffer_2 = list(cal_buffer_2.loc[:, 'positionvectorvalue'])\n",
180
-    "cal_buffer_3 = [0.0]\n",
181
-    "for v in range(0, len(cal_buffer_2)-1):\n",
182
-    "    cal_buffer_3.append(cal_buffer_2[v])\n",
183
-    "buffer_a = np.array(cal_buffer_1)\n",
184
-    "buffer_b = np.array(cal_buffer_3)"
185
-   ]
186
-  },
187
-  {
188
-   "cell_type": "code",
189
-   "execution_count": 5,
190
-   "metadata": {},
191
-   "outputs": [],
192
-   "source": [
193
-    "velocity = (buffer_a - buffer_b)\n",
194
-    "for x in range(0, len(velocity)):\n",
195
-    "    velocity[x] = math.sqrt(abs(velocity[x]))\n",
196
-    "velocity[0]=0.0"
197
-   ]
198
-  },
199
-  {
200
-   "cell_type": "code",
201
-   "execution_count": 6,
202
-   "metadata": {},
203
-   "outputs": [],
204
-   "source": [
205
-    "#merge each list as Series\n",
206
-    "si_1['velocity'] = velocity\n",
207
-    "#print(si_1)"
208
-   ]
209
-  },
210
-  {
211
-   "cell_type": "code",
212
-   "execution_count": 7,
213
-   "metadata": {},
214
-   "outputs": [],
215
-   "source": [
216
-    "cal_buffer_4, cal_buffer_5 = si_1['velocity'].copy(),  si_1['velocity'].copy()\n",
217
-    "#print(cal_buffer_1,'\\n',cal_buffer_2)\n",
218
-    "cal_buffer_4, cal_buffer_5= cal_buffer_4.to_frame(), cal_buffer_5.to_frame()\n",
219
-    "cal_buffer_4 = list(cal_buffer_4.loc[:, 'velocity'])\n",
220
-    "cal_buffer_5 = list(cal_buffer_5.loc[:, 'velocity'])\n",
221
-    "cal_buffer_6 = [0.0]\n",
222
-    "for v in range(0, len(cal_buffer_5)-1):\n",
223
-    "    cal_buffer_6.append(cal_buffer_5[v])\n",
224
-    "buffer_c = np.array(cal_buffer_4)\n",
225
-    "buffer_d = np.array(cal_buffer_6)"
226
-   ]
227
-  },
228
-  {
229
-   "cell_type": "code",
230
-   "execution_count": 8,
231
-   "metadata": {},
232
-   "outputs": [],
233
-   "source": [
234
-    "acceleration = buffer_c - buffer_d\n",
235
-    "acceleration[1] = 0.0\n",
236
-    "#print(acceleration)"
237
-   ]
238
-  },
239
-  {
240
-   "cell_type": "code",
241
-   "execution_count": 9,
242
-   "metadata": {},
243
-   "outputs": [],
244
-   "source": [
245
-    "si_1['acceleration'] = acceleration\n",
246
-    "#print(si_1)"
247
-   ]
248
-  },
249
-  {
250
-   "attachments": {},
251
-   "cell_type": "markdown",
252
-   "metadata": {},
253
-   "source": [
254
-    "Calculate Velocity of all detected objects"
255
-   ]
256
-  },
257
-  {
258
-   "attachments": {},
259
-   "cell_type": "markdown",
260
-   "metadata": {},
261
-   "source": [
262
-    "\n",
263
-    "TODO: approx_total_frame 개수 만큼의 빈 컬럼 생성 (나중에 전체 데이터프레임은 20등분으로 잘릴 예정) -> done\n",
264
-    "실제 값이 존재하는 프레임을 찾고, 그 프레임을 인덱스에 맞추어 x,y,z 집어넣기\n",
265
-    "존재한다면 (x^2 + y^2 + z^2)^(1/3) 을 계산하여 새 컬럼에 저장\n",
266
-    "비 등속 보간 작업을 해야 하는데, 어떤 방식으로 할지 결정하기(piecewise_polynomial?)"
267
-   ]
268
-  },
269
-  {
270
-   "cell_type": "code",
271
-   "execution_count": 11,
272
-   "metadata": {},
273
-   "outputs": [
274
-    {
275
-     "data": {
276
-      "text/html": [
277
-       "<div>\n",
278
-       "<style scoped>\n",
279
-       "    .dataframe tbody tr th:only-of-type {\n",
280
-       "        vertical-align: middle;\n",
281
-       "    }\n",
282
-       "\n",
283
-       "    .dataframe tbody tr th {\n",
284
-       "        vertical-align: top;\n",
285
-       "    }\n",
286
-       "\n",
287
-       "    .dataframe thead th {\n",
288
-       "        text-align: right;\n",
289
-       "    }\n",
290
-       "</style>\n",
291
-       "<table border=\"1\" class=\"dataframe\">\n",
292
-       "  <thead>\n",
293
-       "    <tr style=\"text-align: right;\">\n",
294
-       "      <th></th>\n",
295
-       "      <th>x</th>\n",
296
-       "      <th>y</th>\n",
297
-       "      <th>z</th>\n",
298
-       "      <th>frame</th>\n",
299
-       "      <th>positionvectorvalue</th>\n",
300
-       "      <th>velocity</th>\n",
301
-       "      <th>acceleration</th>\n",
302
-       "    </tr>\n",
303
-       "  </thead>\n",
304
-       "  <tbody>\n",
305
-       "    <tr>\n",
306
-       "      <th>count</th>\n",
307
-       "      <td>62495.000000</td>\n",
308
-       "      <td>62495.000000</td>\n",
309
-       "      <td>62495.000000</td>\n",
310
-       "      <td>62495.000000</td>\n",
311
-       "      <td>62495.000000</td>\n",
312
-       "      <td>62495.000000</td>\n",
313
-       "      <td>62495.000000</td>\n",
314
-       "    </tr>\n",
315
-       "    <tr>\n",
316
-       "      <th>mean</th>\n",
317
-       "      <td>-0.202211</td>\n",
318
-       "      <td>-0.207365</td>\n",
319
-       "      <td>1.601385</td>\n",
320
-       "      <td>42805.432355</td>\n",
321
-       "      <td>2.733538</td>\n",
322
-       "      <td>0.138262</td>\n",
323
-       "      <td>0.000002</td>\n",
324
-       "    </tr>\n",
325
-       "    <tr>\n",
326
-       "      <th>std</th>\n",
327
-       "      <td>0.162759</td>\n",
328
-       "      <td>0.238811</td>\n",
329
-       "      <td>0.041177</td>\n",
330
-       "      <td>27211.098449</td>\n",
331
-       "      <td>0.162993</td>\n",
332
-       "      <td>0.120752</td>\n",
333
-       "      <td>0.124054</td>\n",
334
-       "    </tr>\n",
335
-       "    <tr>\n",
336
-       "      <th>min</th>\n",
337
-       "      <td>-0.750000</td>\n",
338
-       "      <td>-1.750000</td>\n",
339
-       "      <td>0.930000</td>\n",
340
-       "      <td>1.000000</td>\n",
341
-       "      <td>1.109630</td>\n",
342
-       "      <td>0.000000</td>\n",
343
-       "      <td>-1.650274</td>\n",
344
-       "    </tr>\n",
345
-       "    <tr>\n",
346
-       "      <th>25%</th>\n",
347
-       "      <td>-0.328348</td>\n",
348
-       "      <td>-0.377956</td>\n",
349
-       "      <td>1.574043</td>\n",
350
-       "      <td>19851.500000</td>\n",
351
-       "      <td>2.637680</td>\n",
352
-       "      <td>0.067702</td>\n",
353
-       "      <td>-0.045567</td>\n",
354
-       "    </tr>\n",
355
-       "    <tr>\n",
356
-       "      <th>50%</th>\n",
357
-       "      <td>-0.183048</td>\n",
358
-       "      <td>-0.240016</td>\n",
359
-       "      <td>1.598190</td>\n",
360
-       "      <td>38725.000000</td>\n",
361
-       "      <td>2.706999</td>\n",
362
-       "      <td>0.111651</td>\n",
363
-       "      <td>0.000205</td>\n",
364
-       "    </tr>\n",
365
-       "    <tr>\n",
366
-       "      <th>75%</th>\n",
367
-       "      <td>-0.096154</td>\n",
368
-       "      <td>-0.032186</td>\n",
369
-       "      <td>1.625495</td>\n",
370
-       "      <td>69024.500000</td>\n",
371
-       "      <td>2.793686</td>\n",
372
-       "      <td>0.168573</td>\n",
373
-       "      <td>0.045744</td>\n",
374
-       "    </tr>\n",
375
-       "    <tr>\n",
376
-       "      <th>max</th>\n",
377
-       "      <td>0.750000</td>\n",
378
-       "      <td>1.750000</td>\n",
379
-       "      <td>1.800000</td>\n",
380
-       "      <td>233066.000000</td>\n",
381
-       "      <td>6.039652</td>\n",
382
-       "      <td>1.941675</td>\n",
383
-       "      <td>1.692079</td>\n",
384
-       "    </tr>\n",
385
-       "  </tbody>\n",
386
-       "</table>\n",
387
-       "</div>"
388
-      ],
389
-      "text/plain": [
390
-       "                  x             y             z          frame   \n",
391
-       "count  62495.000000  62495.000000  62495.000000   62495.000000  \\\n",
392
-       "mean      -0.202211     -0.207365      1.601385   42805.432355   \n",
393
-       "std        0.162759      0.238811      0.041177   27211.098449   \n",
394
-       "min       -0.750000     -1.750000      0.930000       1.000000   \n",
395
-       "25%       -0.328348     -0.377956      1.574043   19851.500000   \n",
396
-       "50%       -0.183048     -0.240016      1.598190   38725.000000   \n",
397
-       "75%       -0.096154     -0.032186      1.625495   69024.500000   \n",
398
-       "max        0.750000      1.750000      1.800000  233066.000000   \n",
399
-       "\n",
400
-       "       positionvectorvalue      velocity  acceleration  \n",
401
-       "count         62495.000000  62495.000000  62495.000000  \n",
402
-       "mean              2.733538      0.138262      0.000002  \n",
403
-       "std               0.162993      0.120752      0.124054  \n",
404
-       "min               1.109630      0.000000     -1.650274  \n",
405
-       "25%               2.637680      0.067702     -0.045567  \n",
406
-       "50%               2.706999      0.111651      0.000205  \n",
407
-       "75%               2.793686      0.168573      0.045744  \n",
408
-       "max               6.039652      1.941675      1.692079  "
409
-      ]
410
-     },
411
-     "execution_count": 11,
412
-     "metadata": {},
413
-     "output_type": "execute_result"
414
-    }
415
-   ],
416
-   "source": [
417
-    "si_1.describe()"
418
-   ]
419
-  },
420
-  {
421
-   "cell_type": "code",
422
-   "execution_count": 12,
423
-   "metadata": {},
424
-   "outputs": [
425
-    {
426
-     "name": "stdout",
427
-     "output_type": "stream",
428
-     "text": [
429
-      "          x    y    z  frame  positionvectorvalue  velocity  acceleration   \n",
430
-      "478795  0.0  0.0  0.0    0.0                  0.0       0.0           0.0  \\\n",
431
-      "478796  0.0  0.0  0.0    0.0                  0.0       0.0           0.0   \n",
432
-      "478797  0.0  0.0  0.0    0.0                  0.0       0.0           0.0   \n",
433
-      "478798  0.0  0.0  0.0    0.0                  0.0       0.0           0.0   \n",
434
-      "478799  0.0  0.0  0.0    0.0                  0.0       0.0           0.0   \n",
435
-      "\n",
436
-      "        isValid  \n",
437
-      "478795      0.0  \n",
438
-      "478796      0.0  \n",
439
-      "478797      0.0  \n",
440
-      "478798      0.0  \n",
441
-      "478799      0.0  \n"
442
-     ]
443
-    }
444
-   ],
445
-   "source": [
446
-    "# create dataframe with 6 columns and create 0 value rows as many as approx_total_frame value in summary_1\n",
447
-    "j = 0\n",
448
-    "handletrace = pd.DataFrame(columns=['x', 'y', 'z', 'frame', 'positionvectorvalue', 'velocity', 'acceleration', 'isValid'])\n",
449
-    "handletrace = pd.concat([handletrace, pd.DataFrame(np.zeros((int(summary_1['approx_total_frame'][j]),8)), columns=['x', 'y', 'z', 'frame', 'positionvectorvalue','velocity', 'acceleration', 'isValid'])], axis=0)\n",
450
-    "print(handletrace.tail())"
451
-   ]
452
-  },
453
-  {
454
-   "cell_type": "code",
455
-   "execution_count": null,
456
-   "metadata": {},
457
-   "outputs": [],
458
-   "source": [
459
-    "#print(int(si_1['frame'][2]))\n",
460
-    "#print(si_1.loc[2])"
461
-   ]
462
-  },
463
-  {
464
-   "cell_type": "code",
465
-   "execution_count": 13,
466
-   "metadata": {},
467
-   "outputs": [],
468
-   "source": [
469
-    "# frame의 값에 해당하는 것으로 변경\n",
470
-    "for x in range(0, len(si_1)):\n",
471
-    "    handletrace.loc[int(si_1['frame'][x])] = si_1.loc[x]\n",
472
-    "handletrace['isValid'] = handletrace['isValid'].fillna(0)"
473
-   ]
474
-  },
475
-  {
476
-   "cell_type": "code",
477
-   "execution_count": 14,
478
-   "metadata": {},
479
-   "outputs": [
480
-    {
481
-     "name": "stdout",
482
-     "output_type": "stream",
483
-     "text": [
484
-      "               x         y         z  frame  positionvectorvalue  velocity   \n",
485
-      "0       0.000000  0.000000  0.000000    0.0             0.000000  0.000000  \\\n",
486
-      "1      -0.400997 -0.319101  1.632182    1.0             2.926644  0.000000   \n",
487
-      "2      -0.410969 -0.333815  1.629004    2.0             2.933981  0.085661   \n",
488
-      "3      -0.412393 -0.352207  1.634730    3.0             2.966459  0.180214   \n",
489
-      "4      -0.413818 -0.357725  1.638935    4.0             2.985322  0.137342   \n",
490
-      "...          ...       ...       ...    ...                  ...       ...   \n",
491
-      "478795  0.000000  0.000000  0.000000    0.0             0.000000  0.000000   \n",
492
-      "478796  0.000000  0.000000  0.000000    0.0             0.000000  0.000000   \n",
493
-      "478797  0.000000  0.000000  0.000000    0.0             0.000000  0.000000   \n",
494
-      "478798  0.000000  0.000000  0.000000    0.0             0.000000  0.000000   \n",
495
-      "478799  0.000000  0.000000  0.000000    0.0             0.000000  0.000000   \n",
496
-      "\n",
497
-      "        acceleration  isValid  \n",
498
-      "0           0.000000      0.0  \n",
499
-      "1           0.000000      0.0  \n",
500
-      "2           0.000000      0.0  \n",
501
-      "3           0.094553      0.0  \n",
502
-      "4          -0.042873      0.0  \n",
503
-      "...              ...      ...  \n",
504
-      "478795      0.000000      0.0  \n",
505
-      "478796      0.000000      0.0  \n",
506
-      "478797      0.000000      0.0  \n",
507
-      "478798      0.000000      0.0  \n",
508
-      "478799      0.000000      0.0  \n",
509
-      "\n",
510
-      "[478800 rows x 8 columns]\n"
511
-     ]
512
-    }
513
-   ],
514
-   "source": [
515
-    "print(handletrace)"
516
-   ]
517
-  },
518
-  {
519
-   "cell_type": "code",
520
-   "execution_count": null,
521
-   "metadata": {},
522
-   "outputs": [],
523
-   "source": [
524
-    "'''import plotly.graph_objects as go\n",
525
-    "\n",
526
-    "#Create Figure\n",
527
-    "fig = go.Figure()\n",
528
-    "fig.add_trace(go.Scatter( x=list(handletrace.index), y=list(handletrace['velocity'] * 30)))\n",
529
-    "\n",
530
-    "#Set Title\n",
531
-    "fig.update_layout(title_text='Velocity per second by frame')\n",
532
-    "\n",
533
-    "#Add range slider\n",
534
-    "fig.update_layout(\n",
535
-    "    xaxis=dict(\n",
536
-    "        rangeslider=dict(\n",
537
-    "            visible=True\n",
538
-    "        )\n",
539
-    "    )\n",
540
-    ")'''"
541
-   ]
542
-  },
543
-  {
544
-   "cell_type": "code",
545
-   "execution_count": null,
546
-   "metadata": {},
547
-   "outputs": [],
548
-   "source": [
549
-    "'''import plotly.graph_objects as go\n",
550
-    "\n",
551
-    "#Create Figure\n",
552
-    "fig = go.Figure()\n",
553
-    "fig.add_trace(go.Scatter( x=list(handletrace.index), y=list(handletrace['acceleration']*900)))\n",
554
-    "\n",
555
-    "#Set Title\n",
556
-    "fig.update_layout(title_text='acceleration per second^2 by frame')\n",
557
-    "\n",
558
-    "#Add range slider\n",
559
-    "fig.update_layout(\n",
560
-    "    xaxis=dict(\n",
561
-    "        rangeslider=dict(\n",
562
-    "            visible=True\n",
563
-    "        )\n",
564
-    "    )\n",
565
-    ")'''"
566
-   ]
567
-  },
568
-  {
569
-   "cell_type": "code",
570
-   "execution_count": 15,
571
-   "metadata": {},
572
-   "outputs": [],
573
-   "source": [
574
-    "#comapre the value of handletrace['acceleration'] and if it is between -25 and 25, then set handletrace['isValid'] to 1\n",
575
-    "for x in range(0, len(handletrace)):\n",
576
-    "    if (-25/900) < handletrace['acceleration'][x] < (25/900):\n",
577
-    "        handletrace['isValid'][x] = 1\n",
578
-    "    else:\n",
579
-    "        handletrace['isValid'][x] = 0"
580
-   ]
581
-  },
582
-  {
583
-   "cell_type": "code",
584
-   "execution_count": 16,
585
-   "metadata": {},
586
-   "outputs": [
587
-    {
588
-     "name": "stdout",
589
-     "output_type": "stream",
590
-     "text": [
591
-      "[1. 0.]\n",
592
-      "isValid\n",
593
-      "1.0    437730\n",
594
-      "0.0     41070\n",
595
-      "Name: count, dtype: int64\n"
596
-     ]
597
-    }
598
-   ],
599
-   "source": [
600
-    "print(handletrace['isValid'].unique())\n",
601
-    "print(handletrace['isValid'].value_counts())"
602
-   ]
603
-  },
604
-  {
605
-   "cell_type": "code",
606
-   "execution_count": 17,
607
-   "metadata": {},
608
-   "outputs": [
609
-    {
610
-     "name": "stdout",
611
-     "output_type": "stream",
612
-     "text": [
613
-      "               x         y         z  frame  positionvectorvalue  velocity   \n",
614
-      "0       0.000000  0.000000  0.000000    0.0             0.000000  0.000000  \\\n",
615
-      "1      -0.400997 -0.319101  1.632182    1.0             2.926644  0.000000   \n",
616
-      "2      -0.410969 -0.333815  1.629004    2.0             2.933981  0.085661   \n",
617
-      "3      -0.412393 -0.352207  1.634730    3.0             2.966459  0.180214   \n",
618
-      "4      -0.413818 -0.357725  1.638935    4.0             2.985322  0.137342   \n",
619
-      "...          ...       ...       ...    ...                  ...       ...   \n",
620
-      "478795  0.000000  0.000000  0.000000    0.0             0.000000  0.000000   \n",
621
-      "478796  0.000000  0.000000  0.000000    0.0             0.000000  0.000000   \n",
622
-      "478797  0.000000  0.000000  0.000000    0.0             0.000000  0.000000   \n",
623
-      "478798  0.000000  0.000000  0.000000    0.0             0.000000  0.000000   \n",
624
-      "478799  0.000000  0.000000  0.000000    0.0             0.000000  0.000000   \n",
625
-      "\n",
626
-      "        acceleration  isValid  \n",
627
-      "0           0.000000      1.0  \n",
628
-      "1           0.000000      1.0  \n",
629
-      "2           0.000000      1.0  \n",
630
-      "3           0.094553      0.0  \n",
631
-      "4          -0.042873      0.0  \n",
632
-      "...              ...      ...  \n",
633
-      "478795      0.000000      1.0  \n",
634
-      "478796      0.000000      1.0  \n",
635
-      "478797      0.000000      1.0  \n",
636
-      "478798      0.000000      1.0  \n",
637
-      "478799      0.000000      1.0  \n",
638
-      "\n",
639
-      "[478800 rows x 8 columns]\n"
640
-     ]
641
-    }
642
-   ],
643
-   "source": [
644
-    "print(handletrace)"
645
-   ]
646
-  },
647
-  {
648
-   "cell_type": "code",
649
-   "execution_count": null,
650
-   "metadata": {},
651
-   "outputs": [],
652
-   "source": []
653
-  }
654
- ],
655
- "metadata": {
656
-  "kernelspec": {
657
-   "display_name": "Python 3",
658
-   "language": "python",
659
-   "name": "python3"
660
-  },
661
-  "language_info": {
662
-   "codemirror_mode": {
663
-    "name": "ipython",
664
-    "version": 3
665
-   },
666
-   "file_extension": ".py",
667
-   "mimetype": "text/x-python",
668
-   "name": "python",
669
-   "nbconvert_exporter": "python",
670
-   "pygments_lexer": "ipython3",
671
-   "version": "3.8.0"
672
-  },
673
-  "vscode": {
674
-   "interpreter": {
675
-    "hash": "df0893f56f349688326838aaeea0de204df53a132722cbd565e54b24a8fec5f6"
676
-   }
677
-  }
678
- },
679
- "nbformat": 4,
680
- "nbformat_minor": 2
681
-}

Loading…
Отказ
Запис