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