|
|
|
@ -25,20 +25,21 @@ def parse_crest_toes(df_raw_features, df_profiles):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# Puts profiles_features_csv into format expected by rest of analysis
|
|
|
|
|
df_crest_toes = df_raw_features.reset_index().melt(id_vars=['site_id'],
|
|
|
|
|
value_vars=['prestorm_dune_crest_x', 'prestorm_dune_toe_x',
|
|
|
|
|
'poststorm_dune_crest_x', 'poststorm_dune_toe_x'])
|
|
|
|
|
df_crest_toes['profile_type'] = df_crest_toes.variable.str.extract(r'(prestorm|poststorm)')
|
|
|
|
|
df_crest_toes['point_type'] = df_crest_toes.variable.str.extract(r'(dune_crest_x|dune_toe_x)')
|
|
|
|
|
df_crest_toes = df_crest_toes.drop(columns=['variable'])
|
|
|
|
|
df_crest_toes = df_crest_toes.sort_values('site_id')
|
|
|
|
|
df_crest_toes = df_crest_toes.set_index(['site_id', 'profile_type', 'point_type'])
|
|
|
|
|
df_crest_toes = df_raw_features.reset_index().melt(
|
|
|
|
|
id_vars=["site_id"],
|
|
|
|
|
value_vars=["prestorm_dune_crest_x", "prestorm_dune_toe_x", "poststorm_dune_crest_x", "poststorm_dune_toe_x"],
|
|
|
|
|
)
|
|
|
|
|
df_crest_toes["profile_type"] = df_crest_toes.variable.str.extract(r"(prestorm|poststorm)")
|
|
|
|
|
df_crest_toes["point_type"] = df_crest_toes.variable.str.extract(r"(dune_crest_x|dune_toe_x)")
|
|
|
|
|
df_crest_toes = df_crest_toes.drop(columns=["variable"])
|
|
|
|
|
df_crest_toes = df_crest_toes.sort_values("site_id")
|
|
|
|
|
df_crest_toes = df_crest_toes.set_index(["site_id", "profile_type", "point_type"])
|
|
|
|
|
df_crest_toes = df_crest_toes.unstack()
|
|
|
|
|
df_crest_toes.columns = df_crest_toes.columns.droplevel()
|
|
|
|
|
|
|
|
|
|
# Now let's calculate the corresponding z elevations for each of our x coordinates
|
|
|
|
|
for site_id in df_crest_toes.index.get_level_values("site_id").unique():
|
|
|
|
|
logger.info('Calculating dune toe/crest z elevations for {}'.format(site_id))
|
|
|
|
|
logger.info("Calculating dune toe/crest z elevations for {}".format(site_id))
|
|
|
|
|
|
|
|
|
|
# Get profile for this site
|
|
|
|
|
idx = pd.IndexSlice
|
|
|
|
@ -58,9 +59,9 @@ def parse_crest_toes(df_raw_features, df_profiles):
|
|
|
|
|
df_z = df_profile.loc[idx[site_id, param, x_val], :]
|
|
|
|
|
if df_z.empty:
|
|
|
|
|
if param == "prestorm":
|
|
|
|
|
new_param = 'poststorm'
|
|
|
|
|
new_param = "poststorm"
|
|
|
|
|
elif param == "poststorm":
|
|
|
|
|
new_param = 'prestorm'
|
|
|
|
|
new_param = "prestorm"
|
|
|
|
|
z_val = df_profile.loc[idx[site_id, new_param, x_val], :].z
|
|
|
|
|
else:
|
|
|
|
|
z_val = df_z.z
|
|
|
|
@ -80,6 +81,7 @@ def parse_crest_toes(df_raw_features, df_profiles):
|
|
|
|
|
|
|
|
|
|
return df_crest_toes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_dune_crest_toes(df_sites, crest_mat, toe_mat):
|
|
|
|
|
"""
|
|
|
|
|
:param df_sites:
|
|
|
|
@ -128,7 +130,6 @@ def parse_dune_crest_toes(df_sites, crest_mat, toe_mat):
|
|
|
|
|
return df_profile_features
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_waves(waves_mat):
|
|
|
|
|
"""
|
|
|
|
|
Parses the raw waves.mat file and returns a pandas dataframe
|
|
|
|
@ -433,7 +434,6 @@ def create_crest_toes(profile_features_csv, profiles_csv, output_file):
|
|
|
|
|
logger.info("Created %s", output_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.command(short_help="create profiles.csv")
|
|
|
|
|
@click.option("--profiles-mat", required=True, help=".mat file containing beach profiles")
|
|
|
|
|
@click.option("--profiles-output-file", required=True, help="where to save profiles.csv")
|
|
|
|
|