From 43e640b9763c08a61fb71e4dc86912b553915151 Mon Sep 17 00:00:00 2001 From: tobfer Date: Mon, 11 Dec 2023 09:34:52 +0000 Subject: [PATCH] comment notebook --- .../general/polar_plotting.ipynb | 144 ++++++++++-------- 1 file changed, 80 insertions(+), 64 deletions(-) diff --git a/example_scripts/notebook_tutorials/runnable_notebooks/general/polar_plotting.ipynb b/example_scripts/notebook_tutorials/runnable_notebooks/general/polar_plotting.ipynb index aecaca03..895e3a2d 100644 --- a/example_scripts/notebook_tutorials/runnable_notebooks/general/polar_plotting.ipynb +++ b/example_scripts/notebook_tutorials/runnable_notebooks/general/polar_plotting.ipynb @@ -215,9 +215,17 @@ "- In case 3, both corrections have been applied and the velocities quivers now align with the route of strong current speed as would be expected." ] }, + { + "cell_type": "markdown", + "id": "d513b5a2", + "metadata": {}, + "source": [ + "`!WARNING: UNCOMMENT THE LINES BELOW TO PLOT THE MAPS`" + ] + }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "1e0b3efd-b57b-45cd-8974-3ba74c840c0f", "metadata": {}, "outputs": [ @@ -233,62 +241,62 @@ } ], "source": [ - "# Subplot axes settings\n", - "n_r = 2 # Number of subplot rows\n", - "n_c = 2 # Number of subplot columns\n", - "figsize = (20, 20) # Figure size\n", - "subplot_padding = 0.5 # Amount of vertical and horizontal padding between plots\n", - "fig_pad = (0.075, 0.075, 0.1, 0.1) # Figure padding (left, top, right, bottom)\n", + "# # Subplot axes settings\n", + "# n_r = 2 # Number of subplot rows\n", + "# n_c = 2 # Number of subplot columns\n", + "# figsize = (20, 20) # Figure size\n", + "# subplot_padding = 0.5 # Amount of vertical and horizontal padding between plots\n", + "# fig_pad = (0.075, 0.075, 0.1, 0.1) # Figure padding (left, top, right, bottom)\n", "\n", - "# Labels and Titles\n", - "fig_title = \"Velocity Plot\" # Whole figure title\n", + "# # Labels and Titles\n", + "# fig_title = \"Velocity Plot\" # Whole figure title\n", "\n", - "# Create plot and flatten axis array\n", - "fig, ax = plt.subplots(n_r, n_c, subplot_kw={\"projection\": mrc}, sharey=True, sharex=True, figsize=figsize)\n", - "cax = fig.add_axes([0.3, 0.96, 0.4, 0.01])\n", + "# # Create plot and flatten axis array\n", + "# fig, ax = plt.subplots(n_r, n_c, subplot_kw={\"projection\": mrc}, sharey=True, sharex=True, figsize=figsize)\n", + "# cax = fig.add_axes([0.3, 0.96, 0.4, 0.01])\n", "\n", "\n", - "ax = ax.flatten()\n", - "for rr in range(n_r * n_c):\n", - " ax[rr].add_feature(cfeature.LAND, zorder=100)\n", - " ax[rr].gridlines()\n", - " ax[rr].set_extent([-180, 180, 70, 90], crs=data_crs)\n", - " coast._utils.plot_util.set_circle(ax[rr])\n", + "# ax = ax.flatten()\n", + "# for rr in range(n_r * n_c):\n", + "# ax[rr].add_feature(cfeature.LAND, zorder=100)\n", + "# ax[rr].gridlines()\n", + "# ax[rr].set_extent([-180, 180, 70, 90], crs=data_crs)\n", + "# coast._utils.plot_util.set_circle(ax[rr])\n", "\n", "\n", - "cs = ax[0].pcolormesh(nemo_data_t.longitude.values, nemo_data_t.latitude.values, speed, transform=data_crs, vmin=0, vmax=0.3)\n", - "ax[0].quiver(nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n", - " data_u.to_array().values[0, :, :], data_v.to_array().values[0, :, :], \n", - " color='w', transform=data_crs, angles='xy', regrid_shape=40)\n", + "# cs = ax[0].pcolormesh(nemo_data_t.longitude.values, nemo_data_t.latitude.values, speed, transform=data_crs, vmin=0, vmax=0.3)\n", + "# ax[0].quiver(nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n", + "# data_u.to_array().values[0, :, :], data_v.to_array().values[0, :, :], \n", + "# color='w', transform=data_crs, angles='xy', regrid_shape=40)\n", "\n", - "ax[1].pcolormesh(nemo_data_t.longitude.values, nemo_data_t.latitude.values, speed, transform=data_crs, vmin=0, vmax=0.3)\n", - "ax[1].quiver(nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n", - " u_new, v_new, \n", - " color='w', transform=data_crs, angles='xy', regrid_shape=40)\n", + "# ax[1].pcolormesh(nemo_data_t.longitude.values, nemo_data_t.latitude.values, speed, transform=data_crs, vmin=0, vmax=0.3)\n", + "# ax[1].quiver(nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n", + "# u_new, v_new, \n", + "# color='w', transform=data_crs, angles='xy', regrid_shape=40)\n", "\n", - "ax[2].pcolormesh(nemo_data_t.longitude.values, nemo_data_t.latitude.values, speed, transform=data_crs, vmin=0, vmax=0.3)\n", - "ax[2].quiver(nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n", - " u_pol, v_pol, \n", - " color='w', transform=data_crs, angles='xy', regrid_shape=40)\n", + "# ax[2].pcolormesh(nemo_data_t.longitude.values, nemo_data_t.latitude.values, speed, transform=data_crs, vmin=0, vmax=0.3)\n", + "# ax[2].quiver(nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n", + "# u_pol, v_pol, \n", + "# color='w', transform=data_crs, angles='xy', regrid_shape=40)\n", "\n", - "ax[3].pcolormesh(nemo_data_t.longitude.values, nemo_data_t.latitude.values, speed, transform=data_crs, vmin=0, vmax=0.3)\n", - "ax[3].streamplot(nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n", - " u_pol, v_pol, transform=data_crs, linewidth=1, density=2, color='w', zorder=101)\n", + "# ax[3].pcolormesh(nemo_data_t.longitude.values, nemo_data_t.latitude.values, speed, transform=data_crs, vmin=0, vmax=0.3)\n", + "# ax[3].streamplot(nemo_data_t.longitude.values, nemo_data_t.latitude.values, \n", + "# u_pol, v_pol, transform=data_crs, linewidth=1, density=2, color='w', zorder=101)\n", "\n", - "ax[0].set_title('1: No Correction')\n", - "ax[1].set_title('2: NEMO Grid Correction')\n", - "ax[2].set_title('3: Grid Correction and Polar Correction')\n", - "ax[3].set_title('As left but with streamlines')\n", + "# ax[0].set_title('1: No Correction')\n", + "# ax[1].set_title('2: NEMO Grid Correction')\n", + "# ax[2].set_title('3: Grid Correction and Polar Correction')\n", + "# ax[3].set_title('As left but with streamlines')\n", "\n", - "fig.colorbar(cs, cax=cax, orientation='horizontal')\n", - "cax.set_xlabel('U (m s$^{-1}$)')\n", + "# fig.colorbar(cs, cax=cax, orientation='horizontal')\n", + "# cax.set_xlabel('U (m s$^{-1}$)')\n", "\n", - "#fig.tight_layout(w_pad=subplot_padding, h_pad=subplot_padding)\n", - "#fig.subplots_adjust(left=(fig_pad[0]), bottom=(fig_pad[1]), right=(1 - fig_pad[2]), top=(1 - fig_pad[3]))\n", + "# #fig.tight_layout(w_pad=subplot_padding, h_pad=subplot_padding)\n", + "# #fig.subplots_adjust(left=(fig_pad[0]), bottom=(fig_pad[1]), right=(1 - fig_pad[2]), top=(1 - fig_pad[3]))\n", "\n", - "plt.show()\n", - "# uncomment this line to save an output image\n", - "# fig.savefig(fn_out)" + "# plt.show()\n", + "# # uncomment this line to save an output image\n", + "# # fig.savefig(fn_out)" ] }, { @@ -301,7 +309,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "id": "8f79b27f-4c86-4ae1-abb3-8f37ceb96a37", "metadata": {}, "outputs": [], @@ -311,9 +319,17 @@ "data_temp = nemo_data_t.temperature.isel(t_dim=0, z_dim=0)" ] }, + { + "cell_type": "markdown", + "id": "0186fa1a", + "metadata": {}, + "source": [ + "`!WARNING: UNCOMMENT THE LINES BELOW TO PLOT THE MAPS`" + ] + }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "id": "9d15d7af-7cfe-431d-b6e7-fb56fd941501", "metadata": {}, "outputs": [ @@ -339,27 +355,27 @@ } ], "source": [ - "figsize = (5, 5) # Figure size\n", - "fig = plt.figure(figsize=figsize)\n", - "ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.75], projection=mrc)\n", - "cax = fig.add_axes([0.3, 0.96, 0.4, 0.01])\n", + "# figsize = (5, 5) # Figure size\n", + "# fig = plt.figure(figsize=figsize)\n", + "# ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.75], projection=mrc)\n", + "# cax = fig.add_axes([0.3, 0.96, 0.4, 0.01])\n", "\n", - "ax1.add_feature(cfeature.LAND, zorder=105)\n", - "ax1.gridlines()\n", - "ax1.set_extent([-180, 180, 70, 90], crs=data_crs)\n", - "coast._utils.plot_util.set_circle(ax1)\n", + "# ax1.add_feature(cfeature.LAND, zorder=105)\n", + "# ax1.gridlines()\n", + "# ax1.set_extent([-180, 180, 70, 90], crs=data_crs)\n", + "# coast._utils.plot_util.set_circle(ax1)\n", "\n", - "# We use to a function to re-project the data for plotting contours over the pole.\n", - "cs1 = coast._utils.plot_util.plot_polar_contour(\n", - " nemo_data_t.longitude.values, nemo_data_t.latitude.values, data_bathy, ax1, levels=6, colors=\"k\", zorder=101\n", - ")\n", - "cs2 = ax1.pcolormesh(\n", - " nemo_data_t.longitude.values, nemo_data_t.latitude.values, data_temp, transform=data_crs, vmin=-2, vmax=8\n", - ")\n", - "cax.set_xlabel(r\"SST ($^{\\circ}$C)\")\n", - "fig.colorbar(cs2, cax=cax, orientation=\"horizontal\")\n", + "# # We use to a function to re-project the data for plotting contours over the pole.\n", + "# cs1 = coast._utils.plot_util.plot_polar_contour(\n", + "# nemo_data_t.longitude.values, nemo_data_t.latitude.values, data_bathy, ax1, levels=6, colors=\"k\", zorder=101\n", + "# )\n", + "# cs2 = ax1.pcolormesh(\n", + "# nemo_data_t.longitude.values, nemo_data_t.latitude.values, data_temp, transform=data_crs, vmin=-2, vmax=8\n", + "# )\n", + "# cax.set_xlabel(r\"SST ($^{\\circ}$C)\")\n", + "# fig.colorbar(cs2, cax=cax, orientation=\"horizontal\")\n", "\n", - "# fig.savefig(fn_out, dpi=120)\n" + "# # fig.savefig(fn_out, dpi=120)\n" ] }, {