DTN_notebook.ipynb 13.6 KB
Newer Older
Mitchell A Moore's avatar
Mitchell A Moore committed
1
2
3
4
{
 "cells": [
  {
   "cell_type": "code",
Mitchell A Moore's avatar
Mitchell A Moore committed
5
   "execution_count": null,
Mitchell A Moore's avatar
Mitchell A Moore committed
6
7
8
   "metadata": {},
   "outputs": [],
   "source": [
9
    "import globus_sdk\n",
10
    "import matplotlib.pyplot as plt\n",
11
    "from matplotlib import figure\n",
Mitchell A Moore's avatar
Mitchell A Moore committed
12
    "import numpy as np\n",
13
14
15
16
    "import csv\n",
    "import pandas as pd\n",
    "from datetime import datetime, timedelta\n",
    "from mpl_toolkits.mplot3d import Axes3D"
Mitchell A Moore's avatar
Mitchell A Moore committed
17
18
19
20
   ]
  },
  {
   "cell_type": "code",
Mitchell A Moore's avatar
Mitchell A Moore committed
21
   "execution_count": null,
Mitchell A Moore's avatar
Mitchell A Moore committed
22
   "metadata": {},
23
   "outputs": [],
Mitchell A Moore's avatar
Mitchell A Moore committed
24
   "source": [
Mitchell A Moore's avatar
Mitchell A Moore committed
25
    "#  Read File into DataFrame object\n",
26
    "\n",
27
    "data = pd.read_csv(\"test_big.csv\") # reads comma delimited file into a DataFrame object\n",
28
    "#data.head(85) # returns the first n rows of the DataFrame, n here is 16"
Mitchell A Moore's avatar
Mitchell A Moore committed
29
30
31
32
   ]
  },
  {
   "cell_type": "code",
Mitchell A Moore's avatar
Mitchell A Moore committed
33
   "execution_count": null,
Mitchell A Moore's avatar
Mitchell A Moore committed
34
   "metadata": {},
Mitchell A Moore's avatar
Mitchell A Moore committed
35
   "outputs": [],
36
   "source": [
Mitchell A Moore's avatar
Mitchell A Moore committed
37
    "#  Replace Source EP ID with Endpoint name\n",
38
    "\n",
39
    "data = data.replace(to_replace='924a32b0-6a2a-11e6-83a8-22000b97daec', value=\"Pamela Hill Data Share\")\n",
Mitchell A Moore's avatar
Mitchell A Moore committed
40
    "data = data.replace(to_replace='e261ffb8-6d04-11e5-ba46-22000b92c6ec', value=\"DME PerfTest - Argonne\")\n",
41
    "data = data.replace(to_replace='606579ae-5b03-11e9-bf32-0edbf3a4e7ee', value=\"cac_dtn_test\")\n",
Mitchell A Moore's avatar
Mitchell A Moore committed
42
43
    "data = data.replace(to_replace='9c8c88c2-ea4a-11e6-b9ba-22000b9a448b', value=\"Cheaha On-Campus\")\n",
    "data = data.replace(to_replace='7167cb38-9f78-11e6-b0dd-22000b92c261', value=\"Cheaha Off-Campus\")\n",
44
45
46
47
48
    "data.head(85) "
   ]
  },
  {
   "cell_type": "code",
Mitchell A Moore's avatar
Mitchell A Moore committed
49
   "execution_count": null,
50
   "metadata": {},
Mitchell A Moore's avatar
Mitchell A Moore committed
51
   "outputs": [],
Mitchell A Moore's avatar
Mitchell A Moore committed
52
   "source": [
Mitchell A Moore's avatar
Mitchell A Moore committed
53
    "# Convert String to datatime object and get total time elapsed\n",
54
    "data['Elapsed'] = pd.to_datetime(data['Elapsed'], format='%H:%M:%S.%f')\n",
Mitchell A Moore's avatar
Mitchell A Moore committed
55
56
57
58
    "total = 0.0\n",
    "for item in data['Elapsed']:\n",
    "    total += timedelta(hours=item.hour, minutes=item.minute, seconds=item.second).total_seconds()\n",
    "print(round(total/60/60, 2), \"Hours\")\n"
59
60
61
62
   ]
  },
  {
   "cell_type": "code",
Mitchell A Moore's avatar
Mitchell A Moore committed
63
   "execution_count": null,
64
   "metadata": {},
Mitchell A Moore's avatar
Mitchell A Moore committed
65
   "outputs": [],
Mitchell A Moore's avatar
Mitchell A Moore committed
66
67
68
69
70
71
72
73
74
75
76
   "source": [
    "#  Group data by dataset name\n",
    "ds01 = data[(data == 'ds01').any(axis=1)]\n",
    "ds04 = data[(data == 'ds04').any(axis=1)]\n",
    "ds06 = data[(data == 'ds06').any(axis=1)]\n",
    "ds08 = data[(data == 'ds08').any(axis=1)]\n",
    "ds10 = data[(data == 'ds10').any(axis=1)]\n",
    "ds12 = data[(data == 'ds12').any(axis=1)]\n",
    "ds14 = data[(data == 'ds14').any(axis=1)]\n",
    "ds16 = data[(data == 'ds16').any(axis=1)]\n",
    "\n",
Mitchell A Moore's avatar
Mitchell A Moore committed
77
78
79
80
81
82
83
84
    "#  Group data by endpoint\n",
    "cac = data[(data == 'cac_dtn_test').any(axis=1)]\n",
    "cheaha_off = data[(data == 'Cheaha Off-Campus').any(axis=1)]\n",
    "cheaha_on = data[(data == 'Cheaha On-Campus').any(axis=1)]\n",
    "pamela = data[(data == 'Pamela Hill Data Share').any(axis=1)]\n",
    "argonne = data[(data == 'DME PerfTest - Argonne').any(axis=1)]\n",
    "\n",
    "#  Examples\n",
Mitchell A Moore's avatar
Mitchell A Moore committed
85
    "# argonne.head(50)\n",
86
    "# ds10.head(15)"
Mitchell A Moore's avatar
Mitchell A Moore committed
87
88
89
90
   ]
  },
  {
   "cell_type": "code",
Mitchell A Moore's avatar
Mitchell A Moore committed
91
   "execution_count": null,
Mitchell A Moore's avatar
Mitchell A Moore committed
92
   "metadata": {},
Mitchell A Moore's avatar
Mitchell A Moore committed
93
   "outputs": [],
94
   "source": [
Mitchell A Moore's avatar
Mitchell A Moore committed
95
    "#  Builds bar graphs to represent transfer speeds for different datasets\n",
96
97
    "\n",
    "#plot\n",
98
    "# bg1 = data.plot.bar(x = 'Dataset', y = 'Speed', rot = 100,) # graph shows the speed for each ds\n",
Mitchell A Moore's avatar
Mitchell A Moore committed
99
    "\n"
100
101
102
103
   ]
  },
  {
   "cell_type": "code",
Mitchell A Moore's avatar
Mitchell A Moore committed
104
   "execution_count": null,
105
   "metadata": {},
Mitchell A Moore's avatar
Mitchell A Moore committed
106
   "outputs": [],
107
   "source": [
Mitchell A Moore's avatar
Mitchell A Moore committed
108
109
110
111
112
113
114
115
    "#  Builds bar graphs to represent data for different endpoints\n",
    "\n",
    "# time = (pd.to_datetime(data['End'], infer_datetime_format=True) - pd.to_datetime(data['Start']))\n",
    "# print(time)\n",
    "# bg2 = data.plot.bar(x = data[\"Dataset\"],\n",
    "#                     y = (pd.to_datetime(data['End'], \n",
    "#                     infer_datetime_format=True) - pd.to_datetime(data['Start'])),\n",
    "#                     rot=100)"
116
117
118
119
   ]
  },
  {
   "cell_type": "code",
Mitchell A Moore's avatar
Mitchell A Moore committed
120
   "execution_count": null,
121
   "metadata": {},
Mitchell A Moore's avatar
Mitchell A Moore committed
122
   "outputs": [],
123
   "source": [
Mitchell A Moore's avatar
Mitchell A Moore committed
124
    "#  Builds scatter plots to represent transfer speeds for different datasets\n",
125
    "\n",
126
127
128
129
130
    "# plt.scatter((data['Dataset']), data['Speed'])\n",
    "# plt.title('Dataset Speed')\n",
    "# plt.xlabel('Dataset')\n",
    "# plt.ylabel('Speed')\n",
    "# plt.show()"
131
132
   ]
  },
133
134
  {
   "cell_type": "code",
Mitchell A Moore's avatar
Mitchell A Moore committed
135
   "execution_count": null,
Mitchell A Moore's avatar
Mitchell A Moore committed
136
137
138
   "metadata": {
    "scrolled": true
   },
Mitchell A Moore's avatar
Mitchell A Moore committed
139
   "outputs": [],
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
   "source": [
    "#  Show how much the reading varied across endpoints\n",
    "\n",
    "fig, (ax1, ax2) = plt.subplots(1, 2)\n",
    "fig.set_figwidth(15)\n",
    "fig.suptitle('ds01 (100MB, 10,000 x 10KB, 1-dir)', fontsize=18)\n",
    "\n",
    "ax1.set_title('Effective Speed')\n",
    "ax1.set_ylabel('Frequency')\n",
    "ax1.set_xlabel('Speed (Mb/s)')\n",
    "ax2.set_title('Elapsed Time')\n",
    "ax2.set_ylabel('Frequency')\n",
    "ax2.set_xlabel('Time (hh:mm:ss)')\n",
    "\n",
    "ds01['Speed'].hist(grid=True, ax=ax1, color='gold', edgecolor='green') # histogram using pandas\n",
    "ds01['Elapsed'].hist(grid=True, ax=ax2, color='green', edgecolor='gold') # histogram using pandas\n",
    "\n",
    "\n",
    "fig, (ax1, ax2) = plt.subplots(1, 2)\n",
    "fig.set_figwidth(15)\n",
    "fig.suptitle('ds04 (10GB, 10,000 x 1MB files, 100-dirs)', fontsize=18)\n",
    "\n",
    "ax1.set_title('Effective Speed')\n",
    "ax1.set_ylabel('Frequency')\n",
    "ax1.set_xlabel('Speed (Mb/s)')\n",
    "ax2.set_title('Elapsed Time')\n",
    "ax2.set_ylabel('Frequency')\n",
    "ax2.set_xlabel('Time (hh:mm:ss)')\n",
    "\n",
    "ds04['Speed'].hist(grid=True, ax=ax1, color='gold', edgecolor='green') # histogram using pandas\n",
    "ds04['Elapsed'].hist(grid=True, ax=ax2, color='green', edgecolor='gold') # histogram using pandas\n",
    "\n",
    "\n",
    "fig, (ax1, ax2) = plt.subplots(1, 2)\n",
    "fig.set_figwidth(15)\n",
    "fig.suptitle('ds06 (100GB, 100,000 x 1MB, 1-dir)', fontsize=18)\n",
    "\n",
    "ax1.set_title('Effective Speed')\n",
    "ax1.set_ylabel('Frequency')\n",
    "ax1.set_xlabel('Speed (Mb/s)')\n",
    "ax2.set_title('Elapsed Time')\n",
    "ax2.set_ylabel('Frequency')\n",
    "ax2.set_xlabel('Time (hh:mm:ss)')\n",
    "\n",
    "ds06['Speed'].hist(grid=True, ax=ax1, color='gold', edgecolor='green') # histogram using pandas\n",
    "ds06['Elapsed'].hist(grid=True, ax=ax2, color='green', edgecolor='gold') # histogram using pandas\n",
    "\n",
    "\n",
    "fig, (ax1, ax2) = plt.subplots(1, 2)\n",
    "fig.set_figwidth(15)\n",
    "fig.suptitle('ds08 (50 x 10GB; 350 x 1GB; 1,000 x 100MB; 5,500 x 10MB; 23,176 x 1MB, 1-dir)', fontsize=18)\n",
    "\n",
    "ax1.set_title('Effective Speed')\n",
    "ax1.set_ylabel('Frequency')\n",
    "ax1.set_xlabel('Speed (Mb/s)')\n",
    "ax2.set_title('Elapsed Time')\n",
    "ax2.set_ylabel('Frequency')\n",
    "ax2.set_xlabel('Time (hh:mm:ss)')\n",
    "\n",
    "ds08['Speed'].hist(grid=True, ax=ax1, color='gold', edgecolor='green') # histogram using pandas\n",
    "ds08['Elapsed'].hist(grid=True, ax=ax2, color='green', edgecolor='gold') # histogram using pandas\n",
    "\n",
    "\n",
    "fig, (ax1, ax2) = plt.subplots(1, 2)\n",
    "fig.set_figwidth(15)\n",
    "fig.suptitle('ds10 (1TB, 100 x 10GB, 1-dir)', fontsize=18)\n",
    "\n",
    "ax1.set_title('Effective Speed')\n",
    "ax1.set_ylabel('Frequency')\n",
    "ax1.set_xlabel('Speed (Mb/s)')\n",
    "ax2.set_title('Elapsed Time')\n",
    "ax2.set_ylabel('Frequency')\n",
    "ax2.set_xlabel('Time (hh:mm:ss)')\n",
    "\n",
    "ds10['Speed'].hist(grid=True, ax=ax1, color='gold', edgecolor='green') # histogram using pandas\n",
    "ds10['Elapsed'].hist(grid=True, ax=ax2, color='green', edgecolor='gold') # histogram using pandas\n",
    "\n",
    "\n",
    "fig, (ax1, ax2) = plt.subplots(1, 2)\n",
    "fig.set_figwidth(15)\n",
    "fig.suptitle('ds12 (100GB, 1 x 100GB, 1-dir)', fontsize=18)\n",
    "\n",
    "ax1.set_title('Effective Speed')\n",
    "ax1.set_ylabel('Frequency')\n",
    "ax1.set_xlabel('Speed (Mb/s)')\n",
    "ax2.set_title('Elapsed Time')\n",
    "ax2.set_ylabel('Frequency')\n",
    "ax2.set_xlabel('Time (hh:mm:ss)')\n",
    "\n",
    "ds12['Speed'].hist(grid=True, ax=ax1, color='gold', edgecolor='green') # histogram using pandas\n",
    "ds12['Elapsed'].hist(grid=True, ax=ax2, color='green', edgecolor='gold') # histogram using pandas\n",
    "\n",
    "\n",
    "fig, (ax1, ax2) = plt.subplots(1, 2)\n",
    "fig.set_figwidth(15)\n",
    "fig.suptitle('ds16 (1TB, 4 x 250GB, 1-dir)', fontsize=18)\n",
    "\n",
    "ax1.set_title('Effective Speed')\n",
    "ax1.set_ylabel('Frequency')\n",
    "ax1.set_xlabel('Speed (Mb/s)')\n",
    "ax2.set_title('Elapsed Time')\n",
    "ax2.set_ylabel('Frequency')\n",
    "ax2.set_xlabel('Time (hh:mm:ss)')\n",
    "\n",
    "ds16['Speed'].hist(grid=True, ax=ax1, color='gold', edgecolor='green') # histogram using pandas\n",
    "ds16['Elapsed'].hist(grid=True, ax=ax2, color='green', edgecolor='gold') # histogram using pandas"
   ]
  },
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "N = 1\n",
    "menMeans = (20)\n",
    "womenMeans = (25)\n",
    "menStd = (2)\n",
    "womenStd = (3)\n",
    "ind = np.arange(N)    # the x locations for the groups\n",
    "width = 0.35       # the width of the bars: can also be len(x) sequence\n",
    "\n",
    "p1 = plt.bar(ind, menMeans, width, yerr=menStd)\n",
    "p2 = plt.bar(ind, womenMeans, width,\n",
    "             bottom=menMeans, yerr=womenStd)\n",
    "\n",
    "plt.ylabel('Scores')\n",
    "plt.title('Scores by group and gender')\n",
    "plt.xticks(ind, ('ds01',))\n",
    "plt.legend((p1[0], p2[0]), ('Men', 'Women'))\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "labels = ['G1', 'G2', 'G3', 'G4', 'G5']\n",
    "men_means = [20, 34, 30, 35, 27]\n",
    "men_stack = [1,2,3,4,5]\n",
    "women_stack = [5,4,3,2,1]\n",
    "women_means = [25, 32, 34, 20, 25]\n",
    "\n",
    "x = np.arange(len(labels))  # the label locations\n",
    "width = 0.35  # the width of the bars\n",
    "\n",
    "fig, ax = plt.subplots()\n",
    "rects1 = ax.bar(x - width/2, men_means, width, label='Men')\n",
    "stack1 = ax.bar(x - width/2, men_stack, width, bottom=men_means, label='M+')\n",
    "\n",
    "\n",
    "rects2 = ax.bar(x + width/2, women_means, width, label='Women')\n",
    "stack2 = ax.bar(x + width/2, women_stack, width, bottom=women_means, label='W+')\n",
    "\n",
    "# Add some text for labels, title and custom x-axis tick labels, etc.\n",
    "ax.set_ylabel('Scores')\n",
    "ax.set_title('Scores by group and gender')\n",
    "ax.set_xticks(x)\n",
    "ax.set_xticklabels(labels)\n",
    "ax.legend()\n",
    "\n",
    "\n",
    "def autolabel(rects):\n",
    "    \"\"\"Attach a text label above each bar in *rects*, displaying its height.\"\"\"\n",
    "    for rect in rects:\n",
    "        height = rect.get_height()\n",
    "        ax.annotate('{}'.format(height),\n",
    "                    xy=(rect.get_x() + rect.get_width() / 2, height),\n",
    "                    xytext=(0, 3),  # 3 points vertical offset\n",
    "                    textcoords=\"offset points\",\n",
    "                    ha='center', va='bottom')\n",
    "\n",
    "\n",
    "# autolabel(rects1)\n",
    "# autolabel(rects2)\n",
    "\n",
    "fig.tight_layout()\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "cac_ds01 = cac[(cac == 'ds01').any(axis=1)]['Speed']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(cac_ds01)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# First create some toy data:\n",
    "x = np.linspace(0, 2*np.pi, 400)\n",
    "y = np.sin(x**2)\n",
    "\n",
    "# Create just a figure and only one subplot\n",
    "fig, ax = plt.subplots()\n",
    "ax.plot(x, y)\n",
    "ax.set_title('Simple plot')\n",
    "\n",
    "# Create two subplots and unpack the output array immediately\n",
    "f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)\n",
    "ax1.plot(x, y)\n",
    "ax1.set_title('Sharing Y axis')\n",
    "ax2.scatter(x, y)\n",
    "\n",
    "# Create four polar axes and access them through the returned array\n",
    "fig, axs = plt.subplots(2, 2, subplot_kw=dict(polar=True))\n",
    "axs[0, 0].plot(x, y)\n",
    "axs[1, 1].scatter(x, y)\n",
    "\n",
    "# Share a X axis with each column of subplots\n",
    "plt.subplots(2, 2, sharex='col')\n",
    "\n",
    "# Share a Y axis with each row of subplots\n",
    "plt.subplots(2, 2, sharey='row')\n",
    "\n",
    "# Share both X and Y axes with all subplots\n",
    "plt.subplots(2, 2, sharex='all', sharey='all')\n",
    "\n",
    "# Note that this is the same as\n",
    "plt.subplots(2, 2, sharex=True, sharey=True)\n",
    "\n",
    "# Create figure number 10 with a single subplot\n",
    "# and clears it if it already exists.\n",
    "fig, ax = plt.subplots(num=10, clear=True)"
   ]
  },
387
388
  {
   "cell_type": "code",
Mitchell A Moore's avatar
Mitchell A Moore committed
389
   "execution_count": null,
390
   "metadata": {},
Mitchell A Moore's avatar
Mitchell A Moore committed
391
   "outputs": [],
Mitchell A Moore's avatar
Mitchell A Moore committed
392
   "source": []
Mitchell A Moore's avatar
Mitchell A Moore committed
393
394
395
396
  }
 ],
 "metadata": {
  "kernelspec": {
Mitchell A Moore's avatar
Mitchell A Moore committed
397
   "display_name": "Python [conda env:.conda-env]",
Mitchell A Moore's avatar
Mitchell A Moore committed
398
   "language": "python",
Mitchell A Moore's avatar
Mitchell A Moore committed
399
   "name": "conda-env-.conda-env-py"
Mitchell A Moore's avatar
Mitchell A Moore committed
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}