PLOT_DIR = plots
PDF_PLOTS = error_dist_gaussian error_dist_lorentzian error_vs_speed illustrate_method interp2 interp4 interproot2 broadening_schematic dos_example dos_example_broadened dos_example_zoomed error_fits_si
PNG_PLOTS = si-merlin-2 si-merlin-6 si-merlin-exact si-merlin-variable

plots: $(PDF_PLOTS:%=$(PLOT_DIR)/%.pdf) $(PNG_PLOTS:%=$(PLOT_DIR)/%.png)

clean-plots:
	rm -fv plots/*
clean: clean-plots
	rm -fv data/si-powder.json

$(PLOT_DIR)/error_dist_gaussian.pdf: styles/base.mplstyle scripts/Error_distribution.py
	python scripts/Error_distribution.py
$(PLOT_DIR)/error_dist_lorentzian.pdf: plots/error_dist_gaussian.pdf

$(PLOT_DIR)/error_vs_speed.pdf: styles/base.mplstyle scripts/Error_vs_speed.py
	python scripts/Error_vs_speed.py

$(PLOT_DIR)/illustrate_method.pdf: styles/base.mplstyle scripts/Illustrate_method.py
	python scripts/Illustrate_method.py

$(PLOT_DIR)/interp2.pdf $(PLOT_DIR)/interp4.pdf $(PLOT_DIR)/interproot2.pdf: styles/base.mplstyle scripts/Interpolation_comparison.py
	python scripts/Interpolation_comparison.py

$(PLOT_DIR)/broadening_schematic.pdf: styles/base.mplstyle data/mp-200-20180417.yaml scripts/Broadening_schematic.py
	python scripts/Broadening_schematic.py

$(PLOT_DIR)/dos_example.pdf: styles/base.mplstyle data/mp-147-20180417.yaml scripts/DOS_example.py 
	python scripts/DOS_example.py
$(PLOT_DIR)/dos_example_broadened.pdf: $(PLOT_DIR)/dos_example.pdf

$(PLOT_DIR)/dos_example_zoomed.pdf: $(PLOT_DIR)/dos_example.pdf

$(PLOT_DIR)/error_fits_si.pdf: styles/base.mplstyle scripts/Error_fits_SI.py
	python scripts/Error_fits_SI.py

data/si-powder.json: data/mp-149-20180417.yaml scripts/resolution_2d.sh
	bash scripts/resolution_2d.sh

plots/si-merlin-2.png: data/si-powder.json

plots/si-merlin-6.png: data/si-powder.json

plots/si-merlin-exact.png: styles/base.mplstyle styles/merlin_plots.mplstyle scripts/MERLIN_resolution.py data/si-powder.json
	python scripts/MERLIN_resolution.py

# We want to use OpenMP parallelism for this calculation, so don't allow
# other plots to be calculated at the same time
.NOTPARALLEL: data/si-powder.json
