You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

266 lines
12 KiB
Makefile

SHELL=cmd
6 years ago
###############################
# Load environment variables
include .env
export $(shell sed 's/=.*//' .env)
CURRENT_DIR = $(shell pwd)
###############################
# Create python virtual environment
6 years ago
.PHONY: venv-init
6 years ago
venv-init: ##@environment Setup virtual environment
conda env create -f environment.yml --prefix=.venv
6 years ago
.PHONY: venv-activate
venv-activate: ##@environment Activates the virtual environment
activate $(CURRENT_DIR)/.venv
6 years ago
.PHONY: venv-update
6 years ago
venv-update: ##@environment Updates to latest packages
conda update ipykernel && conda update --prefix .venv --all
6 years ago
.PHONY: venv-requirements-install
6 years ago
venv-requirements-install: ##@environment Ensures environment.yml packages are installed
conda env update
# To install new packages: conda install --prefix .venv PACKAGE
###############################
notebook: ##@notebooks Open jupyter notebook in venv
activate ./.venv && jupyter notebook
6 years ago
###############################
# Get data from network drive
.PHONY: push-data pull-data
push-data: ##@data Copies data from ./data/ to data backup directory
rclone copy ./data/ $(DATA_BACKUP_DIR) --exclude "*.las" --progress
# We probably don't want to pull the raw LIDAR .las files, so lets exclude them
pull-data: ##@data Copies data from data backup directory to ./data/
rclone copy $(DATA_BACKUP_DIR) ./data/ --exclude "*.las" --progress
6 years ago
###############################
# Process data
.PHONY: process-mat
# Command for activating our virtual environment and calling the CLI entry point
PYTHON_CLI = activate ./.venv && python ./src/cli.py
6 years ago
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
6 years ago
### Parses raw matfiles
6 years ago
./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"
./data/interim/sites.csv ./data/interim/profiles.csv: ./data/raw/processed_shorelines/profiles.mat
$(PYTHON_CLI) create-sites-and-profiles-csv \
6 years ago
--profiles-mat "./data/raw/processed_shorelines/profiles.mat" \
--profiles-output-file "./data/interim/profiles.csv" \
--sites-output-file "./data/interim/sites.csv"
6 years ago
./data/interim/waves.csv: ./data/interim/sites.csv ./data/raw/processed_shorelines/waves.mat
$(PYTHON_CLI) create-waves-csv \
6 years ago
--waves-mat "./data/raw/processed_shorelines/waves.mat" \
--sites-csv "./data/interim/sites.csv" \
--output-file "./data/interim/waves.csv"
./data/interim/tides.csv: ./data/interim/sites.csv ./data/raw/processed_shorelines/tides.mat
$(PYTHON_CLI) create-tides-csv \
6 years ago
--tides-mat "./data/raw/processed_shorelines/tides.mat" \
--sites-csv "./data/interim/sites.csv" \
--output-file "./data/interim/tides.csv"
./data/interim/profile_features_crest_toes.csv : ./data/raw/profile_features_chris_leaman/profile_features_chris_leaman.csv
$(PYTHON_CLI) create-crest-toes \
--profile-features-csv "./data/raw/profile_features_chris_leaman/profile_features_chris_leaman.csv" \
--profiles-csv "./data/interim/profiles.csv" \
--output-file "./data/interim/profile_features_crest_toes.csv" \
### TWLs
./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
$(PYTHON_CLI) create-twl-forecast \
--waves-csv "./data/interim/waves.csv" \
--tides-csv "./data/interim/tides.csv" \
--profiles-csv "./data/interim/profiles.csv" \
--profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--runup-function "sto06" \
--slope "foreshore" \
--profile-type "prestorm" \
--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_crest_toes.csv
$(PYTHON_CLI) create-twl-forecast \
--waves-csv "./data/interim/waves.csv" \
--tides-csv "./data/interim/tides.csv" \
--profiles-csv "./data/interim/profiles.csv" \
--profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--runup-function "sto06" \
--slope "mean" \
--profile-type "prestorm" \
--output-file "./data/interim/twl_mean_slope_sto06.csv"
./data/interim/twl_mean_slope_hol86.csv: ./data/interim/waves.csv ./data/interim/tides.csv ./data/interim/profiles.csv ./data/interim/sites.csv ./data/interim/profile_features_crest_toes.csv
$(PYTHON_CLI) create-twl-forecast \
--waves-csv "./data/interim/waves.csv" \
--tides-csv "./data/interim/tides.csv" \
--profiles-csv "./data/interim/profiles.csv" \
--profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--runup-function "hol86" \
--slope "mean" \
--profile-type "prestorm" \
--output-file "./data/interim/twl_mean_slope_hol86.csv"
./data/interim/twl_mean_slope_nie91.csv: ./data/interim/waves.csv ./data/interim/tides.csv ./data/interim/profiles.csv ./data/interim/sites.csv ./data/interim/profile_features_crest_toes.csv
$(PYTHON_CLI) create-twl-forecast \
--waves-csv "./data/interim/waves.csv" \
--tides-csv "./data/interim/tides.csv" \
--profiles-csv "./data/interim/profiles.csv" \
--profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--runup-function "nie91" \
--slope "mean" \
--profile-type "prestorm" \
--output-file "./data/interim/twl_mean_slope_nie91.csv"
### IMPACTS
./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
$(PYTHON_CLI) create-observed-impacts \
--profiles-csv "./data/interim/profiles.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"
./data/interim/impacts_forecasted_mean_slope_sto06.csv: ./data/interim/profile_features_crest_toes.csv ./data/interim/twl_mean_slope_sto06.csv
$(PYTHON_CLI) create-forecasted-impacts \
--profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--forecasted-twl-csv "./data/interim/twl_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_crest_toes.csv ./data/interim/twl_foreshore_slope_sto06.csv
$(PYTHON_CLI) create-forecasted-impacts \
--profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--forecasted-twl-csv "./data/interim/twl_foreshore_slope_sto06.csv" \
--output-file "./data/interim/impacts_forecasted_foreshore_slope_sto06.csv"
./data/interim/impacts_forecasted_mean_slope_hol86.csv: ./data/interim/profile_features_crest_toes.csv ./data/interim/twl_mean_slope_hol86.csv
$(PYTHON_CLI) create-forecasted-impacts \
--profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--forecasted-twl-csv "./data/interim/twl_mean_slope_hol86.csv" \
--output-file "./data/interim/impacts_forecasted_mean_slope_hol86.csv"
6 years ago
./data/interim/impacts_forecasted_mean_slope_nie91.csv: ./data/interim/profile_features_crest_toes.csv ./data/interim/twl_mean_slope_nie91.csv
$(PYTHON_CLI) create-forecasted-impacts \
--profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--forecasted-twl-csv "./data/interim/twl_mean_slope_nie91.csv" \
--output-file "./data/interim/impacts_forecasted_mean_slope_nie91.csv"
### GEOJSONs
geojsons: ./data/interim/impacts_forecasted_mean_slope_nie91.geojson ./data/interim/impacts_forecasted_mean_slope_nie91_R_high.geojson ./data/interim/impacts_forecasted_mean_slope_hol86.geojson ./data/interim/impacts_forecasted_mean_slope_hol86_R_high.geojson ./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_observed.csv
$(PYTHON_CLI) impacts-to-geojson \
--sites-csv "./data/interim/sites.csv" \
--observed-impacts-csv "./data/interim/impacts_observed.csv" \
--forecast-impacts-csv "./data/interim/impacts_forecasted_mean_slope_sto06.csv" \
--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
$(PYTHON_CLI) r-high-to-geojson \
--sites-csv "./data/interim/sites.csv" \
--profiles-csv "./data/interim/profiles.csv" \
--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"
./data/interim/impacts_forecasted_mean_slope_hol86.geojson: ./data/interim/impacts_forecasted_mean_slope_hol86.csv ./data/interim/impacts_observed.csv
$(PYTHON_CLI) impacts-to-geojson \
--sites-csv "./data/interim/sites.csv" \
--observed-impacts-csv "./data/interim/impacts_observed.csv" \
--forecast-impacts-csv "./data/interim/impacts_forecasted_mean_slope_hol86.csv" \
--output-geojson "./data/interim/impacts_forecasted_mean_slope_hol86.geojson"
./data/interim/impacts_forecasted_mean_slope_hol86_R_high.geojson: ./data/interim/impacts_forecasted_mean_slope_hol86.csv
$(PYTHON_CLI) r-high-to-geojson \
--sites-csv "./data/interim/sites.csv" \
--profiles-csv "./data/interim/profiles.csv" \
--crest-toes-csv "./data/interim/profile_features_crest_toes.csv" \
--impacts-csv "./data/interim/impacts_forecasted_mean_slope_hol86.csv" \
--output-geojson "./data/interim/impacts_forecasted_mean_slope_hol86_R_high.geojson"
./data/interim/impacts_forecasted_mean_slope_nie91.geojson: ./data/interim/impacts_forecasted_mean_slope_nie91.csv ./data/interim/impacts_observed.csv
$(PYTHON_CLI) impacts-to-geojson \
--sites-csv "./data/interim/sites.csv" \
--observed-impacts-csv "./data/interim/impacts_observed.csv" \
--forecast-impacts-csv "./data/interim/impacts_forecasted_mean_slope_nie91.csv" \
--output-geojson "./data/interim/impacts_forecasted_mean_slope_nie91.geojson"
./data/interim/impacts_forecasted_mean_slope_nie91_R_high.geojson: ./data/interim/impacts_forecasted_mean_slope_nie91.csv
$(PYTHON_CLI) r-high-to-geojson \
--sites-csv "./data/interim/sites.csv" \
--profiles-csv "./data/interim/profiles.csv" \
--crest-toes-csv "./data/interim/profile_features_crest_toes.csv" \
--impacts-csv "./data/interim/impacts_forecasted_mean_slope_nie91.csv" \
--output-geojson "./data/interim/impacts_forecasted_mean_slope_nie91_R_high.geojson"
./data/interim/profile_features_crest_toes.geojson: ./data/interim/profile_features_crest_toes.csv
$(PYTHON_CLI) profile-features-crest-toes-to-geojson \
--sites-csv "./data/interim/sites.csv" \
--profile-features-csv "./data/interim/profile_features_crest_toes.csv" \
--output-geojson "./data/interim/profile_features_crest_toes.geojson"
./data/interim/sites.geojson: ./data/interim/sites.csv
$(PYTHON_CLI) sites-csv-to-geojson \
--input-csv "./data/interim/sites.csv" \
--output-geojson "./data/interim/sites.geojson"
6 years ago
###############################
# Misc commands
format: ./src/*.py ##@misc Check python file formatting
6 years ago
activate ./.venv && black --line-length 120 "src/"
6 years ago
###############################
# Help command
6 years ago
.DEFAULT_GOAL := help
.PHONY: help
# Refer to https://gist.github.com/prwhite/8168133
#COLORS
GREEN := $(shell tput -Txterm setaf 2)
WHITE := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
# A category can be added with @category
HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
print "usage: make [target]\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; }
6 years ago
help: ##@other Show this help.
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)