Add function for estimating twl exceedence time

develop
Chris Leaman 6 years ago
parent f6c43fda38
commit 9f1b801687

@ -66,6 +66,18 @@ def storm_regime(df_forecasted_impacts):
return df_forecasted_impacts return df_forecasted_impacts
def twl_exceedence_time(df_profile_features, df_forecasted_twl, z_twl_col='R_high', z_exceedence_col='dune_toe_z'):
logger.info("Getting twl exceedence time")
df_dune_toes = df_profile_features.query('profile_type=="prestorm"').reset_index('profile_type')[
'dune_toe_z'].to_frame()
df_merged = df_forecasted_twl.merge(df_dune_toes,left_on=['site_id'],right_on=['site_id'])
return (df_merged[z_twl_col] >= df_merged[z_exceedence_col]).groupby('site_id').sum().rename(
'twl_{}_exceedance_hrs'.format(z_exceedence_col)).to_frame()
@click.command() @click.command()
@click.option("--profile-features-csv", required=True, help="") @click.option("--profile-features-csv", required=True, help="")
@click.option("--forecasted-twl-csv", required=True, help="") @click.option("--forecasted-twl-csv", required=True, help="")
@ -77,6 +89,11 @@ def create_forecasted_impacts(profile_features_csv, forecasted_twl_csv, output_f
df_forecasted_twl = pd.read_csv(forecasted_twl_csv, index_col=[0, 1]) df_forecasted_twl = pd.read_csv(forecasted_twl_csv, index_col=[0, 1])
df_forecasted_impacts = forecasted_impacts(df_profile_features, df_forecasted_twl) df_forecasted_impacts = forecasted_impacts(df_profile_features, df_forecasted_twl)
df_forecasted_impacts = df_profile_features.merge(twl_exceedence_time(df_profile_features, df_forecasted_twl),
left_on=['site_id'],
right_on=['site_id'])
df_forecasted_impacts.to_csv(output_file) df_forecasted_impacts.to_csv(output_file)
logger.info("Saved to %s", output_file) logger.info("Saved to %s", output_file)
logger.info("Done!") logger.info("Done!")

Loading…
Cancel
Save