{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Map of the Maritime Continent" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# fig, ax = plt.subplots(figsize=(6.5, 4.25), dpi=300, constrained_layout=True, \n", "# subplot_kw={'projection': ccrs.PlateCarree(central_longitude=180)})\n", "\n", "# extent = [90, 160, -15, 15]\n", "# min_lon, max_lon, min_lat, max_lat = extent\n", "\n", "# ax.set_extent(extent, crs=ccrs.PlateCarree())\n", "# ax.add_feature(ctp.feature.LAND, facecolor='gainsboro')\n", "# ax.add_feature(ctp.feature.OCEAN, facecolor='#b5d4e9')\n", "# ax.coastlines(resolution='50m', color='black', linewidth=0.8)\n", "# gl = ax.gridlines(crs=ccrs.PlateCarree(), linestyle='--', color='gray', linewidth=0.4, alpha=0.5, \n", "# xlocs=[90, 100, 110, 120, 130, 140, 150, 160], ylocs=[-15, -10, -5, 0, 5, 10, 15])\n", "# gl.bottom_labels = True\n", "# gl.left_labels = True\n", "# gl.top_labels = True\n", "# gl.right_labels = True\n", "\n", "# patch_coords = (90, 160, -15, 15)\n", "# patch_min_lon, patch_max_lon, patch_min_lat, patch_max_lat = patch_coords\n", "# ax.add_patch(mpatches.Rectangle(xy=[patch_min_lon, patch_min_lat], \n", "# width=(patch_max_lon-patch_min_lon), height=(patch_max_lat-patch_min_lat), \n", "# edgecolor='black', facecolor='none', linestyle='--', linewidth=1, zorder=4,\n", "# transform=ccrs.PlateCarree()))\n", "\n", "# # Add text to indicate continents, oceans, and study area\n", "# ax.text(92, -11.5, \"Indian Ocean\", fontsize=10, fontweight='normal', ha='left', va='center', transform=ccrs.PlateCarree())\n", "# ax.text(158, 2.5, \"Pacific Ocean\", fontsize=10, fontweight='normal', ha='right', va='center', transform=ccrs.PlateCarree())\n", "\n", "# ax.text(102, -1, \"Sumatra\", fontsize=7, fontweight='normal', ha='center', va='center', rotation=310, transform=ccrs.PlateCarree())\n", "\n", "# ax.scatter(109.6, -7.3, s=6, marker='o', color='black', transform=ccrs.PlateCarree())\n", "# ax.plot([109.6, 109], [-7.3, -9], color='black', linewidth=1, transform=ccrs.PlateCarree())\n", "# ax.text(109, -9.5, \"Java\", fontsize=7, fontweight='normal', ha='center', va='center', rotation=0, transform=ccrs.PlateCarree())\n", "\n", "# ax.scatter(120, -2, s=6, marker='o', color='black', transform=ccrs.PlateCarree())\n", "# ax.plot([120, 117], [-2, -5], color='black', linewidth=1, transform=ccrs.PlateCarree())\n", "# ax.text(116.2, -5.5, \"Sulawesi\", fontsize=7, fontweight='normal', ha='center', va='center', rotation=0, transform=ccrs.PlateCarree())\n", "\n", "# # add dot over Mindanao, add line from the dot to the right, add text to the right \"the Philippines\"\n", "# ax.scatter(125, 7.5, s=6, marker='o', color='black', transform=ccrs.PlateCarree())\n", "# ax.plot([125, 128], [7.5, 8.5], color='black', linewidth=1, transform=ccrs.PlateCarree())\n", "# ax.text(132.5, 8.5, \"The Philippines\", fontsize=7, fontweight='normal', ha='center', va='center', rotation=0, transform=ccrs.PlateCarree())\n", "\n", "# # add dot over Kuala Lumpur, add line from the dot to its right, add text \"Malay Peninsula\"\n", "# ax.scatter(102, 4, s=6, marker='o', color='black', transform=ccrs.PlateCarree())\n", "# ax.plot([102, 104.5], [4, 5.5], color='black', linewidth=1, transform=ccrs.PlateCarree())\n", "# ax.text(108.5, 6.2, \"Malay Peninsula\", fontsize=7, fontweight='normal', ha='center', va='center', rotation=0, transform=ccrs.PlateCarree())\n", "\n", "# ax.text(113.4, 0, \"Borneo\", fontsize=7, fontweight='normal', ha='center', va='center', rotation=0, transform=ccrs.PlateCarree())\n", "# ax.text(141.5, -5.2, \"Papua New Guinea\", fontsize=7, fontweight='normal', ha='center', va='center', rotation=340, transform=ccrs.PlateCarree())\n", "\n", "# ax.text(126.8, -10.2, \"East Timor\", fontsize=7, fontweight='normal', ha='center', va='center', rotation=30, transform=ccrs.PlateCarree())\n", "\n", "\n", "# plt.rcParams['axes.facecolor'] = 'white'\n", "# plt.rcParams['savefig.facecolor'] = 'white'\n", "# plt.show()\n", "# filename = f'fig_study_area_sbc_island_names'\n", "# fig.savefig(f'../figures/{filename}.png', dpi=600, bbox_inches='tight')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# inset on map\n", "# fig, ax = plt.subplots(figsize=(6.5, 4.25), dpi=300, constrained_layout=True, subplot_kw={'projection': ccrs.PlateCarree(central_longitude=180)})\n", "\n", "# extent = [80, 170, -30, 30]\n", "# min_lon, max_lon, min_lat, max_lat = extent\n", "\n", "# ax.set_extent(extent, crs=ccrs.PlateCarree())\n", "# ax.coastlines(resolution='50m', color='gray', linewidth=0.6)\n", "# gl = ax.gridlines(crs=ccrs.PlateCarree(), linestyle='--', color='gray', linewidth=0.4, alpha=0.5,\n", "# xlocs=[100, 120, 140, 160],\n", "# ylocs=[-15, 0, 15])\n", "# gl.bottom_labels = True\n", "# gl.left_labels = True\n", "# gl.top_labels = True\n", "# gl.right_labels = True\n", "\n", "# text_objects = []\n", "# for _, row in df[(df['mainland']!='Sulawesi') & (df['mainland']!='Isles2') & (df['mainland']!='Isles1')].iterrows():\n", "# segment = sgeom.LineString([(row['lon1'], row['lat1']), (row['lon2'], row['lat2'])])\n", "# ax.add_geometries([segment], ccrs.PlateCarree(), facecolor='none', edgecolor='red', linewidth=2, alpha=0.8)\n", "# # Add segment number\n", "# seg_number = str(row['segID'])\n", "# lon_mid = (row['lon1'] + row['lon2']) / 2\n", "# lat_mid = (row['lat1'] + row['lat2']) / 2\n", "# text_obj = ax.text(lon_mid, lat_mid, seg_number, transform=ccrs.PlateCarree(), ha='left', va='center', color='black', fontsize=5)\n", "# text_objects.append(text_obj)\n", "\n", "# # Adjust the position of segment numbers to avoid overlap\n", "# adjust_text(text_objects, ax=ax, autoalign='xy', \n", "# avoid_text=True, avoid_points=True, avoid_self=True, \n", "# expand_text=(1.5,1.2), arrowprops=dict(arrowstyle=\"-\", color='black', lw=0.5, alpha=0.8))\n", "\n", "# # Inset 1\n", "# sulawesi_coords = (118, 131.5, -7, 3)\n", "# sulawesi_min_lon, sulawesi_max_lon, sulawesi_min_lat, sulawesi_max_lat = sulawesi_coords\n", "\n", "# patch_coords = (118, 131.5, -7, 3)\n", "# patch_min_lon, patch_max_lon, patch_min_lat, patch_max_lat = patch_coords\n", "# ax.add_patch(mpatches.Rectangle(xy=[patch_min_lon, patch_min_lat], \n", "# width=(patch_max_lon-patch_min_lon), height=(patch_max_lat-patch_min_lat), \n", "# edgecolor='black', facecolor='none', linestyle='-', linewidth=0.6, zorder=0,\n", "# transform=ccrs.PlateCarree()))\n", "\n", "# ax_inset_1 = fig.add_axes([0.57, 0.55, 0.36, 0.36], projection=ccrs.PlateCarree(central_longitude=180))\n", "# ax_inset_1.set_extent(sulawesi_coords, crs=ccrs.PlateCarree())\n", "# ax_inset_1.coastlines(resolution='50m', color='gray', linewidth=0.6)\n", "# gl_inset_1 = ax_inset_1.gridlines(crs=ccrs.PlateCarree(), linestyle='--', color='gray', linewidth=0.4, alpha=0.5,\n", "# xlocs=[120, 130], ylocs=[0])\n", "# gl_inset_1.bottom_labels = True\n", "# gl_inset_1.left_labels = True\n", "# gl_inset_1.xlabel_style = {'size': 6}\n", "# gl_inset_1.ylabel_style = {'size': 6}\n", "\n", "# text_objects_inset_1 = []\n", "# for _, row in df[(df['mainland']=='Sulawesi') | (df['mainland']=='Isles2')].iterrows():\n", "# segment = sgeom.LineString([(row['lon1'], row['lat1']), (row['lon2'], row['lat2'])])\n", "# ax_inset_1.add_geometries([segment], ccrs.PlateCarree(), facecolor='none', edgecolor='red', linewidth=2, alpha=0.8)\n", "# seg_number = str(row['segID'])\n", "# lon_mid = (row['lon1'] + row['lon2']) / 2\n", "# lat_mid = (row['lat1'] + row['lat2']) / 2\n", "# text_obj = ax_inset_1.text(lon_mid, lat_mid, seg_number, transform=ccrs.PlateCarree(), ha='left', va='center', color='black', fontsize=5)\n", "# text_objects_inset_1.append(text_obj)\n", "\n", "# # Inset 2\n", "# nusa_coords = (114, 128, -11, -6)\n", "# nusa_min_lon, nusa_max_lon, nusa_min_lat, nusa_max_lat = nusa_coords\n", "\n", "# patch_coords = (114, 128, -11, -6)\n", "# patch_min_lon, patch_max_lon, patch_min_lat, patch_max_lat = patch_coords\n", "# ax.add_patch(mpatches.Rectangle(xy=[patch_min_lon, patch_min_lat], \n", "# width=(patch_max_lon-patch_min_lon), height=(patch_max_lat-patch_min_lat), \n", "# edgecolor='black', facecolor='none', linestyle='-', linewidth=0.6, zorder=0,\n", "# transform=ccrs.PlateCarree()))\n", "\n", "# ax_inset_2 = fig.add_axes([0.12, 0.04, 0.36, 0.36], projection=ccrs.PlateCarree(central_longitude=180))\n", "# ax_inset_2.set_extent(nusa_coords, crs=ccrs.PlateCarree())\n", "# ax_inset_2.coastlines(resolution='50m', color='gray', linewidth=0.6)\n", "# gl_inset_2 = ax_inset_2.gridlines(crs=ccrs.PlateCarree(), linestyle='--', color='gray', linewidth=0.4, alpha=0.5,\n", "# xlocs=[120], ylocs=[-10])\n", "# gl_inset_2.bottom_labels = True\n", "# gl_inset_2.left_labels = True\n", "# gl_inset_2.xlabel_style = {'size': 6}\n", "# gl_inset_2.ylabel_style = {'size': 6}\n", "\n", "# text_objects_inset_2 = []\n", "# for _, row in df[(df['mainland']=='Isles1')].iterrows():\n", "# segment = sgeom.LineString([(row['lon1'], row['lat1']), (row['lon2'], row['lat2'])])\n", "# ax_inset_2.add_geometries([segment], ccrs.PlateCarree(), facecolor='none', edgecolor='red', linewidth=2, alpha=0.8)\n", "# seg_number = str(row['segID'])\n", "# lon_mid = (row['lon1'] + row['lon2']) / 2\n", "# lat_mid = (row['lat1'] + row['lat2']) / 2\n", "# text_obj = ax_inset_2.text(lon_mid, lat_mid, seg_number, transform=ccrs.PlateCarree(), ha='left', va='center', color='black', fontsize=5)\n", "# text_objects_inset_2.append(text_obj)\n", "\n", "# plt.rcParams['axes.facecolor'] = 'white'\n", "# plt.rcParams['savefig.facecolor'] = 'white'\n", "# plt.show()\n", "\n", "# filename = f'fig_map_segments'\n", "# fig.savefig(f'../figures/{filename}.png', dpi=600, bbox_inches='tight')\n" ] } ], "metadata": { "kernelspec": { "display_name": "mjo_stable", "language": "python", "name": "python3" }, "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.7.12" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }