diff --git a/src/data/profile_features.py b/src/data/profile_features.py index db901f3..02ee7d5 100644 --- a/src/data/profile_features.py +++ b/src/data/profile_features.py @@ -1,6 +1,6 @@ import os from functools import partial - +import click import fiona import numpy as np import pandas as pd @@ -8,6 +8,11 @@ import pyproj from shapely.geometry import LineString, Point from shapely.geometry import shape from shapely.ops import transform +import logging.config + + +logging.config.fileConfig("./src/logging.conf", disable_existing_loggers=False) +logger = logging.getLogger(__name__) def shapes_from_shp(shp_file): @@ -142,12 +147,26 @@ def parse_profile_features(df_sites, df_profiles, dune_crest_shp, dune_toe_shp): return df_profile_features -if __name__ == "__main__": - data_folder = "./data/interim" - df_sites = pd.read_csv(os.path.join(data_folder, "sites.csv"), index_col=[0]) - df_profiles = pd.read_csv(os.path.join(data_folder, "profiles.csv"), index_col=[0, 1, 2]) - - dune_crest_shp = "./data/raw/profile_features/dune_crests.shp" - dune_toe_shp = "./data/raw/profile_features/dune_toes.shp" +@click.command(short_help='create .csv of dune toe and crest positions') +@click.option("--dune-crest-shp", required=True, help=".csv file to convert") +@click.option("--dune-toe-shp", required=True, help="where to store .shp file") +@click.option("--sites-csv", required=True, help="where to store .shp file") +@click.option("--profiles-csv", required=True, help="where to store .shp file") +@click.option("--output-csv", required=True, help="where to store .shp file") +def create_profile_features(dune_crest_shp, dune_toe_shp, sites_csv, profiles_csv, output_csv): + logger.info("Creating .csv of dune crests and toes") + df_sites = pd.read_csv(sites_csv, index_col=[0]) + df_profiles = pd.read_csv(profiles_csv, index_col=[0, 1, 2]) df_profile_features = parse_profile_features(df_sites, df_profiles, dune_crest_shp, dune_toe_shp) - df_profile_features.to_csv("./data/interim/profile_features.csv") + df_profile_features.to_csv(output_csv) + logger.info("Done!") + + +@click.group() +def cli(): + pass + + +if __name__ == "__main__": + cli.add_command(create_profile_features) + cli()