|
|
|
@ -168,6 +168,10 @@ def parse_waves(waves_mat):
|
|
|
|
|
"P": mat_data["P"][i][j][0],
|
|
|
|
|
"Exs": mat_data["Exs"][i][j][0],
|
|
|
|
|
"Pxs": mat_data["Pxs"][i][j][0],
|
|
|
|
|
"Ecum": mat_data["Ecum"][i],
|
|
|
|
|
"Exscum": mat_data["Exscum"][i],
|
|
|
|
|
"Pcum": mat_data["Pxscum"][i],
|
|
|
|
|
"Pxscum": mat_data["Pxscum"][i],
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -432,21 +436,41 @@ def replace_unique_sites(df, df_sites):
|
|
|
|
|
return df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def split_site_wave_params(df_waves):
|
|
|
|
|
"""
|
|
|
|
|
When we parse the waves.mat file, the cumulative wave energy and power properties are given for each time step.
|
|
|
|
|
This is unnecessary, so let's extract them out of our dataframe and put them in their own seperate dataframe.
|
|
|
|
|
:param df_waves:
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
cols_to_extract = ["Ecum", "Exscum", "Pcum", "Pxscum"]
|
|
|
|
|
|
|
|
|
|
df_sites_waves = df_waves.loc[:, cols_to_extract].groupby(["site_id"]).first()
|
|
|
|
|
df_waves = df_waves.drop(columns=cols_to_extract, errors="ignore")
|
|
|
|
|
return df_waves, df_sites_waves
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.command(short_help="create waves.csv")
|
|
|
|
|
@click.option("--waves-mat", required=True, help=".mat file containing wave records")
|
|
|
|
|
@click.option(
|
|
|
|
|
"--sites-csv", required=True, help=".csv file description of cross section sites"
|
|
|
|
|
)
|
|
|
|
|
@click.option("--output-file", required=True, help="where to save waves.csv")
|
|
|
|
|
def create_waves_csv(waves_mat, sites_csv, output_file):
|
|
|
|
|
logger.info("Creating %s", output_file)
|
|
|
|
|
@click.option("--waves-output-file", required=True, help="where to save waves.csv")
|
|
|
|
|
@click.option(
|
|
|
|
|
"--sites-waves-output-file", required=True, help="where to save sites_waves.csv"
|
|
|
|
|
)
|
|
|
|
|
def create_waves_csv(waves_mat, sites_csv, waves_output_file, sites_waves_output_file):
|
|
|
|
|
logger.info("Creating %s", waves_output_file)
|
|
|
|
|
df_waves = parse_waves(waves_mat=waves_mat)
|
|
|
|
|
df_sites = pd.read_csv(sites_csv, index_col=[0])
|
|
|
|
|
df_waves = replace_unique_sites(df_waves, df_sites)
|
|
|
|
|
df_waves.set_index(["site_id", "datetime"], inplace=True)
|
|
|
|
|
df_waves.sort_index(inplace=True)
|
|
|
|
|
df_waves.to_csv(output_file)
|
|
|
|
|
logger.info("Created %s", output_file)
|
|
|
|
|
df_waves, df_sites_waves = split_site_wave_params(df_waves)
|
|
|
|
|
df_waves.to_csv(waves_output_file)
|
|
|
|
|
df_sites_waves.to_csv(sites_waves_output_file)
|
|
|
|
|
logger.info("Created %s", waves_output_file)
|
|
|
|
|
logger.info("Created %s", sites_waves_output_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# @click.command(short_help="create profile_features.csv")
|
|
|
|
|