From 6912c50a49df5ccf47be21d6f2b056d13743b64c Mon Sep 17 00:00:00 2001 From: Chris Leaman Date: Wed, 19 Dec 2018 15:54:59 +1100 Subject: [PATCH] Use dune crest for mean slope calculation if no dune toe --- src/analysis/forecast_twl.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/analysis/forecast_twl.py b/src/analysis/forecast_twl.py index 9e6dbc3..4628daa 100644 --- a/src/analysis/forecast_twl.py +++ b/src/analysis/forecast_twl.py @@ -51,11 +51,23 @@ def forecast_twl( how="inner", ) df_temp["mhw"] = 0.5 + + # When calculating mean slope, we go from the dune toe to mhw. However, in some profiles, the dune toe is not + # defined. In these cases, we should go to the dune crest + df_temp['top_elevation'] = df_temp['dune_toe_z'] + df_temp.loc[df_temp.dune_toe_z.isnull(), 'top_elevation'] = df_temp.loc[df_temp.dune_toe_z.isnull(), + 'dune_crest_z'] + df_temp['top_x'] = df_temp['dune_toe_x'] + df_temp.loc[df_temp.dune_toe_x.isnull(), 'top_x'] = df_temp.loc[df_temp.dune_toe_x.isnull(), + 'dune_crest_x'] + with Pool(processes=n_processes) as pool: results = pool.starmap( mean_slope_for_site_id, - [(site_id, df_temp, df_profiles, "dune_toe_z", "dune_toe_x", "mhw") for site_id in site_ids], + [(site_id, df_temp, df_profiles, "top_elevation", "top_x", "mhw") for site_id in site_ids], ) + + df_twl["beta"] = pd.concat(results) # Estimate runup