diff --git a/src/analysis/observed_storm_impacts.py b/src/analysis/observed_storm_impacts.py index 8bbe250..754cfcd 100644 --- a/src/analysis/observed_storm_impacts.py +++ b/src/analysis/observed_storm_impacts.py @@ -154,12 +154,16 @@ def volume_change(df_profiles, df_profile_features, zone): if np.isnan(diff_vol): diff_vol = 0 + # Base pct change on diff volume + if diff_vol == 0: + pct_change = 0 + else: + pct_change = diff_vol / prestorm_vol * 100 + df_vol_changes.loc[site_id, "prestorm_{}_vol".format(zone)] = prestorm_vol df_vol_changes.loc[site_id, "poststorm_{}_vol".format(zone)] = poststorm_vol df_vol_changes.loc[site_id, "{}_vol_change".format(zone)] = diff_vol - df_vol_changes.loc[site_id, "{}_pct_change".format(zone)] = ( - diff_vol / prestorm_vol * 100 - ) + df_vol_changes.loc[site_id, "{}_pct_change".format(zone)] = pct_change return df_vol_changes @@ -255,6 +259,8 @@ def create_observed_impacts( df_raw_features = pd.read_csv(raw_profile_features_csv, index_col=[0]) df_observed_impacts = overwrite_impacts(df_observed_impacts, df_raw_features) + # TODO Calculate change in slopes, shoreline and volume + # Save dataframe to csv df_observed_impacts.to_csv(output_file, float_format="%.4f")