1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

Script now can add missed steps to median and 3d plots

This commit is contained in:
Dennis Potter 2018-10-25 02:44:54 +02:00
parent b0179df6d1
commit 42ad6e7c69

View file

@ -21,7 +21,7 @@
"# FOR NOTEBOOK USE #\n",
"# SET DIRECTORY HERE #\n",
"# #\n",
"rootdir = \"varying_sample_size\"\n",
"rootdir = \"3d_constant_samples\"\n",
"# #\n",
"#############################\n",
"\n",
@ -77,7 +77,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"import numpy as np\n",
@ -96,7 +98,7 @@
" output_dataset.append([])\n",
"\n",
" # Acquire node type from the directory\n",
" matchObj = re.match(r'(\\w*)_\\w\\w_', subdir, re.M|re.I)\n",
" matchObj = re.match(r'(\\w*)_[A-Z]', subdir, re.M|re.I)\n",
" \n",
" # Fill value to array\n",
" if matchObj:\n",
@ -345,24 +347,23 @@
"metadata": {},
"outputs": [],
"source": [
"if settings['median_plot']['enabled'] or settings['3d_plot']['enabled']:\n",
" medians = []\n",
" upper_limit = []\n",
" lower_limit = []\n",
"medians = []\n",
"upper_limit = []\n",
"lower_limit = []\n",
"\n",
" for i, subdir in enumerate(subdirs):\n",
" medians.append([])\n",
" upper_limit.append([])\n",
" lower_limit.append([])\n",
"for i, subdir in enumerate(subdirs):\n",
" medians.append([])\n",
" upper_limit.append([])\n",
" lower_limit.append([])\n",
"\n",
" for (j, csv_vec) in enumerate(output_dataset[i]): \n",
" medians[i].append(np.median(csv_vec.transpose()[2]) * 1e6)\n",
" for (j, csv_vec) in enumerate(output_dataset[i]): \n",
" medians[i].append(np.median(csv_vec.transpose()[2]) * 1e6)\n",
"\n",
" if settings['median_plot']['enabled']:\n",
" # np.sort(recv[i][j] - enq_send[i][j])[int(np.size(recv[i][j]]) / 2)] would be the approximately the median\n",
" # Calculate upper 10% and lower 10%\n",
" upper_limit[i].append(abs(medians[i][j] - 1e6 * np.sort(csv_vec.transpose()[2])[int(9 * np.size(csv_vec.transpose()[2]) / 10)]))\n",
" lower_limit[i].append(abs(medians[i][j] - 1e6 * np.sort(csv_vec.transpose()[2])[int(1 * np.size(csv_vec.transpose()[2]) / 10)]))"
" if settings['median_plot']['enabled']:\n",
" # np.sort(recv[i][j] - enq_send[i][j])[int(np.size(recv[i][j]]) / 2)] would be the approximately the median\n",
" # Calculate upper 10% and lower 10%\n",
" upper_limit[i].append(abs(medians[i][j] - 1e6 * np.sort(csv_vec.transpose()[2])[int(9 * np.size(csv_vec.transpose()[2]) / 10)]))\n",
" lower_limit[i].append(abs(medians[i][j] - 1e6 * np.sort(csv_vec.transpose()[2])[int(1 * np.size(csv_vec.transpose()[2]) / 10)]))"
]
},
{
@ -637,14 +638,32 @@
" marker='v', zorder = 2 + i, color=settings['median_plot']['colors'][i],\n",
" label=settings['median_plot']['labels'][i])\n",
"\n",
" ###################################\n",
" # PRINT MISSED STEPS ##############\n",
" ###################################\n",
" if settings['median_plot']['print_missed_steps']:\n",
" for l, median in enumerate(medians[i]):\n",
" \n",
" p = FancyBboxPatch((x_data[l] + 0.07, median + 0.08), 0.345, 0.26, boxstyle=\"round, pad=0.005\",\n",
" ec=\"#dbdbdb\", fc=\"white\", alpha=0.85)\n",
" ax_median.add_patch(p)\n",
" \n",
" ax_median.text(x_data[l] + 0.1, median + 0.15, \"{: >4.2f}%\".format(perc_miss_recv_arr[i][l]))\n",
"\n",
" \n",
" \n",
" ###################################\n",
" # SET AXIS OF MEDIAN PLOT #########\n",
" ###################################\n",
" ax_median.set_ylim([settings['median_plot']['ticks']['y'][0], settings['median_plot']['ticks']['y'][-1]])\n",
" ax_median.set_xticks(np.arange(0, len(settings['median_plot']['ticks']['x']), 1))\n",
" ax_median.set_xticklabels(settings['median_plot']['ticks']['x'])\n",
" ax_median.set_yticks(settings['median_plot']['ticks']['y'])\n",
" \n",
" if settings['median_plot']['log_scale']:\n",
" ax_median.set_yscale('log')\n",
" else:\n",
" ax_median.set_ylim([settings['median_plot']['ticks']['y'][0], settings['median_plot']['ticks']['y'][-1]])\n",
" ax_median.set_yticks(settings['median_plot']['ticks']['y'])\n",
" \n",
" ax_median.set_xlabel(settings['median_plot']['axis_labels']['x'], fontsize=11, family='monospace', labelpad=6)\n",
" ax_median.set_ylabel(settings['median_plot']['axis_labels']['y'], fontsize=11, family='monospace', labelpad=6)\n",
" ax_median.set_axisbelow(True)\n",
@ -705,7 +724,29 @@
" for k in range(0, len(settings['3d_plot']['ticks']['y'])):\n",
" for l in range(0, len(settings['3d_plot']['ticks']['x'])):\n",
" Z = np.append(Z, medians[i][k * len(settings['3d_plot']['ticks']['x']) + l])\n",
" \n",
" ###################################\n",
" # PRINT MISSED STEPS ##############\n",
" ###################################\n",
" \n",
" props = dict(boxstyle='round', facecolor='white', alpha=0.8)\n",
" \n",
" # if more than 5% of the samples were missed, print it to figure\n",
" for k in range(0, len(input_dataset[i])):\n",
" if perc_miss_send_arr[i][k] > 5:\n",
" x = k % (len(settings['3d_plot']['ticks']['x']))\n",
" y = np.floor(k / (len(settings['3d_plot']['ticks']['y'])))\n",
" z = Z[k]\n",
" \n",
" x_delta = 0.65\n",
" y_delta = 0.65\n",
" z_delta = 0.5 * (Z[k] - Z[k - len(settings['3d_plot']['ticks']['y'])])\n",
" ax_3d.text(x - x_delta, y - y_delta, z - z_delta, \"{: >4.2f}%\".format(perc_miss_send_arr[i][k]), \n",
" fontsize=11, family='monospace', color='red', bbox=props)\n",
"\n",
" \n",
" \n",
" \n",
" Z = np.split(Z, len(settings['3d_plot']['ticks']['y']))\n",
"\n",
" # Plot the surface.\n",
@ -754,22 +795,29 @@
"\n",
" # The markers are too big, so lets create smaller markers\n",
" ax_custom = figLegend.add_subplot(111)\n",
" ax_custom.plot(0,0, marker='v', color = 'green', label=\"$\\\\tilde{t}_{min}^{max}$: \"+str(np.min(Z))+ \" µs\", markersize=8, linestyle = 'None')\n",
" ax_custom.plot(0,0, marker='^', color = 'red', label=\"$\\\\tilde{t}_{lat}^{max}$: \"+str(np.max(Z))+ \" µs\", markersize=8, linestyle = 'None')\n",
" ax_custom.plot(0,0, marker='v', color = 'green', label=\"$\\\\max\\\\,\\\\tilde{t}_{lat}$: \"+str(np.min(Z))+ \" µs\", markersize=8, linestyle = 'None')\n",
" ax_custom.plot(0,0, marker='^', color = 'red', label=\"$\\\\max\\\\,\\\\tilde{t}_{lat}$: \"+str(np.max(Z))+ \" µs\", markersize=8, linestyle = 'None')\n",
" ax_custom.set_visible(False)\n",
"\n",
" \n",
" p = FancyBboxPatch((0.1, 0.1), 5, 1, boxstyle=\"round, pad=0.5\", ec=\"#dbdbdb\", fc=\"white\", alpha=0.85)\n",
" \n",
" import matplotlib.legend as mlegend\n",
" handles = []\n",
" handles.append(p)\n",
" text= '% of samples missed by signal generator'\n",
" leg2 = mlegend.Legend(ax_custom, handles, labels=[text], loc = 'upper left', ncol=1,\n",
" prop={'family':'monospace', 'size':'8'})\n",
"\n",
" pylab.figlegend(*ax_custom.get_legend_handles_labels(), loc = 'upper left',\n",
" prop={'family':'monospace', 'size':'8'}, ncol=settings['3d_plot']['legend_columns'])\n",
" handles, labels = ax_custom.get_legend_handles_labels()\n",
"\n",
" leg1= pylab.figlegend(handles, labels, loc = 'upper left', labelspacing=1.2,\n",
" prop={'family':'monospace', 'size':'8'}, ncol=settings['3d_plot']['legend_columns'])\n",
" leg1._legend_box._children.append(leg2._legend_box._children[1])\n",
" leg1._legend_box.align=\"left\"\n",
" \n",
" figLegend.savefig(\"{}/legend_median_3d_plot_{}.pdf\".format(rootdir, settings_array[i][0][2]), format='pdf')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {