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.
128 lines
4.6 KiB
Makefile
128 lines
4.6 KiB
Makefile
###############################
|
|
# Load environment variables
|
|
|
|
include .env
|
|
export $(shell sed 's/=.*//' .env)
|
|
CURRENT_DIR = $(shell pwd)
|
|
|
|
|
|
###############################
|
|
# Create python virtual environment
|
|
|
|
. PHONY: venv_init
|
|
|
|
venv-init: ##@environment Setup virtual environment
|
|
pip install pipenv
|
|
pipenv --python 3.7
|
|
pipenv install
|
|
|
|
|
|
###############################
|
|
# Get data from network drive
|
|
|
|
push-data: ##@data Copies data from ./data/ to data backup directory
|
|
rclone copy ./data/ $(DATA_BACKUP_DIR) --exclude "*.las" --progress
|
|
|
|
pull-data: ##@data Copies data from data backup directory to ./data/
|
|
# We probably don't want to pull the raw LIDAR .las files, so lets exclude them
|
|
rclone copy $(DATA_BACKUP_DIR) ./data/ --exclude "*.las" --progress
|
|
|
|
|
|
###############################
|
|
# Process data
|
|
.PHONY: process-mat
|
|
|
|
process-mat: ./data/interim/sites.csv ./data/interim/waves.csv ./data/interim/profiles.csv ./data/interim/tides.csv ##@data Process all .mat to .csv
|
|
|
|
# Calculates beach orientations at each profile
|
|
./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"
|
|
|
|
# Produces a .csv of sites where our beach cross-sections are located
|
|
./data/interim/sites.csv: ./data/raw/processed_shorelines/*.mat
|
|
pipenv run python ./src/data/parse_mat.py create-sites-csv \
|
|
--waves-mat "./data/raw/processed_shorelines/waves.mat" \
|
|
--tides-mat "./data/raw/processed_shorelines/tides.mat" \
|
|
--profiles-mat "./data/raw/processed_shorelines/profiles.mat" \
|
|
--orientations-mat "./data/raw/processed_shorelines/orientations.mat" \
|
|
--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 ./src/data/parse_mat.py
|
|
pipenv run python ./src/data/parse_mat.py create-waves-csv \
|
|
--waves-mat "./data/raw/processed_shorelines/waves.mat" \
|
|
--sites-csv "./data/interim/sites.csv" \
|
|
--output-file "./data/interim/waves.csv"
|
|
|
|
# Produces a .csv of profiles for each site
|
|
./data/interim/profiles.csv: ./data/interim/sites.csv ./data/raw/processed_shorelines/profiles.mat ./src/data/parse_mat.py
|
|
pipenv run python ./src/data/parse_mat.py create-profiles-csv \
|
|
--profiles-mat "./data/raw/processed_shorelines/profiles.mat" \
|
|
--sites-csv "./data/interim/sites.csv" \
|
|
--output-file "./data/interim/profiles.csv"
|
|
|
|
# Produces a .csv of tides for each site
|
|
./data/interim/tides.csv: ./data/interim/sites.csv ./data/raw/processed_shorelines/tides.mat ./src/data/parse_mat.py
|
|
pipenv run python ./src/data/parse_mat.py create-tides-csv \
|
|
--tides-mat "./data/raw/processed_shorelines/tides.mat" \
|
|
--sites-csv "./data/interim/sites.csv" \
|
|
--output-file "./data/interim/tides.csv"
|
|
|
|
./data/interim/sites.shp : ./data/interim/sites.csv
|
|
pipenv run python ./src/data/csv_to_shp.py sites-csv-to-shp \
|
|
--input-csv "./data/interim/sites.csv" \
|
|
--output-shp "./data/interim/sites.shp"
|
|
|
|
#################################################################################
|
|
# PROJECT RULES #
|
|
#################################################################################
|
|
.PHONY: push-data parse_mat sites-csv-to-shp
|
|
|
|
|
|
mat-to-csv: ##@data Converts raw .mat files to .csv for python
|
|
cd ./src/data/ && python parse_mat.py
|
|
|
|
sites-csv-to-shp: ##@data Create the sites.shp from sites.csv
|
|
cd ./src/data && python csv_to_shp.py sites_csv_to_shp "..\..\data\interim\sites.csv" "..\..\data\interim\sites.shp"
|
|
|
|
|
|
###############################
|
|
# Misc commands
|
|
format: ./src/*.py ##@misc Check python file formatting
|
|
pipenv run black --line-length 120 "src/"
|
|
|
|
|
|
###############################
|
|
# Help command
|
|
|
|
.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"; }
|
|
|
|
help: ##@other Show this help.
|
|
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
|
|
|
|
|