Fix volume difference percent when difference equal to zero

develop
Chris Leaman 6 years ago
parent bc1778c473
commit 16ca2aa482

@ -154,12 +154,16 @@ def volume_change(df_profiles, df_profile_features, zone):
if np.isnan(diff_vol): if np.isnan(diff_vol):
diff_vol = 0 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, "prestorm_{}_vol".format(zone)] = prestorm_vol
df_vol_changes.loc[site_id, "poststorm_{}_vol".format(zone)] = poststorm_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, "{}_vol_change".format(zone)] = diff_vol
df_vol_changes.loc[site_id, "{}_pct_change".format(zone)] = ( df_vol_changes.loc[site_id, "{}_pct_change".format(zone)] = pct_change
diff_vol / prestorm_vol * 100
)
return df_vol_changes 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_raw_features = pd.read_csv(raw_profile_features_csv, index_col=[0])
df_observed_impacts = overwrite_impacts(df_observed_impacts, df_raw_features) df_observed_impacts = overwrite_impacts(df_observed_impacts, df_raw_features)
# TODO Calculate change in slopes, shoreline and volume
# Save dataframe to csv # Save dataframe to csv
df_observed_impacts.to_csv(output_file, float_format="%.4f") df_observed_impacts.to_csv(output_file, float_format="%.4f")

Loading…
Cancel
Save