From 821e5c34cf2986d1be4c5fc6250fcca3125be3e6 Mon Sep 17 00:00:00 2001 From: Chris Leaman Date: Wed, 13 Feb 2019 14:18:26 +1100 Subject: [PATCH] Include grain size inputs --- Makefile | 5 +++++ src/cli.py | 1 + src/data/parse_mat.py | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/Makefile b/Makefile index 0816220..fc8635f 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,11 @@ impacts: ./data/interim/impacts_forecasted_foreshore_slope_sto06.csv ./data/inte --profiles-csv "./data/interim/profiles.csv" \ --output-file "./data/interim/profile_features_crest_toes.csv" \ +./data/interim/sites_grain_size.csv : ./data/raw/grain_size/sites_grain_size.csv + $(PYTHON_CLI) create-grain-size-csv \ + --grain-size-csv "./data/raw/grain_size/sites_grain_size.csv" \ + --output-file "./data/interim/sites_grain_size.csv" \ + ### TWLs diff --git a/src/cli.py b/src/cli.py index c290548..0d29ad9 100644 --- a/src/cli.py +++ b/src/cli.py @@ -33,4 +33,5 @@ if __name__ == "__main__": cli.add_command(parse_mat.create_sites_and_profiles_csv) cli.add_command(parse_mat.create_tides_csv) cli.add_command(parse_mat.create_waves_csv) + cli.add_command(parse_mat.create_grain_size_csv) cli() diff --git a/src/data/parse_mat.py b/src/data/parse_mat.py index 2afa87a..855479b 100644 --- a/src/data/parse_mat.py +++ b/src/data/parse_mat.py @@ -546,6 +546,23 @@ def create_tides_csv(tides_mat, sites_csv, output_file): logger.info("Created %s", output_file) +@click.command(short_help="create sites_grain_size.csv") +@click.option( + "--grain-size-csv", + required=True, + help=".csv file description of cross section sites", +) +@click.option("--output-file", required=True, help="where to save sites_grain_size.csv") +def create_grain_size_csv(grain_size_csv, output_file): + logger.info("Creating %s", output_file) + df_sites_grain_size = pd.read_csv(grain_size_csv, index_col=[0]) + + # Calculate roughness, refer to Power et al (2018) + df_sites_grain_size["r"] = 2.5 * df_sites_grain_size["d_50"] + df_sites_grain_size.to_csv(output_file) + logger.info("Created %s", output_file) + + @click.group() def cli(): pass