You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1646 lines
55 KiB
Plaintext
1646 lines
55 KiB
Plaintext
6 years ago
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Method plots"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Setup notebook\n",
|
||
|
"Import our required packages and set default plotting options."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Enable autoreloading of our modules. \n",
|
||
|
"# Most of the code will be located in the /src/ folder, \n",
|
||
|
"# and then called from the notebook.\n",
|
||
|
"%matplotlib inline\n",
|
||
|
"%reload_ext autoreload\n",
|
||
|
"%autoreload"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"from IPython.core.debugger import set_trace\n",
|
||
|
"\n",
|
||
|
"import pandas as pd\n",
|
||
|
"import numpy as np\n",
|
||
|
"import os\n",
|
||
|
"import decimal\n",
|
||
|
"import plotly\n",
|
||
|
"import plotly.graph_objs as go\n",
|
||
|
"import plotly.plotly as py\n",
|
||
|
"import plotly.tools as tls\n",
|
||
|
"import plotly.figure_factory as ff\n",
|
||
|
"from plotly import tools\n",
|
||
|
"import plotly.io as pio\n",
|
||
|
"from scipy import stats\n",
|
||
|
"import math\n",
|
||
|
"import matplotlib\n",
|
||
|
"from matplotlib import cm\n",
|
||
|
"import colorlover as cl\n",
|
||
|
"from tqdm import tqdm_notebook\n",
|
||
|
"from ipywidgets import widgets, Output\n",
|
||
|
"from IPython.display import display, clear_output, Image, HTML\n",
|
||
|
"from scipy import stats\n",
|
||
|
"from sklearn.metrics import confusion_matrix\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"from matplotlib.ticker import MultipleLocator\n",
|
||
|
"from matplotlib.lines import Line2D\n",
|
||
|
"from cycler import cycler\n",
|
||
|
"from scipy.interpolate import interp1d\n",
|
||
|
"from pandas.api.types import CategoricalDtype\n",
|
||
|
"import seaborn as sns\n",
|
||
|
"sns.set(style=\"white\")\n",
|
||
|
"from scipy import interpolate\n",
|
||
|
"from tqdm import tqdm"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Matplot lib default settings\n",
|
||
|
"plt.rcParams[\"figure.figsize\"] = (10, 6)\n",
|
||
|
"plt.rcParams['axes.grid'] = True\n",
|
||
|
"plt.rcParams['grid.alpha'] = 0.3\n",
|
||
|
"plt.rcParams['grid.color'] = \"grey\"\n",
|
||
|
"plt.rcParams['grid.linestyle'] = \"--\"\n",
|
||
|
"plt.rcParams['grid.linewidth'] = 0.5\n",
|
||
|
"plt.rcParams['axes.grid'] = True\n",
|
||
|
"\n",
|
||
|
"# # https://stackoverflow.com/a/20709149\n",
|
||
|
"matplotlib.rcParams['text.usetex'] = True\n",
|
||
|
"matplotlib.rcParams['font.family'] = 'sans-serif'\n",
|
||
|
"\n",
|
||
|
"# # matplotlib.rcParams['text.latex.preamble'] = [\n",
|
||
|
"# # r'\\usepackage{siunitx}', # i need upright \\micro symbols, but you need...\n",
|
||
|
"# # r'\\sisetup{detect-all}', # ...this to force siunitx to actually use your fonts\n",
|
||
|
"# # r'\\usepackage{helvet}', # set the normal font here\n",
|
||
|
"# # r'\\usepackage{amsmath}',\n",
|
||
|
"# # r'\\usepackage{sansmath}', # load up the sansmath so that math -> helvet\n",
|
||
|
"# # r'\\sansmath', # <- tricky! -- gotta actually tell tex to use!\n",
|
||
|
"# # ]\n",
|
||
|
"\n",
|
||
|
"matplotlib.rcParams['text.latex.preamble'] = [\n",
|
||
|
" r'\\usepackage{siunitx}', # i need upright \\micro symbols, but you need...\n",
|
||
|
" r'\\sisetup{detect-all}', # ...this to force siunitx to actually use your fonts\n",
|
||
|
" r'\\usepackage[default]{sourcesanspro}',\n",
|
||
|
" r'\\usepackage{amsmath}',\n",
|
||
|
" r'\\usepackage{sansmath}', # load up the sansmath so that math -> helvet\n",
|
||
|
" r'\\sansmath', # <- tricky! -- gotta actually tell tex to use!\n",
|
||
|
"]\n",
|
||
|
"\n",
|
||
|
"# import matplotlib as mpl\n",
|
||
|
"# mpl.use(\"pgf\")\n",
|
||
|
"# pgf_with_custom_preamble = {\n",
|
||
|
"# \"font.family\":\"sans-serif\", # use serif/main font for text elements\n",
|
||
|
"# \"text.usetex\":True, # use inline math for ticks\n",
|
||
|
"# \"pgf.rcfonts\":False, # don't setup fonts from rc parameters\n",
|
||
|
"# \"pgf.preamble\": [\n",
|
||
|
"# r'\\usepackage{siunitx}', # i need upright \\micro symbols, but you need...\n",
|
||
|
"# r'\\sisetup{detect-all}', # ...this to force siunitx to actually use your fonts\n",
|
||
|
"# r'\\usepackage[default]{sourcesanspro}',\n",
|
||
|
"# r'\\usepackage{amsmath}',\n",
|
||
|
"# r'\\usepackage[mathrm=sym]{unicode-math}',\n",
|
||
|
"# r'\\setmathfont{Fira Math}',\n",
|
||
|
"# ]\n",
|
||
|
"# }\n",
|
||
|
"# mpl.rcParams.update(pgf_with_custom_preamble)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Import data\n",
|
||
|
"Import our data from the `./data/interim/` folder and load it into pandas dataframes. "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def df_from_csv(csv, index_col, data_folder='../data/interim'):\n",
|
||
|
" print('Importing {}'.format(csv))\n",
|
||
|
" return pd.read_csv(os.path.join(data_folder,csv), index_col=index_col)\n",
|
||
|
"\n",
|
||
|
"df_waves = df_from_csv('waves.csv', index_col=[0, 1])\n",
|
||
|
"df_tides = df_from_csv('tides.csv', index_col=[0, 1])\n",
|
||
|
"df_profiles = df_from_csv('profiles.csv', index_col=[0, 1, 2])\n",
|
||
|
"df_sites = df_from_csv('sites.csv', index_col=[0])\n",
|
||
|
"df_sites_waves = df_from_csv('sites_waves.csv', index_col=[0])\n",
|
||
|
"df_profile_features_crest_toes = df_from_csv('profile_features_crest_toes.csv', index_col=[0,1])\n",
|
||
|
"\n",
|
||
|
"# Note that the forecasted data sets should be in the same order for impacts and twls\n",
|
||
|
"impacts = {\n",
|
||
|
" 'forecasted': {\n",
|
||
|
" 'postintertidal_slope_sto06': df_from_csv('impacts_forecasted_postintertidal_slope_sto06.csv', index_col=[0]),\n",
|
||
|
" 'postmean_slope_sto06': df_from_csv('impacts_forecasted_postmean_slope_sto06.csv', index_col=[0]),\n",
|
||
|
" 'preintertidal_slope_sto06': df_from_csv('impacts_forecasted_preintertidal_slope_sto06.csv', index_col=[0]),\n",
|
||
|
" 'premean_slope_sto06': df_from_csv('impacts_forecasted_premean_slope_sto06.csv', index_col=[0]),\n",
|
||
|
" },\n",
|
||
|
" 'observed': df_from_csv('impacts_observed.csv', index_col=[0])\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
"twls = {\n",
|
||
|
" 'forecasted': {\n",
|
||
|
" 'postintertidal_slope_sto06': df_from_csv('twl_postintertidal_slope_sto06.csv', index_col=[0,1]),\n",
|
||
|
" 'postmean_slope_sto06': df_from_csv('twl_postmean_slope_sto06.csv', index_col=[0,1]),\n",
|
||
|
" 'preintertidal_slope_sto06': df_from_csv('twl_preintertidal_slope_sto06.csv', index_col=[0,1]),\n",
|
||
|
" 'premean_slope_sto06': df_from_csv('twl_premean_slope_sto06.csv', index_col=[0,1]),\n",
|
||
|
" }\n",
|
||
|
"}\n",
|
||
|
"print('Done!')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Plot example of swash and collision profiles"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import matplotlib.gridspec as gridspec\n",
|
||
|
"import matplotlib.ticker as ticker\n",
|
||
|
"\n",
|
||
|
"# Setup grid\n",
|
||
|
"fig = plt.figure(figsize=(7, 2), dpi=300)\n",
|
||
|
"gs = gridspec.GridSpec(1, 3)\n",
|
||
|
"ax1 = fig.add_subplot(gs[0, 0])\n",
|
||
|
"ax2 = fig.add_subplot(gs[0, 1], sharey=ax1)\n",
|
||
|
"ax3 = fig.add_subplot(gs[0, 2], sharey=ax1)\n",
|
||
|
"\n",
|
||
|
"prestorm_color = '#fdae61'\n",
|
||
|
"poststorm_color = '#d53e4f'\n",
|
||
|
"\n",
|
||
|
"plots = [\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax1,\n",
|
||
|
" 'title': 'Swash regime',\n",
|
||
|
" 'site_id': 'GRANTSn0009',\n",
|
||
|
" 'x_min_fill': 150,\n",
|
||
|
" 'location': 'Grants\\nBeach',\n",
|
||
|
" 'subplot_letter': '(a)',\n",
|
||
|
" 'xlim_left' : 50,\n",
|
||
|
" },\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax2,\n",
|
||
|
" 'title': 'Collision regime',\n",
|
||
|
" 'site_id': 'MANNING0078',\n",
|
||
|
" 'x_min_fill': 150,\n",
|
||
|
" 'location': 'Manning\\nPoint',\n",
|
||
|
" 'subplot_letter': '(b)',\n",
|
||
|
" 'xlim_left' : 100,\n",
|
||
|
" },\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax3,\n",
|
||
|
" 'title': 'Overwash regime',\n",
|
||
|
" 'site_id': 'AVOCAs0001',\n",
|
||
|
" 'x_min_fill': 80,\n",
|
||
|
" 'location': 'Avoca Lagoon\\nEntrance',\n",
|
||
|
" 'subplot_letter': '(c)',\n",
|
||
|
" 'xlim_left' : 50,\n",
|
||
|
" },\n",
|
||
|
"]\n",
|
||
|
"\n",
|
||
|
"for plot in plots:\n",
|
||
|
" ax = plot['ax']\n",
|
||
|
" site_id = plot['site_id']\n",
|
||
|
" df_pro_pre = df_profiles.xs((site_id, 'prestorm'),\n",
|
||
|
" level=['site_id', 'profile_type'])\n",
|
||
|
" df_pro_post = df_profiles.xs((site_id, 'poststorm'),\n",
|
||
|
" level=['site_id', 'profile_type'])\n",
|
||
|
" df_feat_pre = df_profile_features_crest_toes.xs(\n",
|
||
|
" (site_id, 'prestorm'), level=['site_id', 'profile_type'])\n",
|
||
|
" df_feat_post = df_profile_features_crest_toes.xs(\n",
|
||
|
" (site_id, 'poststorm'), level=['site_id', 'profile_type'])\n",
|
||
|
"\n",
|
||
|
" ax.plot(\n",
|
||
|
" df_pro_post.index.get_level_values('x'),\n",
|
||
|
" df_pro_post.z.values,\n",
|
||
|
" label='Poststorm profile',\n",
|
||
|
" color=poststorm_color,\n",
|
||
|
" linestyle='--')\n",
|
||
|
" ax.plot(\n",
|
||
|
" df_pro_pre.index.get_level_values('x'),\n",
|
||
|
" df_pro_pre.z.values,\n",
|
||
|
" label='Prestorm profile',\n",
|
||
|
" color=prestorm_color)\n",
|
||
|
" ax.scatter(\n",
|
||
|
" df_feat_post.dune_crest_x,\n",
|
||
|
" df_feat_post.dune_crest_z,\n",
|
||
|
" label='Poststorm dune crest',\n",
|
||
|
" facecolor=poststorm_color,\n",
|
||
|
" edgecolor='black',\n",
|
||
|
" linewidth='0.75',\n",
|
||
|
" marker='v',\n",
|
||
|
" zorder=3)\n",
|
||
|
" ax.scatter(\n",
|
||
|
" df_feat_pre.dune_crest_x,\n",
|
||
|
" df_feat_pre.dune_crest_z,\n",
|
||
|
" label='Prestorm dune crest',\n",
|
||
|
" facecolor=prestorm_color,\n",
|
||
|
" edgecolor='black',\n",
|
||
|
" linewidth='0.75',\n",
|
||
|
" marker='v',\n",
|
||
|
" zorder=3)\n",
|
||
|
"\n",
|
||
|
" if not np.isnan(df_feat_post.dune_toe_x.values[0]):\n",
|
||
|
" ax.scatter(\n",
|
||
|
" df_feat_post.dune_toe_x,\n",
|
||
|
" df_feat_post.dune_toe_z,\n",
|
||
|
" label='Poststorm dune toe',\n",
|
||
|
" facecolor=poststorm_color,\n",
|
||
|
" edgecolor='black',\n",
|
||
|
" linewidth='0.75',\n",
|
||
|
" marker='^',\n",
|
||
|
" zorder=3)\n",
|
||
|
"\n",
|
||
|
" if not np.isnan(df_feat_pre.dune_toe_x.values[0]):\n",
|
||
|
" ax.scatter(\n",
|
||
|
" df_feat_pre.dune_toe_x,\n",
|
||
|
" df_feat_pre.dune_toe_z,\n",
|
||
|
" label='Prestorm dune toe',\n",
|
||
|
" facecolor=prestorm_color,\n",
|
||
|
" edgecolor='black',\n",
|
||
|
" linewidth='0.75',\n",
|
||
|
" marker='^',\n",
|
||
|
" zorder=3)\n",
|
||
|
"\n",
|
||
|
" # Fill to zero elevation if there is no post profile value\n",
|
||
|
" z_post = df_pro_post.z.values\n",
|
||
|
" z_post[np.isnan(z_post)] = 0\n",
|
||
|
"\n",
|
||
|
" # Only want to fill the difference between pre/post past a certain x-val\n",
|
||
|
" mask = df_pro_post.index.get_level_values('x') > plot['x_min_fill']\n",
|
||
|
"\n",
|
||
|
" ax.fill_between(\n",
|
||
|
" df_pro_post.index.get_level_values('x')[mask],\n",
|
||
|
" df_pro_pre.z.values[mask],\n",
|
||
|
" z_post[mask],\n",
|
||
|
" color='#f46d43',\n",
|
||
|
" label='Eroded volume',\n",
|
||
|
" alpha=0.4)\n",
|
||
|
"\n",
|
||
|
" # Set lims\n",
|
||
|
" ax.set_ylim([0, 10])\n",
|
||
|
" ax.set_xlim(left=plot['xlim_left'])\n",
|
||
|
"\n",
|
||
|
" # Set ticks to 50 m\n",
|
||
|
" ax.xaxis.set_major_locator(ticker.MultipleLocator(50))\n",
|
||
|
" \n",
|
||
|
" # Change tick label size\n",
|
||
|
" ax.tick_params(axis='both', which='major', labelsize=7)\n",
|
||
|
"\n",
|
||
|
" # Add titles showing regimes\n",
|
||
|
" ax.set_title(plot['title'], size=8)\n",
|
||
|
"\n",
|
||
|
" # Add subplot letters\n",
|
||
|
" ax.text(\n",
|
||
|
" 0.02,\n",
|
||
|
" 0.90,\n",
|
||
|
" plot['subplot_letter'],\n",
|
||
|
" transform=ax.transAxes,\n",
|
||
|
" size=10,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.9,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
" # Add text showing location\n",
|
||
|
" ax.text(\n",
|
||
|
" 0.95,\n",
|
||
|
" 0.95,\n",
|
||
|
" plot['location'],\n",
|
||
|
" transform=ax.transAxes,\n",
|
||
|
" size=8,\n",
|
||
|
" horizontalalignment='right',\n",
|
||
|
" verticalalignment='top',\n",
|
||
|
" zorder=3,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.9,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"# Remove tick parameters from shared axis\n",
|
||
|
"ax2.tick_params(labelleft=False)\n",
|
||
|
"ax3.tick_params(labelleft=False)\n",
|
||
|
"\n",
|
||
|
"# Add y-label\n",
|
||
|
"ax1.set_ylabel('Elevation (mAHD)', size=8)\n",
|
||
|
"\n",
|
||
|
"# Add common x-label\n",
|
||
|
"fig.text(\n",
|
||
|
" 0.5,\n",
|
||
|
" -0.04,\n",
|
||
|
" 'Cross-shore position (m)',\n",
|
||
|
" ha='center',\n",
|
||
|
" size=8,\n",
|
||
|
" horizontalalignment='center',\n",
|
||
|
" verticalalignment='top')\n",
|
||
|
"\n",
|
||
|
"# Add legend\n",
|
||
|
"ax1.legend(\n",
|
||
|
" prop={'size': 6},\n",
|
||
|
" ncol=4,\n",
|
||
|
" bbox_to_anchor=(0.90, 1.0),\n",
|
||
|
" loc=\"lower right\",\n",
|
||
|
" bbox_transform=fig.transFigure)\n",
|
||
|
"\n",
|
||
|
"# Add title\n",
|
||
|
"fig.text(\n",
|
||
|
"0.06,1.01,\n",
|
||
|
"'Examples of observed\\nstorm regimes',\n",
|
||
|
"horizontalalignment='left',\n",
|
||
|
"verticalalignment='bottom',\n",
|
||
|
"size=10)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"fig.savefig('12_observed_storm_impacts.png',dpi=300, bbox_inches = \"tight\")\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"## For coasts and ports\n",
|
||
|
"\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import matplotlib.gridspec as gridspec\n",
|
||
|
"import matplotlib.ticker as ticker\n",
|
||
|
"\n",
|
||
|
"# Setup grid\n",
|
||
|
"fig = plt.figure(figsize=(3, 1.2), dpi=300)\n",
|
||
|
"gs = gridspec.GridSpec(1, 3)\n",
|
||
|
"ax1 = fig.add_subplot(gs[0, 0])\n",
|
||
|
"ax2 = fig.add_subplot(gs[0, 1], sharey=ax1)\n",
|
||
|
"ax3 = fig.add_subplot(gs[0, 2], sharey=ax1)\n",
|
||
|
"\n",
|
||
|
"prestorm_color = '#fdae61'\n",
|
||
|
"poststorm_color = '#d53e4f'\n",
|
||
|
"scatter_marker_size=12\n",
|
||
|
"scatter_line_width = 0.6\n",
|
||
|
"plots = [\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax1,\n",
|
||
|
" 'title': 'Swash regime',\n",
|
||
|
" 'site_id': 'GRANTSn0009',\n",
|
||
|
" 'x_min_fill': 150,\n",
|
||
|
" 'location': 'Grants\\nBeach',\n",
|
||
|
" 'subplot_letter': '(a)',\n",
|
||
|
" 'xlim_left' : 50,\n",
|
||
|
" },\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax2,\n",
|
||
|
" 'title': 'Collision regime',\n",
|
||
|
" 'site_id': 'MANNING0078',\n",
|
||
|
" 'x_min_fill': 150,\n",
|
||
|
" 'location': 'Manning\\nPoint',\n",
|
||
|
" 'subplot_letter': '(b)',\n",
|
||
|
" 'xlim_left' : 100,\n",
|
||
|
" },\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax3,\n",
|
||
|
" 'title': 'Overwash regime',\n",
|
||
|
" 'site_id': 'AVOCAs0001',\n",
|
||
|
" 'x_min_fill': 80,\n",
|
||
|
" 'location': 'Avoca Lagoon\\nEntrance',\n",
|
||
|
" 'subplot_letter': '(c)',\n",
|
||
|
" 'xlim_left' : 50,\n",
|
||
|
" },\n",
|
||
|
"]\n",
|
||
|
"\n",
|
||
|
"for plot in plots:\n",
|
||
|
" ax = plot['ax']\n",
|
||
|
" site_id = plot['site_id']\n",
|
||
|
" df_pro_pre = df_profiles.xs((site_id, 'prestorm'),\n",
|
||
|
" level=['site_id', 'profile_type'])\n",
|
||
|
" df_pro_post = df_profiles.xs((site_id, 'poststorm'),\n",
|
||
|
" level=['site_id', 'profile_type'])\n",
|
||
|
" df_feat_pre = df_profile_features_crest_toes.xs(\n",
|
||
|
" (site_id, 'prestorm'), level=['site_id', 'profile_type'])\n",
|
||
|
" df_feat_post = df_profile_features_crest_toes.xs(\n",
|
||
|
" (site_id, 'poststorm'), level=['site_id', 'profile_type'])\n",
|
||
|
"\n",
|
||
|
" ax.plot(\n",
|
||
|
" df_pro_post.index.get_level_values('x'),\n",
|
||
|
" df_pro_post.z.values,\n",
|
||
|
" label='Poststorm profile',\n",
|
||
|
" color=poststorm_color,\n",
|
||
|
" linestyle='--')\n",
|
||
|
" ax.plot(\n",
|
||
|
" df_pro_pre.index.get_level_values('x'),\n",
|
||
|
" df_pro_pre.z.values,\n",
|
||
|
" label='Prestorm profile',\n",
|
||
|
" color=prestorm_color)\n",
|
||
|
" ax.scatter(\n",
|
||
|
" df_feat_post.dune_crest_x,\n",
|
||
|
" df_feat_post.dune_crest_z,\n",
|
||
|
" scatter_marker_size,\n",
|
||
|
" label='Poststorm dune crest',\n",
|
||
|
" facecolor=poststorm_color,\n",
|
||
|
" edgecolor='black',\n",
|
||
|
" linewidth=scatter_line_width,\n",
|
||
|
" marker='v',\n",
|
||
|
" zorder=3)\n",
|
||
|
" ax.scatter(\n",
|
||
|
" df_feat_pre.dune_crest_x,\n",
|
||
|
" df_feat_pre.dune_crest_z,\n",
|
||
|
" scatter_marker_size,\n",
|
||
|
" label='Prestorm dune crest',\n",
|
||
|
" facecolor=prestorm_color,\n",
|
||
|
" edgecolor='black',\n",
|
||
|
" linewidth=scatter_line_width,\n",
|
||
|
" marker='v',\n",
|
||
|
" zorder=3)\n",
|
||
|
"\n",
|
||
|
" if not np.isnan(df_feat_post.dune_toe_x.values[0]):\n",
|
||
|
" ax.scatter(\n",
|
||
|
" df_feat_post.dune_toe_x,\n",
|
||
|
" df_feat_post.dune_toe_z,\n",
|
||
|
" scatter_marker_size,\n",
|
||
|
" label='Poststorm dune toe',\n",
|
||
|
" facecolor=poststorm_color,\n",
|
||
|
" edgecolor='black',\n",
|
||
|
" linewidth=scatter_line_width,\n",
|
||
|
" marker='^',\n",
|
||
|
" zorder=3)\n",
|
||
|
"\n",
|
||
|
" if not np.isnan(df_feat_pre.dune_toe_x.values[0]):\n",
|
||
|
" ax.scatter(\n",
|
||
|
" df_feat_pre.dune_toe_x,\n",
|
||
|
" df_feat_pre.dune_toe_z,\n",
|
||
|
" scatter_marker_size,\n",
|
||
|
" label='Prestorm dune toe',\n",
|
||
|
" facecolor=prestorm_color,\n",
|
||
|
" edgecolor='black',\n",
|
||
|
" linewidth=scatter_line_width,\n",
|
||
|
" marker='^',\n",
|
||
|
" zorder=3)\n",
|
||
|
"\n",
|
||
|
" # Fill to zero elevation if there is no post profile value\n",
|
||
|
" z_post = df_pro_post.z.values\n",
|
||
|
" z_post[np.isnan(z_post)] = 0\n",
|
||
|
"\n",
|
||
|
" # Only want to fill the difference between pre/post past a certain x-val\n",
|
||
|
" mask = df_pro_post.index.get_level_values('x') > plot['x_min_fill']\n",
|
||
|
"\n",
|
||
|
" ax.fill_between(\n",
|
||
|
" df_pro_post.index.get_level_values('x')[mask],\n",
|
||
|
" df_pro_pre.z.values[mask],\n",
|
||
|
" z_post[mask],\n",
|
||
|
" color='#f46d43',\n",
|
||
|
" label='Eroded volume',\n",
|
||
|
" alpha=0.4)\n",
|
||
|
"\n",
|
||
|
" # Set lims\n",
|
||
|
" ax.set_ylim([0, 10])\n",
|
||
|
" ax.set_xlim(left=plot['xlim_left'])\n",
|
||
|
"\n",
|
||
|
" # Set ticks to 50 m\n",
|
||
|
" ax.xaxis.set_major_locator(ticker.MultipleLocator(50))\n",
|
||
|
" \n",
|
||
|
" # Change tick label size\n",
|
||
|
" ax.tick_params(axis='both', which='major', labelsize=6)\n",
|
||
|
"\n",
|
||
|
" # Add titles showing regimes\n",
|
||
|
" ax.set_title(plot['title'], size=6)\n",
|
||
|
"\n",
|
||
|
" # Add subplot letters\n",
|
||
|
" ax.text(\n",
|
||
|
" 0.05,\n",
|
||
|
" 0.90,\n",
|
||
|
" plot['subplot_letter'],\n",
|
||
|
" transform=ax.transAxes,\n",
|
||
|
" size=6,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.9,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
" # Add text showing location\n",
|
||
|
" ax.text(\n",
|
||
|
" 0.95,\n",
|
||
|
" 0.95,\n",
|
||
|
" plot['location'],\n",
|
||
|
" transform=ax.transAxes,\n",
|
||
|
" size=5,\n",
|
||
|
" horizontalalignment='right',\n",
|
||
|
" verticalalignment='top',\n",
|
||
|
" zorder=3,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.9,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"# Remove tick parameters from shared axis\n",
|
||
|
"ax2.tick_params(labelleft=False)\n",
|
||
|
"ax3.tick_params(labelleft=False)\n",
|
||
|
"\n",
|
||
|
"# Add y-label\n",
|
||
|
"ax1.set_ylabel('Elevation (mAHD)', size=8)\n",
|
||
|
"\n",
|
||
|
"# Add common x-label\n",
|
||
|
"fig.text(\n",
|
||
|
" 0.5,\n",
|
||
|
" -0.04,\n",
|
||
|
" 'Cross-shore position (m)',\n",
|
||
|
" ha='center',\n",
|
||
|
" size=8,\n",
|
||
|
" horizontalalignment='center',\n",
|
||
|
" verticalalignment='top')\n",
|
||
|
"\n",
|
||
|
"plt.tight_layout(pad=0.1,w_pad=0.1,h_pad=0.1)\n",
|
||
|
"\n",
|
||
|
"# Add legend\n",
|
||
|
"ax1.legend(\n",
|
||
|
" prop={'size': 4},\n",
|
||
|
" ncol=2,\n",
|
||
|
" bbox_to_anchor=(1.0, 1.05),\n",
|
||
|
" loc=\"lower right\",\n",
|
||
|
" bbox_transform=fig.transFigure)\n",
|
||
|
"\n",
|
||
|
"# Add title\n",
|
||
|
"fig.text(\n",
|
||
|
"0.01,1.1,\n",
|
||
|
"'Examples of observed\\nstorm regimes',\n",
|
||
|
"horizontalalignment='left',\n",
|
||
|
"verticalalignment='bottom',\n",
|
||
|
"size=8)\n",
|
||
|
"\n",
|
||
|
"# Adjust width of border\n",
|
||
|
"for axis in ['top','bottom','left','right']:\n",
|
||
|
" ax1.spines[axis].set_linewidth(0.7)\n",
|
||
|
" ax2.spines[axis].set_linewidth(0.7)\n",
|
||
|
" ax3.spines[axis].set_linewidth(0.7)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"fig.savefig('12_c&p_observed_storm_impacts.png',dpi=600, bbox_inches = \"tight\")\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Swash zone volume change histogram\n",
|
||
|
"How much does the beach width change variation can we expect in the swash regime?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"impacts['observed'][impacts['observed'].storm_regime=='swash'].width_msl_change_pct.sort_values(ascending=False)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"code_folding": []
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import matplotlib.ticker as ticker\n",
|
||
|
"\n",
|
||
|
"# Setup grid\n",
|
||
|
"fig = plt.figure(figsize=(6, 3), dpi=300)\n",
|
||
|
"gs = gridspec.GridSpec(2, 3)\n",
|
||
|
"ax1 = fig.add_subplot(gs[0:2, 0:2])\n",
|
||
|
"ax2 = fig.add_subplot(gs[0, 2])\n",
|
||
|
"ax3 = fig.add_subplot(gs[1, 2], sharex=ax2)\n",
|
||
|
"\n",
|
||
|
"# Histogram\n",
|
||
|
"ax1.hist(\n",
|
||
|
" impacts['observed'][impacts['observed'].storm_regime=='swash'].width_msl_change_pct \n",
|
||
|
")\n",
|
||
|
"\n",
|
||
|
"# Format axes, ticks and labels\n",
|
||
|
"ax1.set_xlabel('$\\Delta$ beach width', size=8)\n",
|
||
|
"ax1.set_ylabel('Count', size=8)\n",
|
||
|
"ax1.xaxis.set_major_locator(ticker.MultipleLocator(25))\n",
|
||
|
"ax1.xaxis.set_major_formatter(ticker.PercentFormatter())\n",
|
||
|
"ax1.tick_params(axis='both', which='major', labelsize=7)\n",
|
||
|
"\n",
|
||
|
"# Show erosion and accretion regions\n",
|
||
|
"ax1.autoscale(False)\n",
|
||
|
"ax1.fill([-100,0,0,-100], [0,0,500,500], '#f46d43', alpha=0.2,zorder=0)\n",
|
||
|
"ax1.fill([100,0,0,100], [0,0,500,500], '#abdda4', alpha=0.2,zorder=0)\n",
|
||
|
"\n",
|
||
|
"ax1.text(\n",
|
||
|
" 0.95,\n",
|
||
|
" 0.95,\n",
|
||
|
" 'Accretion',\n",
|
||
|
" transform=ax1.transAxes,\n",
|
||
|
" size=8,\n",
|
||
|
" horizontalalignment='right',\n",
|
||
|
" verticalalignment='top',\n",
|
||
|
" zorder=3,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.0,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"ax1.text(\n",
|
||
|
" 0.05,\n",
|
||
|
" 0.95,\n",
|
||
|
" 'Erosion',\n",
|
||
|
" transform=ax1.transAxes,\n",
|
||
|
" size=8,\n",
|
||
|
" horizontalalignment='left',\n",
|
||
|
" verticalalignment='top',\n",
|
||
|
" zorder=3,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.0,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"# Add subplot letters\n",
|
||
|
"ax1.text(\n",
|
||
|
" 0.93,\n",
|
||
|
" 0.05,\n",
|
||
|
" '(a)',\n",
|
||
|
" transform=ax1.transAxes,\n",
|
||
|
" size=10,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.0,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"# Profile subplots\n",
|
||
|
"prestorm_color = '#fdae61'\n",
|
||
|
"poststorm_color = '#d53e4f'\n",
|
||
|
"\n",
|
||
|
"plots = [\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax2,\n",
|
||
|
" 'title': '$\\Delta$ beach width = $+83\\%$',\n",
|
||
|
" 'site_id': 'MANNING0125',\n",
|
||
|
" 'x_min_fill': 150,\n",
|
||
|
" 'location': 'Grants\\nBeach',\n",
|
||
|
" 'subplot_letter': '(b)',\n",
|
||
|
" 'xlim_left' : 50,\n",
|
||
|
" },\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax3,\n",
|
||
|
" 'title': '$\\Delta$ beach width = $-73\\%$',\n",
|
||
|
" 'site_id': 'DIAMONDn0024',\n",
|
||
|
" 'x_min_fill': 150,\n",
|
||
|
" 'location': 'Manning\\nPoint',\n",
|
||
|
" 'subplot_letter': '(c)',\n",
|
||
|
" 'xlim_left' : 100,\n",
|
||
|
" },\n",
|
||
|
"]\n",
|
||
|
"\n",
|
||
|
"for plot in plots:\n",
|
||
|
" \n",
|
||
|
" ax = plot['ax']\n",
|
||
|
" site_id = plot['site_id']\n",
|
||
|
" df_pro_pre = df_profiles.xs((site_id, 'prestorm'),\n",
|
||
|
" level=['site_id', 'profile_type'])\n",
|
||
|
" df_pro_post = df_profiles.xs((site_id, 'poststorm'),\n",
|
||
|
" level=['site_id', 'profile_type'])\n",
|
||
|
" \n",
|
||
|
" ax.plot(\n",
|
||
|
" df_pro_post.index.get_level_values('x'),\n",
|
||
|
" df_pro_post.z.values,\n",
|
||
|
" label='Poststorm profile',\n",
|
||
|
" color=poststorm_color,\n",
|
||
|
" linestyle='--')\n",
|
||
|
" ax.plot(\n",
|
||
|
" df_pro_pre.index.get_level_values('x'),\n",
|
||
|
" df_pro_pre.z.values,\n",
|
||
|
" label='Prestorm profile',\n",
|
||
|
" color=prestorm_color)\n",
|
||
|
" \n",
|
||
|
" if ax == ax2:\n",
|
||
|
" z_pre = df_pro_pre.z.values\n",
|
||
|
" z_pre[np.isnan(z_pre)] = 0\n",
|
||
|
" \n",
|
||
|
" # Only want to fill the difference between pre/post past a certain x-val\n",
|
||
|
" mask = df_pro_pre.index.get_level_values('x') > plot['x_min_fill']\n",
|
||
|
" \n",
|
||
|
" ax.fill_between(\n",
|
||
|
" df_pro_post.index.get_level_values('x')[mask],\n",
|
||
|
" df_pro_post.z.values[mask],\n",
|
||
|
" z_pre[mask],\n",
|
||
|
" color='#abdda4',\n",
|
||
|
" label='Accreted volume',\n",
|
||
|
" alpha=0.4)\n",
|
||
|
" \n",
|
||
|
" \n",
|
||
|
" if ax == ax3:\n",
|
||
|
" # Fill to zero elevation if there is no post profile value\n",
|
||
|
" z_post = df_pro_post.z.values\n",
|
||
|
" z_post[np.isnan(z_post)] = 0\n",
|
||
|
"\n",
|
||
|
" # Only want to fill the difference between pre/post past a certain x-val\n",
|
||
|
" mask = df_pro_post.index.get_level_values('x') > plot['x_min_fill']\n",
|
||
|
"\n",
|
||
|
" ax.fill_between(\n",
|
||
|
" df_pro_post.index.get_level_values('x')[mask],\n",
|
||
|
" df_pro_pre.z.values[mask],\n",
|
||
|
" z_post[mask],\n",
|
||
|
" color='#f46d43',\n",
|
||
|
" label='Eroded volume',\n",
|
||
|
" alpha=0.4)\n",
|
||
|
" \n",
|
||
|
" # Add dummy legend entry\n",
|
||
|
" ax.fill_between(\n",
|
||
|
" [0,1],\n",
|
||
|
" [0,0],\n",
|
||
|
" [0,0],\n",
|
||
|
" color='#abdda4',\n",
|
||
|
" label='Accreted volume',\n",
|
||
|
" alpha=0.4)\n",
|
||
|
" \n",
|
||
|
" # Set lims\n",
|
||
|
" ax.set_ylim([0, 12])\n",
|
||
|
" ax.set_xlim(left=plot['xlim_left'])\n",
|
||
|
"\n",
|
||
|
" # Set ticks to 50 m\n",
|
||
|
" ax.xaxis.set_major_locator(ticker.MultipleLocator(50))\n",
|
||
|
" \n",
|
||
|
" # Change tick label size\n",
|
||
|
" ax.tick_params(axis='both', which='major', labelsize=7)\n",
|
||
|
"\n",
|
||
|
" # Add titles showing regimes\n",
|
||
|
" ax.set_title(plot['title'], size=8)\n",
|
||
|
" \n",
|
||
|
" # Add subplot letters\n",
|
||
|
" ax.text(\n",
|
||
|
" 0.04,\n",
|
||
|
" 0.08,\n",
|
||
|
" plot['subplot_letter'],\n",
|
||
|
" transform=ax.transAxes,\n",
|
||
|
" size=10,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.9,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
" \n",
|
||
|
"# Remove tick parameters from shared axis\n",
|
||
|
"ax2.tick_params(labelbottom=False)\n",
|
||
|
"\n",
|
||
|
"# Axis labels\n",
|
||
|
"ax3.set_xlabel('Cross-shore position (m)', size=8)\n",
|
||
|
"\n",
|
||
|
"# Change y-axis to right hand side\n",
|
||
|
"ax2.yaxis.tick_right()\n",
|
||
|
"ax3.yaxis.tick_right()\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"# Add common x-label\n",
|
||
|
"fig.text(\n",
|
||
|
" 0.98,\n",
|
||
|
" 0.5,\n",
|
||
|
" 'Elevation (mAHD)',\n",
|
||
|
" ha='center',\n",
|
||
|
" size=8,\n",
|
||
|
" horizontalalignment='center',\n",
|
||
|
" verticalalignment='center',\n",
|
||
|
" rotation=90)\n",
|
||
|
"\n",
|
||
|
"# Needs to be called before legend\n",
|
||
|
"fig.tight_layout()\n",
|
||
|
"\n",
|
||
|
"# Add legend\n",
|
||
|
"ax3.legend(\n",
|
||
|
" prop={'size': 6},\n",
|
||
|
" ncol=2,\n",
|
||
|
" bbox_to_anchor=(1.0, 0.97),\n",
|
||
|
" loc=\"lower right\",\n",
|
||
|
" bbox_transform=fig.transFigure\n",
|
||
|
")\n",
|
||
|
"\n",
|
||
|
"# Add title\n",
|
||
|
"fig.text(\n",
|
||
|
"0.06,1.00,\n",
|
||
|
"'Variation in volume change for swash regime profiles',\n",
|
||
|
"horizontalalignment='left',\n",
|
||
|
"verticalalignment='bottom',\n",
|
||
|
"size=10)\n",
|
||
|
"\n",
|
||
|
"fig.savefig('12_var_vol_change_swash_regime.png',dpi=300, bbox_inches = \"tight\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"code_folding": [
|
||
|
43
|
||
|
]
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# For Coasts and Ports\n",
|
||
|
"\n",
|
||
|
"import matplotlib.ticker as ticker\n",
|
||
|
"\n",
|
||
|
"# Setup grid\n",
|
||
|
"fig = plt.figure(figsize=(3, 1.5), dpi=300)\n",
|
||
|
"gs = gridspec.GridSpec(2, 3)\n",
|
||
|
"ax1 = fig.add_subplot(gs[0:2, 0:2])\n",
|
||
|
"ax2 = fig.add_subplot(gs[0, 2])\n",
|
||
|
"ax3 = fig.add_subplot(gs[1, 2], sharex=ax2)\n",
|
||
|
"\n",
|
||
|
"# Histogram\n",
|
||
|
"ax1.hist(\n",
|
||
|
" impacts['observed'][impacts['observed'].storm_regime ==\n",
|
||
|
" 'swash'].width_msl_change_pct\n",
|
||
|
")\n",
|
||
|
"\n",
|
||
|
"# Format axes, ticks and labels\n",
|
||
|
"ax1.set_xlabel('$\\Delta$ beach width', size=6)\n",
|
||
|
"ax1.set_ylabel('Count', size=6)\n",
|
||
|
"ax1.xaxis.set_major_locator(ticker.MultipleLocator(50))\n",
|
||
|
"ax1.xaxis.set_major_formatter(ticker.PercentFormatter())\n",
|
||
|
"ax1.tick_params(axis='both', which='major', labelsize=6)\n",
|
||
|
"\n",
|
||
|
"# Show erosion and accretion regions\n",
|
||
|
"ax1.autoscale(False)\n",
|
||
|
"ax1.fill([-100, 0, 0, -100], [0, 0, 500, 500], '#f46d43', alpha=0.2, zorder=0)\n",
|
||
|
"ax1.fill([100, 0, 0, 100], [0, 0, 500, 500], '#abdda4', alpha=0.2, zorder=0)\n",
|
||
|
"\n",
|
||
|
"ax1.text(\n",
|
||
|
" 0.95,\n",
|
||
|
" 0.95,\n",
|
||
|
" 'Accretion',\n",
|
||
|
" transform=ax1.transAxes,\n",
|
||
|
" size=6,\n",
|
||
|
" horizontalalignment='right',\n",
|
||
|
" verticalalignment='top',\n",
|
||
|
" zorder=3,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.0,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"ax1.text(\n",
|
||
|
" 0.05,\n",
|
||
|
" 0.95,\n",
|
||
|
" 'Erosion',\n",
|
||
|
" transform=ax1.transAxes,\n",
|
||
|
" size=6,\n",
|
||
|
" horizontalalignment='left',\n",
|
||
|
" verticalalignment='top',\n",
|
||
|
" zorder=3,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.0,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"# Add subplot letters\n",
|
||
|
"ax1.text(\n",
|
||
|
" 0.90,\n",
|
||
|
" 0.04,\n",
|
||
|
" '(a)',\n",
|
||
|
" transform=ax1.transAxes,\n",
|
||
|
" size=8,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.0,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"# Profile subplots\n",
|
||
|
"prestorm_color = '#fdae61'\n",
|
||
|
"poststorm_color = '#d53e4f'\n",
|
||
|
"\n",
|
||
|
"plots = [\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax2,\n",
|
||
|
" 'title': '$\\Delta$ beach width = $+83\\%$',\n",
|
||
|
" 'site_id': 'MANNING0125',\n",
|
||
|
" 'x_min_fill': 150,\n",
|
||
|
" 'location': 'Grants\\nBeach',\n",
|
||
|
" 'subplot_letter': '(b)',\n",
|
||
|
" 'xlim_left': 50,\n",
|
||
|
" },\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax3,\n",
|
||
|
" 'title': '$\\Delta$ beach width = $-73\\%$',\n",
|
||
|
" 'site_id': 'DIAMONDn0024',\n",
|
||
|
" 'x_min_fill': 150,\n",
|
||
|
" 'location': 'Manning\\nPoint',\n",
|
||
|
" 'subplot_letter': '(c)',\n",
|
||
|
" 'xlim_left': 100,\n",
|
||
|
" },\n",
|
||
|
"]\n",
|
||
|
"\n",
|
||
|
"for plot in plots:\n",
|
||
|
"\n",
|
||
|
" ax = plot['ax']\n",
|
||
|
" site_id = plot['site_id']\n",
|
||
|
" df_pro_pre = df_profiles.xs((site_id, 'prestorm'),\n",
|
||
|
" level=['site_id', 'profile_type'])\n",
|
||
|
" df_pro_post = df_profiles.xs((site_id, 'poststorm'),\n",
|
||
|
" level=['site_id', 'profile_type'])\n",
|
||
|
"\n",
|
||
|
" ax.plot(\n",
|
||
|
" df_pro_post.index.get_level_values('x'),\n",
|
||
|
" df_pro_post.z.values,\n",
|
||
|
" label='Poststorm profile',\n",
|
||
|
" color=poststorm_color,\n",
|
||
|
" linestyle='--',\n",
|
||
|
" lw=1)\n",
|
||
|
" ax.plot(\n",
|
||
|
" df_pro_pre.index.get_level_values('x'),\n",
|
||
|
" df_pro_pre.z.values,\n",
|
||
|
" label='Prestorm profile',\n",
|
||
|
" color=prestorm_color,\n",
|
||
|
" lw=1)\n",
|
||
|
"\n",
|
||
|
" if ax == ax2:\n",
|
||
|
" z_pre = df_pro_pre.z.values\n",
|
||
|
" z_pre[np.isnan(z_pre)] = 0\n",
|
||
|
"\n",
|
||
|
" # Only want to fill the difference between pre/post past a certain x-val\n",
|
||
|
" mask = df_pro_pre.index.get_level_values('x') > plot['x_min_fill']\n",
|
||
|
"\n",
|
||
|
" ax.fill_between(\n",
|
||
|
" df_pro_post.index.get_level_values('x')[mask],\n",
|
||
|
" df_pro_post.z.values[mask],\n",
|
||
|
" z_pre[mask],\n",
|
||
|
" color='#abdda4',\n",
|
||
|
" label='Accreted volume',\n",
|
||
|
" alpha=0.4)\n",
|
||
|
"\n",
|
||
|
" if ax == ax3:\n",
|
||
|
" # Fill to zero elevation if there is no post profile value\n",
|
||
|
" z_post = df_pro_post.z.values\n",
|
||
|
" z_post[np.isnan(z_post)] = 0\n",
|
||
|
"\n",
|
||
|
" # Only want to fill the difference between pre/post past a certain x-val\n",
|
||
|
" mask = df_pro_post.index.get_level_values('x') > plot['x_min_fill']\n",
|
||
|
"\n",
|
||
|
" ax.fill_between(\n",
|
||
|
" df_pro_post.index.get_level_values('x')[mask],\n",
|
||
|
" df_pro_pre.z.values[mask],\n",
|
||
|
" z_post[mask],\n",
|
||
|
" color='#f46d43',\n",
|
||
|
" label='Eroded volume',\n",
|
||
|
" alpha=0.4)\n",
|
||
|
"\n",
|
||
|
" # Add dummy legend entry\n",
|
||
|
" ax.fill_between(\n",
|
||
|
" [0, 1],\n",
|
||
|
" [0, 0],\n",
|
||
|
" [0, 0],\n",
|
||
|
" color='#abdda4',\n",
|
||
|
" label='Accreted volume',\n",
|
||
|
" alpha=0.4)\n",
|
||
|
"\n",
|
||
|
" # Set lims\n",
|
||
|
" ax.set_ylim([0, 12])\n",
|
||
|
" ax.set_xlim(left=plot['xlim_left'])\n",
|
||
|
"\n",
|
||
|
" # Set ticks to 50 m\n",
|
||
|
" ax.xaxis.set_major_locator(ticker.MultipleLocator(50))\n",
|
||
|
" ax.yaxis.set_major_locator(ticker.MultipleLocator(5))\n",
|
||
|
"\n",
|
||
|
" # Change tick label size\n",
|
||
|
" ax.tick_params(axis='both', which='major', labelsize=6)\n",
|
||
|
"\n",
|
||
|
" # Add titles showing regimes\n",
|
||
|
" ax.set_title(plot['title'], size=5)\n",
|
||
|
"\n",
|
||
|
" # Add subplot letters\n",
|
||
|
" ax.text(\n",
|
||
|
" 0.04,\n",
|
||
|
" 0.15,\n",
|
||
|
" plot['subplot_letter'],\n",
|
||
|
" transform=ax.transAxes,\n",
|
||
|
" size=8,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.9,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"# Remove tick parameters from shared axis\n",
|
||
|
"ax2.tick_params(labelbottom=False)\n",
|
||
|
"\n",
|
||
|
"# Remove tick lines but keep labels\n",
|
||
|
"ax2.tick_params(axis='y', which='both', length=0)\n",
|
||
|
"ax3.tick_params(axis='y', which='both', length=0)\n",
|
||
|
"\n",
|
||
|
"# Axis labels\n",
|
||
|
"ax3.set_xlabel('Cross-shore position (m)', size=6)\n",
|
||
|
"\n",
|
||
|
"# Change y-axis to right hand side\n",
|
||
|
"ax2.yaxis.tick_right()\n",
|
||
|
"ax3.yaxis.tick_right()\n",
|
||
|
"\n",
|
||
|
"# Pad tick parameter labels\n",
|
||
|
"ax1.xaxis.set_tick_params(pad=-3)\n",
|
||
|
"ax2.xaxis.set_tick_params(pad=-3)\n",
|
||
|
"ax3.xaxis.set_tick_params(pad=-3)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"# Add common x-label\n",
|
||
|
"fig.text(\n",
|
||
|
" 1.75,\n",
|
||
|
" 0.5,\n",
|
||
|
" 'Elevation (mAHD)',\n",
|
||
|
" size=6,\n",
|
||
|
" horizontalalignment='center',\n",
|
||
|
" verticalalignment='center',\n",
|
||
|
" rotation=90,\n",
|
||
|
" transform=ax1.transAxes)\n",
|
||
|
"\n",
|
||
|
"# Needs to be called before legend\n",
|
||
|
"fig.tight_layout(pad=0.5, h_pad=0.1, w_pad=0.2)\n",
|
||
|
"\n",
|
||
|
"# Add legend\n",
|
||
|
"ax3.legend(\n",
|
||
|
" prop={'size': 4.5},\n",
|
||
|
" ncol=2,\n",
|
||
|
" bbox_to_anchor=(1.0, 0.97),\n",
|
||
|
" loc=\"lower right\",\n",
|
||
|
" bbox_transform=fig.transFigure\n",
|
||
|
")\n",
|
||
|
"\n",
|
||
|
"# Add title\n",
|
||
|
"fig.text(\n",
|
||
|
" 0.06, 1.14,\n",
|
||
|
" 'Variation in volume change\\nfor swash regime profiles',\n",
|
||
|
" horizontalalignment='left',\n",
|
||
|
" verticalalignment='top',\n",
|
||
|
" size=8)\n",
|
||
|
"\n",
|
||
|
"# Adjust width of border\n",
|
||
|
"for axis in ['top', 'bottom', 'left', 'right']:\n",
|
||
|
" ax1.spines[axis].set_linewidth(0.7)\n",
|
||
|
" ax2.spines[axis].set_linewidth(0.7)\n",
|
||
|
" ax3.spines[axis].set_linewidth(0.7)\n",
|
||
|
" ax2.yaxis.set_tick_params(width=0.7)\n",
|
||
|
" ax3.yaxis.set_tick_params(width=0.7)\n",
|
||
|
"\n",
|
||
|
"fig.savefig('12_c&p_var_vol_change_swash_regime.png',\n",
|
||
|
" dpi=600, bbox_inches=\"tight\", pad_inches=0.01)\n",
|
||
|
"# fig.savefig('12_c&p_var_vol_change_swash_regime.svg',bbox_inches = \"tight\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Narrabeen section plots"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"code_folding": []
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import matplotlib.gridspec as gridspec\n",
|
||
|
"import matplotlib.ticker as ticker\n",
|
||
|
"\n",
|
||
|
"# Setup grid\n",
|
||
|
"fig = plt.figure(figsize=(3, 5), dpi=150)\n",
|
||
|
"gs = gridspec.GridSpec(3, 1)\n",
|
||
|
"ax1 = fig.add_subplot(gs[0, 0])\n",
|
||
|
"ax2 = fig.add_subplot(gs[1, 0], sharex=ax1)\n",
|
||
|
"ax3 = fig.add_subplot(gs[2, 0], sharex=ax1)\n",
|
||
|
"\n",
|
||
|
"prestorm_color = '#fdae61'\n",
|
||
|
"poststorm_color = '#d53e4f'\n",
|
||
|
"\n",
|
||
|
"plots = [\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax1,\n",
|
||
|
" 'title': '$\\Delta$ Dune Vol = \\SI{-13}{\\m^{3}\\per\\m}',\n",
|
||
|
" 'site_id': 'NARRA0005',\n",
|
||
|
" 'x_min_fill': 150,\n",
|
||
|
" 'location': 'Grants\\nBeach',\n",
|
||
|
" 'subplot_letter': '(a)',\n",
|
||
|
" 'xlim_left' : 150,\n",
|
||
|
" },\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax2,\n",
|
||
|
" 'title': '$\\Delta$ Dune Vol = \\SI{-10}{\\m^{3}\\per\\m}',\n",
|
||
|
" 'site_id': 'NARRA0026',\n",
|
||
|
" 'x_min_fill': 150,\n",
|
||
|
" 'location': 'Manning\\nPoint',\n",
|
||
|
" 'subplot_letter': '(b)',\n",
|
||
|
" 'xlim_left' : 150,\n",
|
||
|
" },\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax3,\n",
|
||
|
" 'title': '$\\Delta$ Dune Vol = \\SI{-21}{\\m^{3}\\per\\m}',\n",
|
||
|
" 'site_id': 'NARRA0028',\n",
|
||
|
" 'x_min_fill': 190,\n",
|
||
|
" 'location': 'Avoca Lagoon\\nEntrance',\n",
|
||
|
" 'subplot_letter': '(c)',\n",
|
||
|
" 'xlim_left' : 150,\n",
|
||
|
" },\n",
|
||
|
"]\n",
|
||
|
"\n",
|
||
|
"for plot in plots:\n",
|
||
|
" ax = plot['ax']\n",
|
||
|
" site_id = plot['site_id']\n",
|
||
|
" df_pro_pre = df_profiles.xs((site_id, 'prestorm'),\n",
|
||
|
" level=['site_id', 'profile_type'])\n",
|
||
|
" df_pro_post = df_profiles.xs((site_id, 'poststorm'),\n",
|
||
|
" level=['site_id', 'profile_type'])\n",
|
||
|
" df_feat_pre = df_profile_features_crest_toes.xs(\n",
|
||
|
" (site_id, 'prestorm'), level=['site_id', 'profile_type'])\n",
|
||
|
" df_feat_post = df_profile_features_crest_toes.xs(\n",
|
||
|
" (site_id, 'poststorm'), level=['site_id', 'profile_type'])\n",
|
||
|
"\n",
|
||
|
" ax.plot(\n",
|
||
|
" df_pro_post.index.get_level_values('x'),\n",
|
||
|
" df_pro_post.z.values,\n",
|
||
|
" label='Poststorm profile',\n",
|
||
|
" color=poststorm_color,\n",
|
||
|
" linestyle='--')\n",
|
||
|
" ax.plot(\n",
|
||
|
" df_pro_pre.index.get_level_values('x'),\n",
|
||
|
" df_pro_pre.z.values,\n",
|
||
|
" label='Prestorm profile',\n",
|
||
|
" color=prestorm_color)\n",
|
||
|
"# ax.scatter(\n",
|
||
|
"# df_feat_post.dune_crest_x,\n",
|
||
|
"# df_feat_post.dune_crest_z,\n",
|
||
|
"# label='Poststorm dune crest',\n",
|
||
|
"# facecolor=poststorm_color,\n",
|
||
|
"# edgecolor='black',\n",
|
||
|
"# linewidth='0.75',\n",
|
||
|
"# marker='v',\n",
|
||
|
"# zorder=3)\n",
|
||
|
"# ax.scatter(\n",
|
||
|
"# df_feat_pre.dune_crest_x,\n",
|
||
|
"# df_feat_pre.dune_crest_z,\n",
|
||
|
"# label='Prestorm dune crest',\n",
|
||
|
"# facecolor=prestorm_color,\n",
|
||
|
"# edgecolor='black',\n",
|
||
|
"# linewidth='0.75',\n",
|
||
|
"# marker='v',\n",
|
||
|
"# zorder=3)\n",
|
||
|
"\n",
|
||
|
"# if not np.isnan(df_feat_post.dune_toe_x.values[0]):\n",
|
||
|
"# ax.scatter(\n",
|
||
|
"# df_feat_post.dune_toe_x,\n",
|
||
|
"# df_feat_post.dune_toe_z,\n",
|
||
|
"# label='Poststorm dune toe',\n",
|
||
|
"# facecolor=poststorm_color,\n",
|
||
|
"# edgecolor='black',\n",
|
||
|
"# linewidth='0.75',\n",
|
||
|
"# marker='^',\n",
|
||
|
"# zorder=3)\n",
|
||
|
"\n",
|
||
|
"# if not np.isnan(df_feat_pre.dune_toe_x.values[0]):\n",
|
||
|
"# ax.scatter(\n",
|
||
|
"# df_feat_pre.dune_toe_x,\n",
|
||
|
"# df_feat_pre.dune_toe_z,\n",
|
||
|
"# label='Prestorm dune toe',\n",
|
||
|
"# facecolor=prestorm_color,\n",
|
||
|
"# edgecolor='black',\n",
|
||
|
"# linewidth='0.75',\n",
|
||
|
"# marker='^',\n",
|
||
|
"# zorder=3)\n",
|
||
|
"\n",
|
||
|
" # Fill to zero elevation if there is no post profile value\n",
|
||
|
" z_post = df_pro_post.z.values\n",
|
||
|
" z_post[np.isnan(z_post)] = 0\n",
|
||
|
"\n",
|
||
|
" # Only want to fill the difference between pre/post past a certain x-val\n",
|
||
|
" mask = df_pro_post.index.get_level_values('x') > plot['x_min_fill']\n",
|
||
|
"\n",
|
||
|
" ax.fill_between(\n",
|
||
|
" df_pro_post.index.get_level_values('x')[mask],\n",
|
||
|
" df_pro_pre.z.values[mask],\n",
|
||
|
" z_post[mask],\n",
|
||
|
" color='#f46d43',\n",
|
||
|
" label='Eroded volume',\n",
|
||
|
" alpha=0.4)\n",
|
||
|
"\n",
|
||
|
" # Set lims\n",
|
||
|
" ax.set_ylim([0, 14])\n",
|
||
|
" ax.set_xlim(left=plot['xlim_left'])\n",
|
||
|
"\n",
|
||
|
" # Set ticks to 50 m\n",
|
||
|
" ax.xaxis.set_major_locator(ticker.MultipleLocator(50))\n",
|
||
|
" \n",
|
||
|
" # Change tick label size\n",
|
||
|
" ax.tick_params(axis='both', which='major', labelsize=7)\n",
|
||
|
"\n",
|
||
|
" # Add titles showing regimes\n",
|
||
|
" ax.set_title(plot['title'], size=8)\n",
|
||
|
"\n",
|
||
|
" # Add subplot letters\n",
|
||
|
" ax.text(\n",
|
||
|
" 0.02,\n",
|
||
|
" 0.05,\n",
|
||
|
" plot['subplot_letter'],\n",
|
||
|
" transform=ax.transAxes,\n",
|
||
|
" size=10,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.9,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"# # Add text showing location\n",
|
||
|
"# ax.text(\n",
|
||
|
"# 0.95,\n",
|
||
|
"# 0.95,\n",
|
||
|
"# plot['location'],\n",
|
||
|
"# transform=ax.transAxes,\n",
|
||
|
"# size=8,\n",
|
||
|
"# horizontalalignment='right',\n",
|
||
|
"# verticalalignment='top',\n",
|
||
|
"# zorder=3,\n",
|
||
|
"# bbox=dict(\n",
|
||
|
"# facecolor='white',\n",
|
||
|
"# alpha=0.9,\n",
|
||
|
"# edgecolor='white',\n",
|
||
|
"# boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"# Remove tick parameters from shared axis\n",
|
||
|
"ax1.tick_params(labelbottom=False)\n",
|
||
|
"ax2.tick_params(labelbottom=False)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"plt.tight_layout()\n",
|
||
|
"\n",
|
||
|
"# Add y-label\n",
|
||
|
"ax3.set_xlabel('Cross-shore position (m)', size=8)\n",
|
||
|
"\n",
|
||
|
"# Add common x-label\n",
|
||
|
"fig.text(\n",
|
||
|
" 0.0,\n",
|
||
|
" 0.5,\n",
|
||
|
" 'Elevation (mAHD)',\n",
|
||
|
" ha='center',\n",
|
||
|
" size=8,\n",
|
||
|
" rotation=90,\n",
|
||
|
" horizontalalignment='center',\n",
|
||
|
" verticalalignment='center')\n",
|
||
|
"\n",
|
||
|
"# # Add legend\n",
|
||
|
"# ax1.legend(\n",
|
||
|
"# prop={'size': 6},\n",
|
||
|
"# ncol=4,\n",
|
||
|
"# bbox_to_anchor=(0.90, 1.0),\n",
|
||
|
"# loc=\"lower right\",\n",
|
||
|
"# bbox_transform=fig.transFigure)\n",
|
||
|
"\n",
|
||
|
"# # Add title\n",
|
||
|
"# fig.text(\n",
|
||
|
"# 0.06,1.01,\n",
|
||
|
"# 'Examples of observed\\nstorm regimes',\n",
|
||
|
"# horizontalalignment='left',\n",
|
||
|
"# verticalalignment='bottom',\n",
|
||
|
"# size=10)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"fig.savefig('12_narrabeen_triple_plot.png',dpi=300, bbox_inches = \"tight\")\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"## For coasts and ports\n",
|
||
|
"\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import matplotlib.gridspec as gridspec\n",
|
||
|
"import matplotlib.ticker as ticker\n",
|
||
|
"\n",
|
||
|
"# Setup grid\n",
|
||
|
"fig = plt.figure(figsize=(1, 1.5), dpi=150)\n",
|
||
|
"gs = gridspec.GridSpec(3, 1)\n",
|
||
|
"ax1 = fig.add_subplot(gs[0, 0])\n",
|
||
|
"ax2 = fig.add_subplot(gs[1, 0], sharex=ax1)\n",
|
||
|
"ax3 = fig.add_subplot(gs[2, 0], sharex=ax1)\n",
|
||
|
"\n",
|
||
|
"prestorm_color = '#fdae61'\n",
|
||
|
"poststorm_color = '#d53e4f'\n",
|
||
|
"\n",
|
||
|
"plots = [\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax1,\n",
|
||
|
" 'title': '$\\Delta$ Dune Vol = \\SI{-13}{\\m^{3}\\per\\m}',\n",
|
||
|
" 'site_id': 'NARRA0005',\n",
|
||
|
" 'x_min_fill': 150,\n",
|
||
|
" 'location': 'Grants\\nBeach',\n",
|
||
|
" 'subplot_letter': 'Profile A',\n",
|
||
|
" 'xlim_left': 150,\n",
|
||
|
" },\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax2,\n",
|
||
|
" 'title': '$\\Delta$ Dune Vol = \\SI{-10}{\\m^{3}\\per\\m}',\n",
|
||
|
" 'site_id': 'NARRA0026',\n",
|
||
|
" 'x_min_fill': 150,\n",
|
||
|
" 'location': 'Manning\\nPoint',\n",
|
||
|
" 'subplot_letter': 'Profile B',\n",
|
||
|
" 'xlim_left': 150,\n",
|
||
|
" },\n",
|
||
|
" {\n",
|
||
|
" 'ax': ax3,\n",
|
||
|
" 'title': '$\\Delta$ Dune Vol = \\SI{-21}{\\m^{3}\\per\\m}',\n",
|
||
|
" 'site_id': 'NARRA0028',\n",
|
||
|
" 'x_min_fill': 190,\n",
|
||
|
" 'location': 'Avoca Lagoon\\nEntrance',\n",
|
||
|
" 'subplot_letter': 'Profile C',\n",
|
||
|
" 'xlim_left': 150,\n",
|
||
|
" },\n",
|
||
|
"]\n",
|
||
|
"\n",
|
||
|
"for plot in plots:\n",
|
||
|
" ax = plot['ax']\n",
|
||
|
" site_id = plot['site_id']\n",
|
||
|
" df_pro_pre = df_profiles.xs((site_id, 'prestorm'),\n",
|
||
|
" level=['site_id', 'profile_type'])\n",
|
||
|
" df_pro_post = df_profiles.xs((site_id, 'poststorm'),\n",
|
||
|
" level=['site_id', 'profile_type'])\n",
|
||
|
" df_feat_pre = df_profile_features_crest_toes.xs(\n",
|
||
|
" (site_id, 'prestorm'), level=['site_id', 'profile_type'])\n",
|
||
|
" df_feat_post = df_profile_features_crest_toes.xs(\n",
|
||
|
" (site_id, 'poststorm'), level=['site_id', 'profile_type'])\n",
|
||
|
"\n",
|
||
|
" ax.plot(\n",
|
||
|
" df_pro_post.index.get_level_values('x'),\n",
|
||
|
" df_pro_post.z.values,\n",
|
||
|
" label='Poststorm profile',\n",
|
||
|
" color=poststorm_color,\n",
|
||
|
" linestyle='--')\n",
|
||
|
" ax.plot(\n",
|
||
|
" df_pro_pre.index.get_level_values('x'),\n",
|
||
|
" df_pro_pre.z.values,\n",
|
||
|
" label='Prestorm profile',\n",
|
||
|
" color=prestorm_color)\n",
|
||
|
" # ax.scatter(\n",
|
||
|
" # df_feat_post.dune_crest_x,\n",
|
||
|
" # df_feat_post.dune_crest_z,\n",
|
||
|
" # label='Poststorm dune crest',\n",
|
||
|
" # facecolor=poststorm_color,\n",
|
||
|
" # edgecolor='black',\n",
|
||
|
" # linewidth='0.75',\n",
|
||
|
" # marker='v',\n",
|
||
|
" # zorder=3)\n",
|
||
|
" # ax.scatter(\n",
|
||
|
" # df_feat_pre.dune_crest_x,\n",
|
||
|
" # df_feat_pre.dune_crest_z,\n",
|
||
|
" # label='Prestorm dune crest',\n",
|
||
|
" # facecolor=prestorm_color,\n",
|
||
|
" # edgecolor='black',\n",
|
||
|
" # linewidth='0.75',\n",
|
||
|
" # marker='v',\n",
|
||
|
" # zorder=3)\n",
|
||
|
"\n",
|
||
|
" # if not np.isnan(df_feat_post.dune_toe_x.values[0]):\n",
|
||
|
" # ax.scatter(\n",
|
||
|
" # df_feat_post.dune_toe_x,\n",
|
||
|
" # df_feat_post.dune_toe_z,\n",
|
||
|
" # label='Poststorm dune toe',\n",
|
||
|
" # facecolor=poststorm_color,\n",
|
||
|
" # edgecolor='black',\n",
|
||
|
" # linewidth='0.75',\n",
|
||
|
" # marker='^',\n",
|
||
|
" # zorder=3)\n",
|
||
|
"\n",
|
||
|
" # if not np.isnan(df_feat_pre.dune_toe_x.values[0]):\n",
|
||
|
" # ax.scatter(\n",
|
||
|
" # df_feat_pre.dune_toe_x,\n",
|
||
|
" # df_feat_pre.dune_toe_z,\n",
|
||
|
" # label='Prestorm dune toe',\n",
|
||
|
" # facecolor=prestorm_color,\n",
|
||
|
" # edgecolor='black',\n",
|
||
|
" # linewidth='0.75',\n",
|
||
|
" # marker='^',\n",
|
||
|
" # zorder=3)\n",
|
||
|
"\n",
|
||
|
" # Fill to zero elevation if there is no post profile value\n",
|
||
|
" z_post = df_pro_post.z.values\n",
|
||
|
" z_post[np.isnan(z_post)] = 0\n",
|
||
|
"\n",
|
||
|
" # Only want to fill the difference between pre/post past a certain x-val\n",
|
||
|
" mask = df_pro_post.index.get_level_values('x') > plot['x_min_fill']\n",
|
||
|
"\n",
|
||
|
" ax.fill_between(\n",
|
||
|
" df_pro_post.index.get_level_values('x')[mask],\n",
|
||
|
" df_pro_pre.z.values[mask],\n",
|
||
|
" z_post[mask],\n",
|
||
|
" color='#f46d43',\n",
|
||
|
" label='Eroded volume',\n",
|
||
|
" alpha=0.4)\n",
|
||
|
"\n",
|
||
|
" # Set lims\n",
|
||
|
" ax.set_ylim([0, 14])\n",
|
||
|
" ax.set_xlim(left=plot['xlim_left'])\n",
|
||
|
"\n",
|
||
|
" # Set ticks to 50 m\n",
|
||
|
" ax.xaxis.set_major_locator(ticker.MultipleLocator(50))\n",
|
||
|
" ax.yaxis.set_major_locator(ticker.MultipleLocator(5))\n",
|
||
|
" ax.yaxis.set_tick_params(pad=-3)\n",
|
||
|
" ax.xaxis.set_tick_params(pad=-3)\n",
|
||
|
"\n",
|
||
|
" # Change tick label size\n",
|
||
|
" ax.tick_params(axis='both', which='major', labelsize=6)\n",
|
||
|
"\n",
|
||
|
" # Add titles showing regimes\n",
|
||
|
" ax.set_title(plot['title'], size=6)\n",
|
||
|
"\n",
|
||
|
" # Add subplot letters\n",
|
||
|
" ax.text(\n",
|
||
|
" 0.60,\n",
|
||
|
" 0.6,\n",
|
||
|
" plot['subplot_letter'],\n",
|
||
|
" transform=ax.transAxes,\n",
|
||
|
" size=6,\n",
|
||
|
" bbox=dict(\n",
|
||
|
" facecolor='white',\n",
|
||
|
" alpha=0.9,\n",
|
||
|
" edgecolor='white',\n",
|
||
|
" boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"# # Add text showing location\n",
|
||
|
"# ax.text(\n",
|
||
|
"# 0.95,\n",
|
||
|
"# 0.95,\n",
|
||
|
"# plot['location'],\n",
|
||
|
"# transform=ax.transAxes,\n",
|
||
|
"# size=8,\n",
|
||
|
"# horizontalalignment='right',\n",
|
||
|
"# verticalalignment='top',\n",
|
||
|
"# zorder=3,\n",
|
||
|
"# bbox=dict(\n",
|
||
|
"# facecolor='white',\n",
|
||
|
"# alpha=0.9,\n",
|
||
|
"# edgecolor='white',\n",
|
||
|
"# boxstyle='square,pad=0'))\n",
|
||
|
"\n",
|
||
|
"# Remove tick parameters from shared axis\n",
|
||
|
"ax1.tick_params(labelbottom=False)\n",
|
||
|
"ax2.tick_params(labelbottom=False)\n",
|
||
|
"\n",
|
||
|
"plt.tight_layout(pad=0.1, w_pad=0.1, h_pad=0.1)\n",
|
||
|
"\n",
|
||
|
"# Add x-label\n",
|
||
|
"ax3.set_xlabel('Cross-shore position (m)', size=6)\n",
|
||
|
"\n",
|
||
|
"# Add common y-label\n",
|
||
|
"fig.text(\n",
|
||
|
" -0.05,\n",
|
||
|
" 0.5,\n",
|
||
|
" 'Elevation (mAHD)',\n",
|
||
|
" ha='center',\n",
|
||
|
" size=6,\n",
|
||
|
" rotation=90,\n",
|
||
|
" horizontalalignment='center',\n",
|
||
|
" verticalalignment='center')\n",
|
||
|
"\n",
|
||
|
"# # Add legend\n",
|
||
|
"# ax1.legend(\n",
|
||
|
"# prop={'size': 6},\n",
|
||
|
"# ncol=4,\n",
|
||
|
"# bbox_to_anchor=(0.90, 1.0),\n",
|
||
|
"# loc=\"lower right\",\n",
|
||
|
"# bbox_transform=fig.transFigure)\n",
|
||
|
"\n",
|
||
|
"# # Add title\n",
|
||
|
"# fig.text(\n",
|
||
|
"# 0.06,1.01,\n",
|
||
|
"# 'Examples of observed\\nstorm regimes',\n",
|
||
|
"# horizontalalignment='left',\n",
|
||
|
"# verticalalignment='bottom',\n",
|
||
|
"# size=10)\n",
|
||
|
"\n",
|
||
|
"# Adjust width of border\n",
|
||
|
"for axis in ['top', 'bottom', 'left', 'right']:\n",
|
||
|
" ax1.spines[axis].set_linewidth(0.7)\n",
|
||
|
" ax2.spines[axis].set_linewidth(0.7)\n",
|
||
|
" ax3.spines[axis].set_linewidth(0.7)\n",
|
||
|
"\n",
|
||
|
"fig.savefig(\n",
|
||
|
" '12_c&p_narrabeen_triple_plot.png',\n",
|
||
|
" dpi=600,\n",
|
||
|
" bbox_inches=\"tight\",\n",
|
||
|
" pad_inches=0.01)\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"df_sites.groupby('beach').mean()[['lat','lon']].to_dict('index')"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"hide_input": false,
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"toc": {
|
||
|
"base_numbering": 1,
|
||
|
"nav_menu": {},
|
||
|
"number_sections": true,
|
||
|
"sideBar": true,
|
||
|
"skip_h1_title": false,
|
||
|
"title_cell": "Table of Contents",
|
||
|
"title_sidebar": "Contents",
|
||
|
"toc_cell": false,
|
||
|
"toc_position": {
|
||
|
"height": "calc(100% - 180px)",
|
||
|
"left": "10px",
|
||
|
"top": "150px",
|
||
|
"width": "255.391px"
|
||
|
},
|
||
|
"toc_section_display": true,
|
||
|
"toc_window_display": true
|
||
|
},
|
||
|
"varInspector": {
|
||
|
"cols": {
|
||
|
"lenName": 16,
|
||
|
"lenType": 16,
|
||
|
"lenVar": 40
|
||
|
},
|
||
|
"kernels_config": {
|
||
|
"python": {
|
||
|
"delete_cmd_postfix": "",
|
||
|
"delete_cmd_prefix": "del ",
|
||
|
"library": "var_list.py",
|
||
|
"varRefreshCmd": "print(var_dic_list())"
|
||
|
},
|
||
|
"r": {
|
||
|
"delete_cmd_postfix": ") ",
|
||
|
"delete_cmd_prefix": "rm(",
|
||
|
"library": "var_list.r",
|
||
|
"varRefreshCmd": "cat(var_dic_list()) "
|
||
|
}
|
||
|
},
|
||
|
"types_to_exclude": [
|
||
|
"module",
|
||
|
"function",
|
||
|
"builtin_function_or_method",
|
||
|
"instance",
|
||
|
"_Feature"
|
||
|
],
|
||
|
"window_display": false
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|