Refactor PYTHON_CLI command

develop
Chris Leaman 6 years ago
parent 2d22734bfa
commit 9755810f40

@ -46,149 +46,116 @@ pull-data: ##@data Copies data from data backup directory to ./data/
# Process data # Process data
.PHONY: process-mat .PHONY: process-mat
# Command for activating our virtual environment and calling the CLI entry point
PYTHON_CLI = activate ./.venv && python ./src/cli.py
impacts: ./data/interim/impacts_forecasted_foreshore_slope_sto06.csv ./data/interim/impacts_forecasted_mean_slope_sto06.csv ./data/interim/impacts_observed.csv ##@products makes obsered and forecasted impacts impacts: ./data/interim/impacts_forecasted_foreshore_slope_sto06.csv ./data/interim/impacts_forecasted_mean_slope_sto06.csv ./data/interim/impacts_observed.csv ##@products makes obsered and forecasted impacts
# Calculates beach orientations at each profile
### Parses raw matfiles
./data/raw/processed_shorelines/orientations.mat: ./data/raw/processed_shorelines/profiles.mat ./data/raw/processed_shorelines/orientations.mat: ./data/raw/processed_shorelines/profiles.mat
$(MATLAB_PATH) -nosplash -r "cd $(CURRENT_DIR); run('./src/data/beach_orientations.m'); quit" $(MATLAB_PATH) -nosplash -r "cd $(CURRENT_DIR); run('./src/data/beach_orientations.m'); quit"
# # Produces a .csv of sites where our beach cross-sections are located
# ./data/interim/sites.csv ./data/interim/profiles.csv: ./data/raw/processed_shorelines/profiles.mat
# activate ./.venv && python ./src/data/parse_mat.py create-sites-and-profiles-csv \
# --profiles-mat "./data/raw/processed_shorelines/profiles.mat" \
# --profiles-output-file "./data/interim/profiles.csv" \
# --sites-output-file "./data/interim/sites.csv"
# Produces a .csv of sites where our beach cross-sections are located
./data/interim/sites.csv ./data/interim/profiles.csv: ./data/raw/processed_shorelines/profiles.mat ./data/interim/sites.csv ./data/interim/profiles.csv: ./data/raw/processed_shorelines/profiles.mat
activate ./.venv && python ./src/cli.py create-sites-and-profiles-csv \ $(PYTHON_CLI) create-sites-and-profiles-csv \
--profiles-mat "./data/raw/processed_shorelines/profiles.mat" \ --profiles-mat "./data/raw/processed_shorelines/profiles.mat" \
--profiles-output-file "./data/interim/profiles.csv" \ --profiles-output-file "./data/interim/profiles.csv" \
--sites-output-file "./data/interim/sites.csv" --sites-output-file "./data/interim/sites.csv"
# Produces a .csv of waves for each site
./data/interim/waves.csv: ./data/interim/sites.csv ./data/raw/processed_shorelines/waves.mat ./data/interim/waves.csv: ./data/interim/sites.csv ./data/raw/processed_shorelines/waves.mat
activate ./.venv && python ./src/cli.py create-waves-csv \ $(PYTHON_CLI) create-waves-csv \
--waves-mat "./data/raw/processed_shorelines/waves.mat" \ --waves-mat "./data/raw/processed_shorelines/waves.mat" \
--sites-csv "./data/interim/sites.csv" \ --sites-csv "./data/interim/sites.csv" \
--output-file "./data/interim/waves.csv" --output-file "./data/interim/waves.csv"
# Produces a .csv of tides for each site
./data/interim/tides.csv: ./data/interim/sites.csv ./data/raw/processed_shorelines/tides.mat ./data/interim/tides.csv: ./data/interim/sites.csv ./data/raw/processed_shorelines/tides.mat
activate ./.venv && python ./src/cli.py create-tides-csv \ $(PYTHON_CLI) create-tides-csv \
--tides-mat "./data/raw/processed_shorelines/tides.mat" \ --tides-mat "./data/raw/processed_shorelines/tides.mat" \
--sites-csv "./data/interim/sites.csv" \ --sites-csv "./data/interim/sites.csv" \
--output-file "./data/interim/tides.csv" --output-file "./data/interim/tides.csv"
# Creates a .shp of our sites to load into QGis ./data/interim/profile_features_crest_toes.csv : ./data/raw/profile_features_chris_leaman/profile_features_chris_leaman.csv
./data/interim/sites.shp: ./data/interim/sites.csv $(PYTHON_CLI) create-crest-toes \
activate ./.venv && python ./src/cli.py sites-csv-to-shp \ --profile-features-csv "./data/raw/profile_features_chris_leaman/profile_features_chris_leaman.csv" \
--input-csv "./data/interim/sites.csv" \ --profiles-csv "./data/interim/profiles.csv" \
--output-shp "./data/interim/sites.shp" --output-file "./data/interim/profile_features_crest_toes.csv" \
# # Creates a .csv of our dune toe and crest profile features from .shp file
# ./data/interim/profile_features.csv: ./data/raw/profile_features/dune_crests.shp ./data/raw/profile_features/dune_toes.shp ./data/interim/sites.csv ./data/interim/profiles.csv ### TWLs
# activate ./.venv && python ./src/cli.py create-profile-features \
# --dune-crest-shp "./data/raw/profile_features/dune_crests.shp" \ ./data/interim/twl_foreshore_slope_sto06.csv: ./data/interim/waves.csv ./data/interim/tides.csv ./data/interim/profiles.csv ./data/interim/sites.csv ./data/interim/profile_features_crest_toes.csv
# --dune-toe-shp "./data/raw/profile_features/dune_toes.shp" \ $(PYTHON_CLI) create-twl-forecast \
# --sites-csv "./data/interim/sites.csv" \
# --profiles-csv "./data/interim/profiles.csv" \
# --output-csv "./data/interim/profile_features.csv"
# Create a .csv of our dune toe and crest profile features from Tom Beuzen's .mat file
# Also apply an overwrite of some values, using an excel sheet
./data/interim/profile_features.csv: ./data/raw/profile_features_tom_beuzen/*.mat ./data/interim/sites.csv
activate ./.venv && python ./src/cli.py create-profile-features \
--crest-mat "./data/raw/profile_features_tom_beuzen/J16_DuneCrest.mat" \
--toe-mat "./data/raw/profile_features_tom_beuzen/J16_DuneToe.mat" \
--sites-csv "./data/interim/sites.csv" \
--output-file "./data/interim/profile_features.csv" \
&& python ./src/cli.py apply-profile-features-overwrite \
--interim_file "./data/interim/profile_features.csv" \
--overwrite_file "./data/raw/profile_features_chris_leaman/profile_features_chris_leaman.xlsx" \
--profile_file "./data/interim/profiles.csv"
# Creates a forecast of twl using sto06 and prestorm time varying prestorm foreshore slope
./data/interim/twl_foreshore_slope_sto06.csv: ./data/interim/waves.csv ./data/interim/tides.csv ./data/interim/profiles.csv ./data/interim/sites.csv ./data/interim/profile_features.csv
activate ./.venv && python ./src/cli.py create-twl-forecast \
--waves-csv "./data/interim/waves.csv" \ --waves-csv "./data/interim/waves.csv" \
--tides-csv "./data/interim/tides.csv" \ --tides-csv "./data/interim/tides.csv" \
--profiles-csv "./data/interim/profiles.csv" \ --profiles-csv "./data/interim/profiles.csv" \
--profile-features-csv "./data/interim/profile_features.csv" \ --profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--runup-function "sto06" \ --runup-function "sto06" \
--slope "foreshore" \ --slope "foreshore" \
--profile-type "prestorm" \ --profile-type "prestorm" \
--output-file "./data/interim/twl_foreshore_slope_sto06.csv" --output-file "./data/interim/twl_foreshore_slope_sto06.csv"
./data/interim/twl_mean_slope_sto06.csv: ./data/interim/waves.csv ./data/interim/tides.csv ./data/interim/profiles.csv ./data/interim/sites.csv ./data/interim/profile_features.csv ./data/interim/twl_mean_slope_sto06.csv: ./data/interim/waves.csv ./data/interim/tides.csv ./data/interim/profiles.csv ./data/interim/sites.csv ./data/interim/profile_features_crest_toes.csv
activate ./.venv && python ./src/cli.py create-twl-forecast \ $(PYTHON_CLI) create-twl-forecast \
--waves-csv "./data/interim/waves.csv" \ --waves-csv "./data/interim/waves.csv" \
--tides-csv "./data/interim/tides.csv" \ --tides-csv "./data/interim/tides.csv" \
--profiles-csv "./data/interim/profiles.csv" \ --profiles-csv "./data/interim/profiles.csv" \
--profile-features-csv "./data/interim/profile_features.csv" \ --profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--runup-function "sto06" \ --runup-function "sto06" \
--slope "mean" \ --slope "mean" \
--profile-type "prestorm" \ --profile-type "prestorm" \
--output-file "./data/interim/twl_mean_slope_sto06.csv" --output-file "./data/interim/twl_mean_slope_sto06.csv"
# ./data/interim/twl_poststorm_mean_slope_sto06.csv: ./data/interim/waves.csv ./data/interim/tides.csv ./data/interim/profiles.csv ./data/interim/sites.csv ./data/interim/profile_features.csv
# activate ./.venv && python ./src/cli.py create-twl-forecast \ ### IMPACTS
# --waves-csv "./data/interim/waves.csv" \
# --tides-csv "./data/interim/tides.csv" \ ./data/interim/impacts_observed.csv: ./data/interim/profiles.csv ./data/interim/profile_features_crest_toes.csv ./data/raw/profile_features_chris_leaman/profile_features_chris_leaman.csv
# --profiles-csv "./data/interim/profiles.csv" \ $(PYTHON_CLI) create-observed-impacts \
# --profile-features-csv "./data/interim/profile_features.csv" \
# --runup-function "sto06" \
# --slope "mean" \
# --profile-type "poststorm" \
# --output-file "./data/interim/twl_poststorm_mean_slope_sto06.csv"
./data/interim/impacts_observed.csv: ./data/interim/profiles.csv ./data/interim/profile_features.csv
activate ./.venv && python ./src/cli.py create-observed-impacts \
--profiles-csv "./data/interim/profiles.csv" \ --profiles-csv "./data/interim/profiles.csv" \
--profile-features-csv "./data/interim/profile_features.csv" \ --profile-features-crest-toes-csv "./data/interim/profile_features_crest_toes.csv" \
--raw-profile-features-csv "./data/raw/profile_features_chris_leaman/profile_features_chris_leaman.csv" \
--output-file "./data/interim/impacts_observed.csv" --output-file "./data/interim/impacts_observed.csv"
./data/interim/impacts_forecasted_mean_slope_sto06.csv: ./data/interim/profile_features.csv ./data/interim/twl_mean_slope_sto06.csv ./data/interim/impacts_forecasted_mean_slope_sto06.csv: ./data/interim/profile_features_crest_toes.csv ./data/interim/twl_mean_slope_sto06.csv
activate ./.venv && python ./src/cli.py create-forecasted-impacts \ $(PYTHON_CLI) create-forecasted-impacts \
--profile-features-csv "./data/interim/profile_features.csv" \ --profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--forecasted-twl-csv "./data/interim/twl_mean_slope_sto06.csv" \ --forecasted-twl-csv "./data/interim/twl_mean_slope_sto06.csv" \
--output-file "./data/interim/impacts_forecasted_mean_slope_sto06.csv" --output-file "./data/interim/impacts_forecasted_mean_slope_sto06.csv"
./data/interim/impacts_forecasted_foreshore_slope_sto06.csv: ./data/interim/profile_features.csv ./data/interim/twl_foreshore_slope_sto06.csv ./data/interim/impacts_forecasted_foreshore_slope_sto06.csv: ./data/interim/profile_features_crest_toes.csv ./data/interim/twl_foreshore_slope_sto06.csv
activate ./.venv && python ./src/cli.py create-forecasted-impacts \ $(PYTHON_CLI) create-forecasted-impacts \
--profile-features-csv "./data/interim/profile_features.csv" \ --profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--forecasted-twl-csv "./data/interim/twl_foreshore_slope_sto06.csv" \ --forecasted-twl-csv "./data/interim/twl_foreshore_slope_sto06.csv" \
--output-file "./data/interim/impacts_forecasted_foreshore_slope_sto06.csv" --output-file "./data/interim/impacts_forecasted_foreshore_slope_sto06.csv"
# ./data/interim/impacts_forecasted_poststorm_mean_slope_sto06.csv: ./data/interim/profile_features.csv ./data/interim/twl_foreshore_slope_sto06.csv
# activate ./.venv && python ./src/cli.py create-forecasted-impacts \
# --profile-features-csv "./data/interim/profile_features.csv" \
# --forecasted-twl-csv "./data/interim/twl_poststorm_mean_slope_sto06.csv" \
# --output-file "./data/interim/impacts_forecasted_poststorm_mean_slope_sto06.csv"
### GEOJSONs
geojsons: ./data/interim/impacts_forecasted_mean_slope_sto06.geojson ./data/interim/impacts_forecasted_mean_slope_sto06_R_high.geojson ./data/interim/profile_features_crest_toes.geojson ./data/interim/sites.geojson
./data/interim/impacts_forecasted_mean_slope_sto06.geojson: ./data/interim/impacts_forecasted_mean_slope_sto06.csv ./data/interim/impacts_forecasted_mean_slope_sto06.geojson: ./data/interim/impacts_forecasted_mean_slope_sto06.csv ./data/interim/impacts_observed.csv
activate ./.venv && python ./src/cli.py impacts-to-geojson \ $(PYTHON_CLI) impacts-to-geojson \
--sites-csv "./data/interim/sites.csv" \ --sites-csv "./data/interim/sites.csv" \
--observed-impacts-csv "./data/interim/impacts_observed.csv" \ --observed-impacts-csv "./data/interim/impacts_observed.csv" \
--forecast-impacts-csv "./data/interim/impacts_forecasted_mean_slope_sto06.csv" \ --forecast-impacts-csv "./data/interim/impacts_forecasted_mean_slope_sto06.csv" \
--output-geojson "./data/interim/impacts_forecasted_mean_slope_sto06.geojson" --output-geojson "./data/interim/impacts_forecasted_mean_slope_sto06.geojson"
./data/interim/impacts_forecasted_mean_slope_sto06_R_high.geojson: ./data/interim/impacts_forecasted_mean_slope_sto06.csv ./data/interim/impacts_forecasted_mean_slope_sto06_R_high.geojson: ./data/interim/impacts_forecasted_mean_slope_sto06.csv
activate ./.venv && python ./src/cli.py R-high-to-geojson \ $(PYTHON_CLI) r-high-to-geojson \
--sites-csv "./data/interim/sites.csv" \ --sites-csv "./data/interim/sites.csv" \
--profile-csv "./data/interim/profiles.csv" \ --profiles-csv "./data/interim/profiles.csv" \
--impacts-csv "./data/interim/impacts_forecasted_mean_slope_sto06" \ --crest-toes-csv "./data/interim/profile_features_crest_toes.csv" \
--impacts-csv "./data/interim/impacts_forecasted_mean_slope_sto06.csv" \
--output-geojson "./data/interim/impacts_forecasted_mean_slope_sto06_R_high.geojson" --output-geojson "./data/interim/impacts_forecasted_mean_slope_sto06_R_high.geojson"
./data/interim/profile_features.geojson: ./data/interim/profile_features.csv ./data/interim/profile_features_crest_toes.geojson: ./data/interim/profile_features_crest_toes.csv
activate ./.venv && python ./src/cli.py R-high-to-geojson \ $(PYTHON_CLI) profile-features-crest-toes-to-geojson \
--sites-csv "./data/interim/sites.csv" \ --sites-csv "./data/interim/sites.csv" \
--profile-features-csv "./data/interim/profile_features.csv" \ --profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--output-geojson "./data/interim/profile_features.geojson" --output-geojson "./data/interim/profile_features_crest_toes.geojson"
./data/interim/sites.geojson: ./data/interim/sites.csv ./data/interim/sites.geojson: ./data/interim/sites.csv
activate ./.venv && python ./src/cli.py sites-csv-to-geojson \ $(PYTHON_CLI) sites-csv-to-geojson \
--input-csv "./data/interim/sites.csv" \ --input-csv "./data/interim/sites.csv" \
--output-geojson "./data/interim/sites.geojson" --output-geojson "./data/interim/sites.geojson"

Loading…
Cancel
Save