Skip to content

Commit

Permalink
updated post_process file so to move title string into figure frame, …
Browse files Browse the repository at this point in the history
…changed line style #24 [ci skip]
  • Loading branch information
JayHuLBL committed Oct 26, 2017
1 parent 7b68ed4 commit 9412e37
Showing 1 changed file with 66 additions and 52 deletions.
118 changes: 66 additions & 52 deletions examples/case_study_1/post_process.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 52,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -50,7 +50,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 53,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -99,7 +99,7 @@
"\n",
"def set_cases_and_initiate_plot():\n",
" from matplotlib.gridspec import GridSpec\n",
" cases = ['Base case', 'Guideline 36']\n",
" cases = ['Base\\ case', 'Guideline\\ 36']\n",
" seasons = ['Winter', 'Spring', 'Summer']\n",
" num_cases = len(cases)\n",
" num_seasons = len(seasons)\n",
Expand All @@ -122,32 +122,45 @@
" return cases, seasons, num_cases, num_seasons, fig, ax\n",
"\n",
"def set_up_labels(i, ax, cases, seasons, num_cases, num_seasons, x_axis_label, y_axis_label):\n",
" # Hide xtick labels and ticks on the upper case subplot (each basecase)\n",
" if i % 2 == 0:\n",
" hide_tick_labels(ax)\n",
"\n",
" # Print x axis title only below the lowest subplot\n",
" if i == num_cases*num_seasons - 1:\n",
" ax.set_xlabel(x_axis_label)\n",
" ax.set_ylabel(y_axis_label)\n",
" #ax.xaxis.set_ticks(np.arange(min(t)+0, 365, 1))\n",
" left, width = .01, .97\n",
" bottom, height = .01, .88\n",
" right = left + width\n",
" top = bottom + height\n",
" # Hide xtick labels and ticks on the upper case subplot (each basecase)\n",
" if i % 2 == 0:\n",
" hide_tick_labels(ax)\n",
"\n",
" # Print x axis title only below the lowest subplot\n",
" if i == num_cases*num_seasons - 1:\n",
" ax.set_xlabel(x_axis_label)\n",
" ax.set_ylabel(y_axis_label)\n",
" #ax.xaxis.set_ticks(np.arange(min(t)+0, 365, 1))\n",
" \n",
" # Annotate case\n",
" if i % 2 == 0:\n",
" title_str = r\"$\\bf{\" + seasons[i/2] + \"}$\" + ' (upper: ' + r\"$\\it{\" + cases[i % 2] + \"}$\" + ', lower: ' + r\"$\\it{\" + cases[(i-1) % 2] + \"}$\" + ')'\n",
" ax.set_title(title_str, # mg assign appropriate season/case\n",
" verticalalignment = 'top',\n",
" horizontalalignment = 'center', \n",
" fontsize = 6, color = 'k')\n",
" # Annotate case\n",
" title_str = r\"$\\it{\" + cases[i % 2] + \"}$\"\n",
" ax.text(left, top,\n",
" title_str, # mg assign appropriate season/case\n",
" verticalalignment = 'center',\n",
" horizontalalignment = 'left', \n",
" transform=ax.transAxes,\n",
" fontsize = 6, color = 'k')\n",
" \n",
" # Annotate case\n",
" # if i % 2 == 0:\n",
" # title_str = r\"$\\bf{\" + seasons[i/2] + \"}$\" + ' (upper: ' + r\"$\\it{\" + cases[i % 2] + \"}$\" + ', lower: ' + r\"$\\it{\" + cases[(i-1) % 2] + \"}$\" + ')'\n",
" # ax.set_title(title_str, # mg assign appropriate season/case\n",
" # verticalalignment = 'top',\n",
" # horizontalalignment = 'center', \n",
" # fontsize = 6, color = 'k')\n",
" \n",
" # Print legend only at the lower plot (g36 case)\n",
" if i % 2 == 1:\n",
" ax.legend(loc='center right', ncol=1)\n",
" configure_axes(ax)\n",
" # Print legend only at the lower plot (g36 case)\n",
" if i % 2 == 1:\n",
" ax.legend(loc='center right', ncol=1)\n",
" configure_axes(ax)\n",
" \n",
" #plt.tight_layout(h_pad=0)\n",
" plt.tight_layout()\n",
" #plt.subplots_adjust(hspace = .2)\n",
" #plt.tight_layout(h_pad=0)\n",
" plt.tight_layout()\n",
" #plt.subplots_adjust(hspace = .2)\n",
" \n",
"def tem_conv_CtoF(T_in_degC):\n",
" '''Converts temperature provided in degC to degF\n",
Expand Down Expand Up @@ -183,7 +196,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 54,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -257,7 +270,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 75,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -339,7 +352,7 @@
},
{
"cell_type": "code",
"execution_count": 44,
"execution_count": 56,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -389,9 +402,9 @@
"\n",
" ax[i].plot(t, TOut-273.15, 'k', label='$T_{out}$', linewidth=0.5)\n",
" ax[i].plot(t, TRoo_N_S[0]-273.15, 'b', label='$T_{nor}$', linewidth=0.5)\n",
" ax[i].plot(tWith, TRoo_N_S[1]-273.15, 'b', label='$T_{norWdivIHG}$', linewidth=0.5, linestyle='--')\n",
" ax[i].plot(tWith, TRoo_N_S[1]-273.15, 'b', label='$T_{nor\\_with\\_divIHG}$', linewidth=0.5, linestyle='--')\n",
" ax[i].plot(t, TRoo_N_S[2]-273.15, 'r', label='$T_{sou}$', linewidth=0.5)\n",
" ax[i].plot(tWith, TRoo_N_S[3]-273.15, 'r', label='$T_{souWdivIHG}$', linewidth=0.5, linestyle='--')\n",
" ax[i].plot(tWith, TRoo_N_S[3]-273.15, 'r', label='$T_{sou\\_with\\_divIHG}$', linewidth=0.5, linestyle='--')\n",
"\n",
" ax[i].patch.set_facecolor('mistyrose') \n",
" ax[i].fill_between(t, TSetHea-273.15, y2=TSetCoo-273.15, color='white')\n",
Expand Down Expand Up @@ -421,7 +434,7 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 74,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -432,7 +445,7 @@
" from buildingspy.io.outputfile import Reader\n",
" import matplotlib.pyplot as plt\n",
"\n",
" room_styles = ['k', 'b', 'g', 'r', 'c', 'g']\n",
" room_styles = ['b', 'k', 'r', 'g', 'c', 'g']\n",
" room_names = ['nor', 'wes', 'sou', 'eas', 'cor'] \n",
" plt.clf() \n",
" time_scale=86400.\n",
Expand Down Expand Up @@ -462,8 +475,9 @@
" for iRoo in [0, 2]:\n",
" ax[i].plot(t, yHea[iRoo], room_styles[iRoo], \\\n",
" label='$y_{{hea,{name}}}$'.format(name=room_names[iRoo]), linewidth=0.25)\n",
" ax[i].plot(t, yVAV[iRoo], room_styles[iRoo+1], \\\n",
" label='$y_{{vav,{name}}}$'.format(name=room_names[iRoo]), linewidth=0.25)\n",
" ax[i].plot(t, yVAV[iRoo], room_styles[iRoo], \\\n",
" label='$y_{{vav,{name}}}$'.format(name=room_names[iRoo]), linewidth=0.25, linestyle=\"--\", \\\n",
" marker='^', markersize=1, markevery=200)\n",
" \n",
" # customize days to display\n",
" ax[i].set_xlim([min(t)+5, min(t)+12])\n",
Expand All @@ -488,7 +502,7 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 57,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -550,7 +564,7 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 76,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -585,12 +599,12 @@
"\n",
" \n",
" # Plot figure\n",
"\n",
" ax = plt.subplot(2, 1, 1)\n",
" fig = plt.figure(figsize=(6.5,4.))\n",
" ax = fig.add_subplot(2, 1, 1)\n",
" ax.plot(t, TOut-273.15, 'gray', label='$T_{out}$', linewidth=0.25)\n",
" ax.plot(t, TSupNoFr-273.15, 'b', label='$T_{sup}$', linewidth=0.25)\n",
" ax.plot(tWith, TMixWith-273.15, 'g', label='$T_{mix,with}$', linewidth=0.5)\n",
" ax.plot(t, TMixNoFr-273.15, 'r', label='$T_{mix}$', linewidth=0.5)\n",
" ax.plot(t, TSupNoFr-273.15, 'k', label='$T_{sup}$', linewidth=0.25)\n",
" ax.plot(tWith, TMixWith-273.15, 'b', label='$T_{mix,with}$', linewidth=0.5)\n",
" ax.plot(t, TMixNoFr-273.15, 'b', label='$T_{mix}$', linewidth=0.5, linestyle=\"--\")\n",
"\n",
" #ax.set_xlabel('time [days]')\n",
" ax.set_ylabel('temperature [$^\\circ$C]')\n",
Expand All @@ -602,9 +616,9 @@
"\n",
" configure_axes(ax)\n",
"\n",
" ax = plt.subplot(2, 1, 2)\n",
" ax.plot(tWith, yEcoOutWith, 'g', label='$y_{eco,out,with}$', linewidth=0.25)\n",
" ax.plot(t, yEcoOutNoFr, 'r', label='$y_{eco,out,no}$', linewidth=0.25)\n",
" ax = fig.add_subplot(2, 1, 2)\n",
" ax.plot(tWith, yEcoOutWith, 'r', label='$y_{eco,out,with}$', linewidth=0.25)\n",
" ax.plot(t, yEcoOutNoFr, 'r', label='$y_{eco,out,no}$', linewidth=0.25, linestyle=\"--\")\n",
" ax.set_xlabel('time [days]')\n",
" ax.set_ylabel('$y_{eco,out}$ [$1$]')\n",
" #ax.xaxis.set_ticks(np.arange(min(t)+0, 365, 1))\n",
Expand All @@ -631,7 +645,7 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 62,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -666,9 +680,9 @@
" # ax[i] = plt.subplot(num_cases*num_seasons, 1, i+1)\n",
"\n",
" ax[i].plot(t, yFanSup, 'r', label='$y_{fan,sup}$', linewidth=0.25)\n",
" #ax[i].plot(t, yFanRet, 'g', label='$y_{fan,ret}$', linewidth=0.25)\n",
" #ax[i].plot(t, yEcoOut, 'g', label='$y_{eco,out}$', linewidth=0.25)\n",
" #ax[i].plot(t, yEcoRet, 'b', label='$y_{eco,ret}$', linewidth=0.25)\n",
" #ax[i].plot(t, yFanRet, 'b', label='$y_{fan,ret}$', linewidth=0.25, linestyle='--')\n",
" #ax[i].plot(t, yEcoOut, 'r', label='$y_{eco,out}$', linewidth=0.25)\n",
" #ax[i].plot(t, yEcoRet, 'r', label='$y_{eco,ret}$', linewidth=0.25, linestyle='--')\n",
" \n",
" ax[i].set_xlim([min(t)+5, min(t)+12])\n",
" \n",
Expand All @@ -692,7 +706,7 @@
},
{
"cell_type": "code",
"execution_count": 51,
"execution_count": 64,
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -762,9 +776,9 @@
" \n",
" # ax[i] = plt.subplot(num_cases*num_seasons, 1, i+1)\n",
"\n",
" ax[i].plot(t, fanSupACH, 'r', label='$\\dot m_{fan,sup}/V_{bui}$', linewidth=0.25)\n",
" ax[i].plot(t, fanSupACH, 'b', label='$\\dot m_{fan,sup}/V_{bui}$', linewidth=0.25)\n",
"# ax[i].plot(t, mFanRet, 'g', label='$\\dot m_{fan,ret}/\\dot m_{0}$', linewidth=0.25)\n",
" ax[i].plot(t, ecoACH, 'g', label='$\\dot m_{eco,out}/V_{bui}$', linewidth=0.25)\n",
" ax[i].plot(t, ecoACH, 'r', label='$\\dot m_{eco,out}/V_{bui}$', linewidth=0.25)\n",
"\n",
" \n",
" # customize days to display\n",
Expand Down

0 comments on commit 9412e37

Please sign in to comment.