|
|
@ -10,9 +10,7 @@
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {
|
|
|
|
"metadata": {},
|
|
|
|
"heading_collapsed": true
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"source": [
|
|
|
|
"source": [
|
|
|
|
"## Setup notebook\n",
|
|
|
|
"## Setup notebook\n",
|
|
|
|
"Import our required packages and set default plotting options."
|
|
|
|
"Import our required packages and set default plotting options."
|
|
|
@ -21,9 +19,7 @@
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {
|
|
|
|
"metadata": {},
|
|
|
|
"hidden": true
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"outputs": [],
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"source": [
|
|
|
|
"# Enable autoreloading of our modules. \n",
|
|
|
|
"# Enable autoreloading of our modules. \n",
|
|
|
@ -37,9 +33,7 @@
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {
|
|
|
|
"metadata": {},
|
|
|
|
"hidden": true
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"outputs": [],
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"source": [
|
|
|
|
"from IPython.core.debugger import set_trace\n",
|
|
|
|
"from IPython.core.debugger import set_trace\n",
|
|
|
@ -66,6 +60,7 @@
|
|
|
|
"from scipy import stats\n",
|
|
|
|
"from scipy import stats\n",
|
|
|
|
"from sklearn.metrics import confusion_matrix\n",
|
|
|
|
"from sklearn.metrics import confusion_matrix\n",
|
|
|
|
"import matplotlib.pyplot as plt\n",
|
|
|
|
"import matplotlib.pyplot as plt\n",
|
|
|
|
|
|
|
|
"from matplotlib.ticker import MultipleLocator\n",
|
|
|
|
"from matplotlib.lines import Line2D\n",
|
|
|
|
"from matplotlib.lines import Line2D\n",
|
|
|
|
"from cycler import cycler\n",
|
|
|
|
"from cycler import cycler\n",
|
|
|
|
"from scipy.interpolate import interp1d\n",
|
|
|
|
"from scipy.interpolate import interp1d\n",
|
|
|
@ -75,9 +70,7 @@
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {
|
|
|
|
"metadata": {},
|
|
|
|
"hidden": true
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"outputs": [],
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"source": [
|
|
|
|
"# Matplot lib default settings\n",
|
|
|
|
"# Matplot lib default settings\n",
|
|
|
@ -128,11 +121,22 @@
|
|
|
|
"# Note that the forecasted data sets should be in the same order for impacts and twls\n",
|
|
|
|
"# Note that the forecasted data sets should be in the same order for impacts and twls\n",
|
|
|
|
"impacts = {\n",
|
|
|
|
"impacts = {\n",
|
|
|
|
" 'forecasted': {\n",
|
|
|
|
" 'forecasted': {\n",
|
|
|
|
" 'foreshore_slope_sto06': df_from_csv('impacts_forecasted_foreshore_slope_sto06.csv',index_col=[0]),\n",
|
|
|
|
" 'postintertidal_slope_hol86': df_from_csv('impacts_forecasted_postintertidal_slope_hol86.csv', index_col=[0]),\n",
|
|
|
|
" 'mean_slope_hol86': df_from_csv('impacts_forecasted_mean_slope_hol86.csv',index_col=[0]),\n",
|
|
|
|
" 'postintertidal_slope_nie91': df_from_csv('impacts_forecasted_postintertidal_slope_nie91.csv', index_col=[0]),\n",
|
|
|
|
" 'mean_slope_nie91': df_from_csv('impacts_forecasted_mean_slope_nie91.csv',index_col=[0]),\n",
|
|
|
|
" 'postintertidal_slope_pow18': df_from_csv('impacts_forecasted_postintertidal_slope_pow18.csv', index_col=[0]),\n",
|
|
|
|
" 'mean_slope_pow18': df_from_csv('impacts_forecasted_mean_slope_pow18.csv',index_col=[0]),\n",
|
|
|
|
" 'postintertidal_slope_sto06': df_from_csv('impacts_forecasted_postintertidal_slope_sto06.csv', index_col=[0]),\n",
|
|
|
|
" 'mean_slope_sto06': df_from_csv('impacts_forecasted_mean_slope_sto06.csv',index_col=[0]),\n",
|
|
|
|
" 'postmean_slope_hol86': df_from_csv('impacts_forecasted_postmean_slope_hol86.csv', index_col=[0]),\n",
|
|
|
|
|
|
|
|
" 'postmean_slope_nie91': df_from_csv('impacts_forecasted_postmean_slope_nie91.csv', index_col=[0]),\n",
|
|
|
|
|
|
|
|
" 'postmean_slope_pow18': df_from_csv('impacts_forecasted_postmean_slope_pow18.csv', index_col=[0]),\n",
|
|
|
|
|
|
|
|
" 'postmean_slope_sto06': df_from_csv('impacts_forecasted_postmean_slope_sto06.csv', index_col=[0]),\n",
|
|
|
|
|
|
|
|
" 'preintertidal_slope_hol86': df_from_csv('impacts_forecasted_preintertidal_slope_hol86.csv', index_col=[0]),\n",
|
|
|
|
|
|
|
|
" 'preintertidal_slope_nie91': df_from_csv('impacts_forecasted_preintertidal_slope_nie91.csv', index_col=[0]),\n",
|
|
|
|
|
|
|
|
" 'preintertidal_slope_pow18': df_from_csv('impacts_forecasted_preintertidal_slope_pow18.csv', index_col=[0]),\n",
|
|
|
|
|
|
|
|
" 'preintertidal_slope_sto06': df_from_csv('impacts_forecasted_preintertidal_slope_sto06.csv', index_col=[0]),\n",
|
|
|
|
|
|
|
|
" 'premean_slope_hol86': df_from_csv('impacts_forecasted_premean_slope_hol86.csv', index_col=[0]),\n",
|
|
|
|
|
|
|
|
" 'premean_slope_nie91': df_from_csv('impacts_forecasted_premean_slope_nie91.csv', index_col=[0]),\n",
|
|
|
|
|
|
|
|
" 'premean_slope_pow18': df_from_csv('impacts_forecasted_premean_slope_pow18.csv', index_col=[0]),\n",
|
|
|
|
|
|
|
|
" 'premean_slope_sto06': df_from_csv('impacts_forecasted_premean_slope_sto06.csv', index_col=[0]),\n",
|
|
|
|
" },\n",
|
|
|
|
" },\n",
|
|
|
|
" 'observed': df_from_csv('impacts_observed.csv', index_col=[0])\n",
|
|
|
|
" 'observed': df_from_csv('impacts_observed.csv', index_col=[0])\n",
|
|
|
|
" }\n",
|
|
|
|
" }\n",
|
|
|
@ -140,11 +144,22 @@
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"twls = {\n",
|
|
|
|
"twls = {\n",
|
|
|
|
" 'forecasted': {\n",
|
|
|
|
" 'forecasted': {\n",
|
|
|
|
" 'foreshore_slope_sto06': df_from_csv('twl_foreshore_slope_sto06.csv',index_col=[0,1]),\n",
|
|
|
|
" 'postintertidal_slope_hol86': df_from_csv('twl_postintertidal_slope_hol86.csv', index_col=[0,1]),\n",
|
|
|
|
" 'mean_slope_hol86': df_from_csv('twl_mean_slope_hol86.csv',index_col=[0,1]),\n",
|
|
|
|
" 'postintertidal_slope_nie91': df_from_csv('twl_postintertidal_slope_nie91.csv', index_col=[0,1]),\n",
|
|
|
|
" 'mean_slope_nie91': df_from_csv('twl_mean_slope_nie91.csv',index_col=[0,1]),\n",
|
|
|
|
" 'postintertidal_slope_pow18': df_from_csv('twl_postintertidal_slope_pow18.csv', index_col=[0,1]),\n",
|
|
|
|
" 'mean_slope_pow18': df_from_csv('twl_mean_slope_pow18.csv',index_col=[0,1]),\n",
|
|
|
|
" 'postintertidal_slope_sto06': df_from_csv('twl_postintertidal_slope_sto06.csv', index_col=[0,1]),\n",
|
|
|
|
" 'mean_slope_sto06': df_from_csv('twl_mean_slope_sto06.csv',index_col=[0,1]),\n",
|
|
|
|
" 'postmean_slope_hol86': df_from_csv('twl_postmean_slope_hol86.csv', index_col=[0,1]),\n",
|
|
|
|
|
|
|
|
" 'postmean_slope_nie91': df_from_csv('twl_postmean_slope_nie91.csv', index_col=[0,1]),\n",
|
|
|
|
|
|
|
|
" 'postmean_slope_pow18': df_from_csv('twl_postmean_slope_pow18.csv', index_col=[0,1]),\n",
|
|
|
|
|
|
|
|
" 'postmean_slope_sto06': df_from_csv('twl_postmean_slope_sto06.csv', index_col=[0,1]),\n",
|
|
|
|
|
|
|
|
" 'preintertidal_slope_hol86': df_from_csv('twl_preintertidal_slope_hol86.csv', index_col=[0,1]),\n",
|
|
|
|
|
|
|
|
" 'preintertidal_slope_nie91': df_from_csv('twl_preintertidal_slope_nie91.csv', index_col=[0,1]),\n",
|
|
|
|
|
|
|
|
" 'preintertidal_slope_pow18': df_from_csv('twl_preintertidal_slope_pow18.csv', index_col=[0,1]),\n",
|
|
|
|
|
|
|
|
" 'preintertidal_slope_sto06': df_from_csv('twl_preintertidal_slope_sto06.csv', index_col=[0,1]),\n",
|
|
|
|
|
|
|
|
" 'premean_slope_hol86': df_from_csv('twl_premean_slope_hol86.csv', index_col=[0,1]),\n",
|
|
|
|
|
|
|
|
" 'premean_slope_nie91': df_from_csv('twl_premean_slope_nie91.csv', index_col=[0,1]),\n",
|
|
|
|
|
|
|
|
" 'premean_slope_pow18': df_from_csv('twl_premean_slope_pow18.csv', index_col=[0,1]),\n",
|
|
|
|
|
|
|
|
" 'premean_slope_sto06': df_from_csv('twl_premean_slope_sto06.csv', index_col=[0,1]),\n",
|
|
|
|
" }\n",
|
|
|
|
" }\n",
|
|
|
|
"}\n",
|
|
|
|
"}\n",
|
|
|
|
"print('Done!')"
|
|
|
|
"print('Done!')"
|
|
|
@ -152,9 +167,7 @@
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {
|
|
|
|
"metadata": {},
|
|
|
|
"heading_collapsed": true
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"source": [
|
|
|
|
"source": [
|
|
|
|
"## Generate longshore plots for each beach"
|
|
|
|
"## Generate longshore plots for each beach"
|
|
|
|
]
|
|
|
|
]
|
|
|
@ -163,57 +176,66 @@
|
|
|
|
"cell_type": "code",
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {
|
|
|
|
"metadata": {
|
|
|
|
"hidden": true
|
|
|
|
"code_folding": []
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"outputs": [],
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"source": [
|
|
|
|
"beach = 'NARRA'\n",
|
|
|
|
"beaches = list(\n",
|
|
|
|
|
|
|
|
" set([\n",
|
|
|
|
|
|
|
|
" x[:-4] for x in df_profiles.index.get_level_values('site_id').unique()\n",
|
|
|
|
|
|
|
|
" ]))\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"df_obs_impacts = impacts['observed'].loc[impacts['observed'].index.str.\n",
|
|
|
|
"for beach in beaches:\n",
|
|
|
|
|
|
|
|
" \n",
|
|
|
|
|
|
|
|
" df_obs_impacts = impacts['observed'].loc[impacts['observed'].index.str.\n",
|
|
|
|
" contains(beach)]\n",
|
|
|
|
" contains(beach)]\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Get index for each site on the beach\n",
|
|
|
|
" # Get index for each site on the beach\n",
|
|
|
|
"n = [x for x in range(len(df_obs_impacts))][::-1]\n",
|
|
|
|
" n = [x for x in range(len(df_obs_impacts))][::-1]\n",
|
|
|
|
"n_sites = [x for x in df_obs_impacts.index][::-1]\n",
|
|
|
|
" n_sites = [x for x in df_obs_impacts.index][::-1]\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Convert storm regimes to categorical datatype\n",
|
|
|
|
" # Convert storm regimes to categorical datatype\n",
|
|
|
|
"cat_type = CategoricalDtype(\n",
|
|
|
|
" cat_type = CategoricalDtype(\n",
|
|
|
|
" categories=['swash', 'collision', 'overwash', 'inundation'], ordered=True)\n",
|
|
|
|
" categories=['swash', 'collision', 'overwash', 'inundation'],\n",
|
|
|
|
"df_obs_impacts.storm_regime = df_obs_impacts.storm_regime.astype(cat_type)\n",
|
|
|
|
" ordered=True)\n",
|
|
|
|
|
|
|
|
" df_obs_impacts.storm_regime = df_obs_impacts.storm_regime.astype(cat_type)\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Create figure\n",
|
|
|
|
" # Create figure\n",
|
|
|
|
"f, (ax1, ax2, ax3, ax4, ax5, ax6, ax7, ax8) = plt.subplots(\n",
|
|
|
|
" \n",
|
|
|
|
|
|
|
|
" # Determine the height of the figure, based on the number of sites.\n",
|
|
|
|
|
|
|
|
" fig_height = max(6, 0.18 * len(n_sites))\n",
|
|
|
|
|
|
|
|
" f, (ax1, ax2, ax3, ax4, ax5, ax6, ax7, ax8) = plt.subplots(\n",
|
|
|
|
" 1,\n",
|
|
|
|
" 1,\n",
|
|
|
|
" 8,\n",
|
|
|
|
" 8,\n",
|
|
|
|
" sharey=True,\n",
|
|
|
|
" sharey=True,\n",
|
|
|
|
" figsize=(18, 8),\n",
|
|
|
|
" figsize=(18, fig_height),\n",
|
|
|
|
" gridspec_kw={'width_ratios': [4, 4, 2, 2, 2, 2, 2, 2]})\n",
|
|
|
|
" gridspec_kw={'width_ratios': [4, 4, 2, 2, 2, 2, 2, 2]})\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# ax1: Impacts\n",
|
|
|
|
" # ax1: Impacts\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Define colors for storm regime\n",
|
|
|
|
" # Define colors for storm regime\n",
|
|
|
|
"cmap = {'swash': '#1a9850', 'collision': '#fee08b', 'overwash': '#d73027'}\n",
|
|
|
|
" cmap = {'swash': '#1a9850', 'collision': '#fee08b', 'overwash': '#d73027'}\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Common marker style\n",
|
|
|
|
" # Common marker style\n",
|
|
|
|
"marker_style = {\n",
|
|
|
|
" marker_style = {\n",
|
|
|
|
" 's': 60,\n",
|
|
|
|
" 's': 60,\n",
|
|
|
|
" 'linewidths': 0.7,\n",
|
|
|
|
" 'linewidths': 0.7,\n",
|
|
|
|
" 'alpha': 1,\n",
|
|
|
|
" 'alpha': 1,\n",
|
|
|
|
" 'edgecolors': 'k',\n",
|
|
|
|
" 'edgecolors': 'k',\n",
|
|
|
|
" 'marker': 'o',\n",
|
|
|
|
" 'marker': 'o',\n",
|
|
|
|
"}\n",
|
|
|
|
" }\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Plot observed impacts\n",
|
|
|
|
" # Plot observed impacts\n",
|
|
|
|
"colors = [cmap.get(x) for x in df_obs_impacts.storm_regime]\n",
|
|
|
|
" colors = [cmap.get(x) for x in df_obs_impacts.storm_regime]\n",
|
|
|
|
"colors = ['#d73027' if c is None else c for c in colors]\n",
|
|
|
|
" colors = ['#aaaaaa' if c is None else c for c in colors]\n",
|
|
|
|
"ax1.scatter([0 for x in n], n, color=colors, **marker_style)\n",
|
|
|
|
" ax1.scatter([0 for x in n], n, color=colors, **marker_style)\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Plot model impacts\n",
|
|
|
|
" # Plot model impacts\n",
|
|
|
|
"for i, model in enumerate(impacts['forecasted']):\n",
|
|
|
|
" for i, model in enumerate(impacts['forecasted']):\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
" # Only get model results for this beach\n",
|
|
|
|
" # Only get model results for this beach\n",
|
|
|
|
" df_model = impacts['forecasted'][model].loc[impacts['forecasted'][model].\n",
|
|
|
|
" df_model = impacts['forecasted'][model].loc[\n",
|
|
|
|
" index.str.contains(beach)]\n",
|
|
|
|
" impacts['forecasted'][model].index.str.contains(beach)]\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
" # Recast storm regimes as categorical data\n",
|
|
|
|
" # Recast storm regimes as categorical data\n",
|
|
|
|
" df_model.storm_regime = df_model.storm_regime.astype(cat_type)\n",
|
|
|
|
" df_model.storm_regime = df_model.storm_regime.astype(cat_type)\n",
|
|
|
@ -221,19 +243,30 @@
|
|
|
|
" # Assign colors\n",
|
|
|
|
" # Assign colors\n",
|
|
|
|
" colors = [cmap.get(x) for x in df_model.storm_regime]\n",
|
|
|
|
" colors = [cmap.get(x) for x in df_model.storm_regime]\n",
|
|
|
|
" colors = ['#aaaaaa' if c is None else c for c in colors]\n",
|
|
|
|
" colors = ['#aaaaaa' if c is None else c for c in colors]\n",
|
|
|
|
" ax1.scatter([i + 1 for x in n], n, color=colors, **marker_style)\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Add model names to each impact on x axis\n",
|
|
|
|
" # Only plot markers which are different to the observed storm regime. \n",
|
|
|
|
"ax1.set_xticks(range(len(impacts['forecasted']) + 1))\n",
|
|
|
|
" # This makes it easier to find where model predictions differ\n",
|
|
|
|
"ax1.set_xticklabels(['observed'] +\n",
|
|
|
|
" y_coords = []\n",
|
|
|
|
|
|
|
|
" for obs_impact, for_impact in zip(df_model.storm_regime,\n",
|
|
|
|
|
|
|
|
" df_obs_impacts.storm_regime):\n",
|
|
|
|
|
|
|
|
" if obs_impact == for_impact:\n",
|
|
|
|
|
|
|
|
" y_coords.append(None)\n",
|
|
|
|
|
|
|
|
" else:\n",
|
|
|
|
|
|
|
|
" y_coords.append(i + 1)\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" ax1.scatter(y_coords, n, color=colors, **marker_style)\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" # Add model names to each impact on x axis\n",
|
|
|
|
|
|
|
|
" ax1.set_xticks(range(len(impacts['forecasted']) + 1))\n",
|
|
|
|
|
|
|
|
" ax1.set_xticklabels(['observed'] +\n",
|
|
|
|
" [x.replace('_', '\\_') for x in impacts['forecasted']])\n",
|
|
|
|
" [x.replace('_', '\\_') for x in impacts['forecasted']])\n",
|
|
|
|
"ax1.xaxis.set_tick_params(rotation=90)\n",
|
|
|
|
" ax1.xaxis.set_tick_params(rotation=90)\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Add title\n",
|
|
|
|
" # Add title\n",
|
|
|
|
"ax1.set_title('Storm regime')\n",
|
|
|
|
" ax1.set_title('Storm regime')\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Create custom legend\n",
|
|
|
|
" # Create custom legend\n",
|
|
|
|
"legend_elements = [\n",
|
|
|
|
" legend_elements = [\n",
|
|
|
|
" Line2D([0], [0],\n",
|
|
|
|
" Line2D([0], [0],\n",
|
|
|
|
" marker='o',\n",
|
|
|
|
" marker='o',\n",
|
|
|
|
" color='w',\n",
|
|
|
|
" color='w',\n",
|
|
|
@ -258,25 +291,29 @@
|
|
|
|
" markersize=8,\n",
|
|
|
|
" markersize=8,\n",
|
|
|
|
" markeredgewidth=1.0,\n",
|
|
|
|
" markeredgewidth=1.0,\n",
|
|
|
|
" markeredgecolor='k'),\n",
|
|
|
|
" markeredgecolor='k'),\n",
|
|
|
|
"]\n",
|
|
|
|
" ]\n",
|
|
|
|
"ax1.legend(\n",
|
|
|
|
" ax1.legend(\n",
|
|
|
|
" handles=legend_elements, loc='lower center', bbox_to_anchor=(0.5, 1.1))\n",
|
|
|
|
" handles=legend_elements, loc='lower center', bbox_to_anchor=(0.5, 1.1))\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Replace yticks with site_ids\n",
|
|
|
|
" # Replace axis ticks with names of site ids\n",
|
|
|
|
"yticks = ax1.get_yticks().tolist()\n",
|
|
|
|
" ytick_labels = ax1.get_yticks().tolist()\n",
|
|
|
|
"yticks = [n_sites[int(y)] if 0 <= y <= len(n_sites) else y for y in yticks]\n",
|
|
|
|
" yticks = [\n",
|
|
|
|
"ax1.set_yticklabels(yticks)\n",
|
|
|
|
" n_sites[int(y)] if all([y >= 0, y < len(n_sites)]) else ''\n",
|
|
|
|
|
|
|
|
" for y in ytick_labels\n",
|
|
|
|
|
|
|
|
" ]\n",
|
|
|
|
|
|
|
|
" yticks = [x.replace('_', '\\_') for x in yticks]\n",
|
|
|
|
|
|
|
|
" ax1.set_yticklabels(yticks)\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# ax2: elevations\n",
|
|
|
|
" # ax2: elevations\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Dune elevations\n",
|
|
|
|
" # Dune elevations\n",
|
|
|
|
"df_feats = df_profile_features_crest_toes.xs(['prestorm'],\n",
|
|
|
|
" df_feats = df_profile_features_crest_toes.xs(['prestorm'],\n",
|
|
|
|
" level=['profile_type'])\n",
|
|
|
|
" level=['profile_type'])\n",
|
|
|
|
"df_feats = df_feats.loc[df_feats.index.str.contains(beach)]\n",
|
|
|
|
" df_feats = df_feats.loc[df_feats.index.str.contains(beach)]\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"ax2.plot(df_feats.dune_crest_z, n, color='#fdae61')\n",
|
|
|
|
" ax2.plot(df_feats.dune_crest_z, n, color='#fdae61')\n",
|
|
|
|
"ax2.plot(df_feats.dune_toe_z, n, color='#fdae61')\n",
|
|
|
|
" ax2.plot(df_feats.dune_toe_z, n, color='#fdae61')\n",
|
|
|
|
"ax2.fill_betweenx(\n",
|
|
|
|
" ax2.fill_betweenx(\n",
|
|
|
|
" n,\n",
|
|
|
|
" n,\n",
|
|
|
|
" df_feats.dune_toe_z,\n",
|
|
|
|
" df_feats.dune_toe_z,\n",
|
|
|
|
" df_feats.dune_crest_z,\n",
|
|
|
|
" df_feats.dune_crest_z,\n",
|
|
|
@ -284,7 +321,7 @@
|
|
|
|
" color='#fdae61',\n",
|
|
|
|
" color='#fdae61',\n",
|
|
|
|
" label='$D_{low}$ to $D_{high}$')\n",
|
|
|
|
" label='$D_{low}$ to $D_{high}$')\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"model_colors = [\n",
|
|
|
|
" model_colors = [\n",
|
|
|
|
" '#1f78b4',\n",
|
|
|
|
" '#1f78b4',\n",
|
|
|
|
" '#33a02c',\n",
|
|
|
|
" '#33a02c',\n",
|
|
|
|
" '#e31a1c',\n",
|
|
|
|
" '#e31a1c',\n",
|
|
|
@ -296,93 +333,149 @@
|
|
|
|
" '#ffff99',\n",
|
|
|
|
" '#ffff99',\n",
|
|
|
|
" ]\n",
|
|
|
|
" ]\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Define colors to cycle through for our R_high\n",
|
|
|
|
" # Define colors to cycle through for our R_high\n",
|
|
|
|
"ax2.set_prop_cycle(cycler('color', model_colors))\n",
|
|
|
|
" ax2.set_prop_cycle(cycler('color', model_colors))\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Plot R_high values\n",
|
|
|
|
" # For TWL elevations, Rhigh-Dlow and R2 axis, only plot a few models\n",
|
|
|
|
"for model in impacts['forecasted']:\n",
|
|
|
|
" models_to_plot = [\n",
|
|
|
|
|
|
|
|
" 'premean_slope_hol86',\n",
|
|
|
|
|
|
|
|
" 'premean_slope_sto06',\n",
|
|
|
|
|
|
|
|
" 'preintertidal_slope_hol86',\n",
|
|
|
|
|
|
|
|
" 'preintertidal_slope_sto06',\n",
|
|
|
|
|
|
|
|
" ]\n",
|
|
|
|
|
|
|
|
" models_linewidth = 0.8\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" # Plot R_high values\n",
|
|
|
|
|
|
|
|
" for model in models_to_plot:\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
" # Only get model results for this beach\n",
|
|
|
|
" # Only get model results for this beach\n",
|
|
|
|
" df_model = impacts['forecasted'][model].loc[impacts['forecasted'][model].\n",
|
|
|
|
" df_model = impacts['forecasted'][model].loc[\n",
|
|
|
|
" index.str.contains(beach)]\n",
|
|
|
|
" impacts['forecasted'][model].index.str.contains(beach)]\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
" # Recast storm regimes as categorical data\n",
|
|
|
|
" # Recast storm regimes as categorical data\n",
|
|
|
|
" ax2.plot(df_model.R_high, n, label=model.replace('_', '\\_'))\n",
|
|
|
|
" ax2.plot(\n",
|
|
|
|
|
|
|
|
" df_model.R_high,\n",
|
|
|
|
|
|
|
|
" n,\n",
|
|
|
|
|
|
|
|
" label=model.replace('_', '\\_'),\n",
|
|
|
|
|
|
|
|
" linewidth=models_linewidth)\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Set title, legend and labels\n",
|
|
|
|
" # Set title, legend and labels\n",
|
|
|
|
"ax2.set_title('TWL \\& dune\\nelevations')\n",
|
|
|
|
" ax2.set_title('TWL \\& dune\\nelevations')\n",
|
|
|
|
"ax2.legend(loc='lower center', bbox_to_anchor=(0.5, 1.1))\n",
|
|
|
|
" ax2.legend(loc='lower center', bbox_to_anchor=(0.5, 1.1))\n",
|
|
|
|
"ax2.set_xlabel('Elevation (m AHD)')\n",
|
|
|
|
" ax2.set_xlabel('Elevation (m AHD)')\n",
|
|
|
|
|
|
|
|
"# ax2.set_xlim([0, max(df_feats.dune_crest_z)])\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" # ax3: Plot R_high - D_low\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# ax3: Plot R_high - D_low\n",
|
|
|
|
" # Define colors to cycle through for our R_high\n",
|
|
|
|
|
|
|
|
" ax3.set_prop_cycle(cycler('color', model_colors))\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Define colors to cycle through for our R_high\n",
|
|
|
|
" # Plot R_high values\n",
|
|
|
|
"ax3.set_prop_cycle(cycler('color', model_colors))\n",
|
|
|
|
" for model in models_to_plot:\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Plot R_high values\n",
|
|
|
|
" df_model = impacts['forecasted'][model].loc[\n",
|
|
|
|
"for model in impacts['forecasted']:\n",
|
|
|
|
" impacts['forecasted'][model].index.str.contains(beach)]\n",
|
|
|
|
" \n",
|
|
|
|
|
|
|
|
" df_model = impacts['forecasted'][model].loc[impacts['forecasted'][model].\n",
|
|
|
|
|
|
|
|
" index.str.contains(beach)]\n",
|
|
|
|
|
|
|
|
" # R_high - D_low\n",
|
|
|
|
" # R_high - D_low\n",
|
|
|
|
" ax3.plot(df_model.R_high - df_feats.dune_toe_z, n, label=model.replace('_', '\\_'))\n",
|
|
|
|
" ax3.plot(\n",
|
|
|
|
"\n",
|
|
|
|
" df_model.R_high - df_feats.dune_toe_z,\n",
|
|
|
|
"ax3.axvline(x=0,color='black',linestyle=':')\n",
|
|
|
|
" n,\n",
|
|
|
|
"ax3.set_title('$R_{high}$ - $D_{low}$')\n",
|
|
|
|
" label=model.replace('_', '\\_'),\n",
|
|
|
|
"ax3.set_xlabel('Height (m)')\n",
|
|
|
|
" linewidth=models_linewidth)\n",
|
|
|
|
"ax3.set_xlim([-2,2])\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" ax3.axvline(x=0, color='black', linestyle=':')\n",
|
|
|
|
|
|
|
|
" ax3.set_title('$R_{high}$ - $D_{low}$')\n",
|
|
|
|
|
|
|
|
" ax3.set_xlabel('Height (m)')\n",
|
|
|
|
|
|
|
|
"# ax3.set_xlim([-2, 2])\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Define colors to cycle through for our R2\n",
|
|
|
|
" # Define colors to cycle through for our R2\n",
|
|
|
|
"ax4.set_prop_cycle(cycler('color', model_colors))\n",
|
|
|
|
" ax4.set_prop_cycle(cycler('color', model_colors))\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# R_high - D_low\n",
|
|
|
|
" # R_high - D_low\n",
|
|
|
|
"for model in impacts['forecasted']:\n",
|
|
|
|
" for model in models_to_plot:\n",
|
|
|
|
" df_R2 = impacts['forecasted'][model].merge(twls['forecasted'][model],on=['site_id','datetime'])\n",
|
|
|
|
" df_R2 = impacts['forecasted'][model].merge(\n",
|
|
|
|
|
|
|
|
" twls['forecasted'][model], on=['site_id', 'datetime'], how='left')\n",
|
|
|
|
" df_R2 = df_R2.loc[df_R2.index.str.contains(beach)]\n",
|
|
|
|
" df_R2 = df_R2.loc[df_R2.index.str.contains(beach)]\n",
|
|
|
|
" ax4.plot(df_R2.R2, n, label=model.replace('_', '\\_'))\n",
|
|
|
|
" ax4.plot(\n",
|
|
|
|
"\n",
|
|
|
|
" df_R2.R2,\n",
|
|
|
|
"ax4.set_title(r'$R_{2\\%}$')\n",
|
|
|
|
" n,\n",
|
|
|
|
"ax4.set_xlabel('Height (m)')\n",
|
|
|
|
" label=model.replace('_', '\\_'),\n",
|
|
|
|
"\n",
|
|
|
|
" linewidth=models_linewidth)\n",
|
|
|
|
"# Need to chose a model to extract environmental parameters at maximum R_high time\n",
|
|
|
|
"\n",
|
|
|
|
"model = 'mean_slope_sto06'\n",
|
|
|
|
" ax4.set_title(r'$R_{2\\%}$')\n",
|
|
|
|
"df_beach = impacts['forecasted'][model].merge(twls['forecasted'][model], on=['site_id','datetime'])\n",
|
|
|
|
" ax4.set_xlabel('Height (m)')\n",
|
|
|
|
"df_beach = df_beach.loc[df_beach.index.str.contains(beach)]\n",
|
|
|
|
"# ax4.set_xlim([0, 10])\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"# Wave height, wave period, beach slope\n",
|
|
|
|
" # Beach slope\n",
|
|
|
|
"ax5.plot(df_beach.beta, n,color='#4daf4a')\n",
|
|
|
|
" slope_colors = [\n",
|
|
|
|
"ax5.set_title(r'$\\beta$')\n",
|
|
|
|
" '#bebada',\n",
|
|
|
|
"ax5.set_xlabel('Mean prestorm\\nbeach slope')\n",
|
|
|
|
" '#bc80bd',\n",
|
|
|
|
"ax5.set_xlim([0,0.15])\n",
|
|
|
|
" '#ffed6f',\n",
|
|
|
|
"\n",
|
|
|
|
" '#fdb462',\n",
|
|
|
|
"ax6.plot(df_beach.Hs0, n,color='#999999')\n",
|
|
|
|
" ]\n",
|
|
|
|
"ax6.set_title('$H_{s0}$')\n",
|
|
|
|
" ax5.set_prop_cycle(cycler('color', slope_colors))\n",
|
|
|
|
"ax6.set_xlabel('Sig. wave height (m)')\n",
|
|
|
|
" slope_models = {\n",
|
|
|
|
"ax6.set_xlim([3,5])\n",
|
|
|
|
" 'prestorm mean': 'premean_slope_sto06',\n",
|
|
|
|
"\n",
|
|
|
|
" 'poststorm mean': 'postmean_slope_sto06',\n",
|
|
|
|
"ax7.plot(df_beach.Tp, n,color='#999999')\n",
|
|
|
|
" 'prestorm intertidal': 'preintertidal_slope_sto06',\n",
|
|
|
|
"ax7.set_title('$T_{p}$')\n",
|
|
|
|
" 'poststorm intertidal': 'postintertidal_slope_sto06',\n",
|
|
|
|
"ax7.set_xlabel('Peak wave period (s)')\n",
|
|
|
|
" }\n",
|
|
|
|
"ax7.set_xlim([8,14])\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
"ax8.plot(df_beach.tide, n,color='#999999')\n",
|
|
|
|
|
|
|
|
"ax8.set_title('Tide \\& surge')\n",
|
|
|
|
|
|
|
|
"ax8.set_xlabel('Elevation (m AHD)')\n",
|
|
|
|
|
|
|
|
"ax8.set_xlim([0,2])\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
"plt.tight_layout()\n",
|
|
|
|
|
|
|
|
"f.subplots_adjust(top=0.88)\n",
|
|
|
|
|
|
|
|
"f.suptitle(beach)\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
"# # Print to figure\n",
|
|
|
|
|
|
|
|
"plt.savefig('07_{}.png'.format(beach), dpi=600, bbox_inches='tight')\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"plt.show()\n",
|
|
|
|
" for label in slope_models:\n",
|
|
|
|
"plt.close()"
|
|
|
|
" model = slope_models[label]\n",
|
|
|
|
|
|
|
|
" df_beta = impacts['forecasted'][model].merge(\n",
|
|
|
|
|
|
|
|
" twls['forecasted'][model], on=['site_id', 'datetime'], how='left')\n",
|
|
|
|
|
|
|
|
" df_beta = df_beta.loc[df_beta.index.str.contains(beach)]\n",
|
|
|
|
|
|
|
|
" ax5.plot(df_beta.beta, n, label=label, linewidth=models_linewidth)\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" ax5.set_title(r'$\\beta$')\n",
|
|
|
|
|
|
|
|
" ax5.set_xlabel('Beach slope')\n",
|
|
|
|
|
|
|
|
" ax5.legend(loc='lower center', bbox_to_anchor=(0.5, 1.1))\n",
|
|
|
|
|
|
|
|
" # ax5.set_xlim([0, 0.15])\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" # Need to chose a model to extract environmental parameters at maximum R_high time\n",
|
|
|
|
|
|
|
|
" model = 'premean_slope_sto06'\n",
|
|
|
|
|
|
|
|
" df_beach = impacts['forecasted'][model].merge(\n",
|
|
|
|
|
|
|
|
" twls['forecasted'][model], on=['site_id', 'datetime'], how='left')\n",
|
|
|
|
|
|
|
|
" df_beach = df_beach.loc[df_beach.index.str.contains(beach)]\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" # Wave height, wave period\n",
|
|
|
|
|
|
|
|
" ax6.plot(df_beach.Hs0, n, color='#999999')\n",
|
|
|
|
|
|
|
|
" ax6.set_title('$H_{s0}$')\n",
|
|
|
|
|
|
|
|
" ax6.set_xlabel('Sig. wave height (m)')\n",
|
|
|
|
|
|
|
|
" ax6.set_xlim([3, 5])\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" ax7.plot(df_beach.Tp, n, color='#999999')\n",
|
|
|
|
|
|
|
|
" ax7.set_title('$T_{p}$')\n",
|
|
|
|
|
|
|
|
" ax7.set_xlabel('Peak wave period (s)')\n",
|
|
|
|
|
|
|
|
" ax7.set_xlim([8, 14])\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" ax8.plot(df_beach.tide, n, color='#999999')\n",
|
|
|
|
|
|
|
|
" ax8.set_title('Tide \\& surge')\n",
|
|
|
|
|
|
|
|
" ax8.set_xlabel('Elevation (m AHD)')\n",
|
|
|
|
|
|
|
|
" ax8.set_xlim([0, 2])\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" plt.tight_layout()\n",
|
|
|
|
|
|
|
|
" f.subplots_adjust(top=0.88)\n",
|
|
|
|
|
|
|
|
" f.suptitle(beach.replace('_', '\\_'))\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" # Set minor axis ticks on each plot\n",
|
|
|
|
|
|
|
|
" ax1.yaxis.set_minor_locator(MultipleLocator(1))\n",
|
|
|
|
|
|
|
|
" ax1.yaxis.grid(True, which='minor', linestyle='--', alpha=0.1)\n",
|
|
|
|
|
|
|
|
" ax2.yaxis.grid(True, which='minor', linestyle='--', alpha=0.1)\n",
|
|
|
|
|
|
|
|
" ax3.yaxis.grid(True, which='minor', linestyle='--', alpha=0.1)\n",
|
|
|
|
|
|
|
|
" ax4.yaxis.grid(True, which='minor', linestyle='--', alpha=0.1)\n",
|
|
|
|
|
|
|
|
" ax5.yaxis.grid(True, which='minor', linestyle='--', alpha=0.1)\n",
|
|
|
|
|
|
|
|
" ax6.yaxis.grid(True, which='minor', linestyle='--', alpha=0.1)\n",
|
|
|
|
|
|
|
|
" ax7.yaxis.grid(True, which='minor', linestyle='--', alpha=0.1)\n",
|
|
|
|
|
|
|
|
" ax8.yaxis.grid(True, which='minor', linestyle='--', alpha=0.1)\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
" # # Print to figure\n",
|
|
|
|
|
|
|
|
" plt.savefig('07_{}.png'.format(beach), dpi=600, bbox_inches='tight')\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
"# plt.show()\n",
|
|
|
|
|
|
|
|
" plt.close()\n",
|
|
|
|
|
|
|
|
" print('Done: {}'.format(beach))\n",
|
|
|
|
|
|
|
|
"print('Done!')"
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -393,6 +486,13 @@
|
|
|
|
"Use sklearn metrics to generate classification reports for each forecasting model."
|
|
|
|
"Use sklearn metrics to generate classification reports for each forecasting model."
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
|
|
|
"metadata": {},
|
|
|
|
|
|
|
|
"outputs": [],
|
|
|
|
|
|
|
|
"source": []
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"execution_count": null,
|
|
|
@ -407,7 +507,7 @@
|
|
|
|
"# Convert storm regimes to categorical datatype\n",
|
|
|
|
"# Convert storm regimes to categorical datatype\n",
|
|
|
|
"cat_type = CategoricalDtype(\n",
|
|
|
|
"cat_type = CategoricalDtype(\n",
|
|
|
|
" categories=['swash', 'collision', 'overwash', 'inundation'], ordered=True)\n",
|
|
|
|
" categories=['swash', 'collision', 'overwash', 'inundation'], ordered=True)\n",
|
|
|
|
"df_obs.storm_regime = df_obs_impacts.storm_regime.astype(cat_type)\n",
|
|
|
|
"df_obs.storm_regime = df_obs.storm_regime.astype(cat_type)\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"for model in impacts['forecasted']:\n",
|
|
|
|
"for model in impacts['forecasted']:\n",
|
|
|
|
" df_for = impacts['forecasted'][model]\n",
|
|
|
|
" df_for = impacts['forecasted'][model]\n",
|
|
|
|