|
|
@ -22,6 +22,13 @@ def return_first_or_nan(l):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def volume_change(df_profiles, df_profile_features, zone):
|
|
|
|
def volume_change(df_profiles, df_profile_features, zone):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Calculates how much the volume change there is between prestrom and post storm profiles.
|
|
|
|
|
|
|
|
:param df_profiles:
|
|
|
|
|
|
|
|
:param df_profile_features:
|
|
|
|
|
|
|
|
:param zone: Either 'swash' or 'dune_face'
|
|
|
|
|
|
|
|
:return:
|
|
|
|
|
|
|
|
"""
|
|
|
|
logger.info('Calculating change in beach volume in {} zone'.format(zone))
|
|
|
|
logger.info('Calculating change in beach volume in {} zone'.format(zone))
|
|
|
|
|
|
|
|
|
|
|
|
df_vol_changes = pd.DataFrame(index=df_profile_features.index)
|
|
|
|
df_vol_changes = pd.DataFrame(index=df_profile_features.index)
|
|
|
@ -96,27 +103,19 @@ def beach_volume(x, z, x_min=np.NINF, x_max=np.inf):
|
|
|
|
return simps(z_masked, x_masked)
|
|
|
|
return simps(z_masked, x_masked)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def impacts_from_profiles(df_profiles, df_profile_features):
|
|
|
|
|
|
|
|
# Impacts should be per site, so use the profile_features as the base index.
|
|
|
|
|
|
|
|
df_observed_impacts = pd.DataFrame(index=df_profile_features.index)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Swash zone volume change
|
|
|
|
|
|
|
|
prestorm_swash_vol, poststorm_swash_vol = volume_change(df_profiles, df_profile_features, zone='swash')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Dune volume change
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If no dune volume change, then swash zone
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def storm_regime(df_observed_impacts):
|
|
|
|
def storm_regime(df_observed_impacts):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Returns the dataframe with an additional column of storm impacts based on the Storm Impact Scale. Refer to
|
|
|
|
|
|
|
|
Sallenger (2000) for details.
|
|
|
|
|
|
|
|
:param df_observed_impacts:
|
|
|
|
|
|
|
|
:return:
|
|
|
|
|
|
|
|
"""
|
|
|
|
logger.info('Getting observed storm regimes')
|
|
|
|
logger.info('Getting observed storm regimes')
|
|
|
|
df_observed_impacts.loc[df_observed_impacts.swash_vol_change < 3,'storm_regime'] = 'swash'
|
|
|
|
df_observed_impacts.loc[df_observed_impacts.swash_vol_change < 3, 'storm_regime'] = 'swash'
|
|
|
|
df_observed_impacts.loc[df_observed_impacts.dune_face_vol_change > 3, 'storm_regime'] = 'collision'
|
|
|
|
df_observed_impacts.loc[df_observed_impacts.dune_face_vol_change > 3, 'storm_regime'] = 'collision'
|
|
|
|
return df_observed_impacts
|
|
|
|
return df_observed_impacts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
logger.info('Importing existing data')
|
|
|
|
logger.info('Importing existing data')
|
|
|
|
data_folder = './data/interim'
|
|
|
|
data_folder = './data/interim'
|
|
|
@ -129,10 +128,10 @@ if __name__ == '__main__':
|
|
|
|
logger.info('Getting pre/post storm volumes')
|
|
|
|
logger.info('Getting pre/post storm volumes')
|
|
|
|
df_swash_vol_changes = volume_change(df_profiles, df_profile_features, zone='swash')
|
|
|
|
df_swash_vol_changes = volume_change(df_profiles, df_profile_features, zone='swash')
|
|
|
|
df_dune_face_vol_changes = volume_change(df_profiles, df_profile_features, zone='dune_face')
|
|
|
|
df_dune_face_vol_changes = volume_change(df_profiles, df_profile_features, zone='dune_face')
|
|
|
|
df_observed_impacts = df_observed_impacts.join([df_swash_vol_changes, df_dune_face_vol_changes ])
|
|
|
|
df_observed_impacts = df_observed_impacts.join([df_swash_vol_changes, df_dune_face_vol_changes])
|
|
|
|
|
|
|
|
|
|
|
|
# TODO Classify regime based on volume changes
|
|
|
|
# Classify regime based on volume changes
|
|
|
|
df_observed_impacts = storm_regime(df_observed_impacts)
|
|
|
|
df_observed_impacts = storm_regime(df_observed_impacts)
|
|
|
|
|
|
|
|
|
|
|
|
# TODO Save dataframe to csv
|
|
|
|
# Save dataframe to csv
|
|
|
|
df_observed_impacts.to_csv(os.path.join(data_folder, 'impacts_observed.csv'))
|
|
|
|
df_observed_impacts.to_csv(os.path.join(data_folder, 'impacts_observed.csv'))
|
|
|
|