all : plot 
	sgn-manifold-cbc-bank-test-plot --output-prefix test --test test.h5

small-sky-bank.h5 : small-sky-bank.yaml
	sgn-manifold-cbc-bank --yaml $< --output-h5 $@ --verbose


small-sky-bank-refined.h5 : small-sky-bank.h5
	sgn-manifold-cbc-bank-check-coverage \
		--bank $< \
		--output-bank $@ \
		--match-resolution pn \
		--target-match 0.97 \
		--neighbors 16384 \
		--n-samples 1 \
		--max-iterations 100 \
		--mc-tolerance 0.01 \
		--processes 6 \
		--seed 42 \
		--verbose

test.h5 : small-sky-bank-refined.h5
	sgn-manifold-cbc-bank-test --num-injections 100 --bank $< --output-h5 $@ --verbose

test_mismatch_histogram.png : test.h5
	sgn-manifold-cbc-bank-test-plot \
		--output-prefix test-2 \
		--test $< \
		--verbose

mass-model.h5 : small-sky-bank-refined.h5
	sgn-manifold-cbc-bank-mass-model \
		--bank $^ \
		--yaml pastro/pop.yaml \
		--output-h5 $@ \
		--model salpeter \
                --processes 6 \
		--window 50000 \
		--match-dispersion 0.1 \
		--verbose \

# The p_astro component models and combined model are built by pastro/Makefile.

plot : mass-model.h5
	sgn-manifold-cbc-bank-plot-mass-model \
	$< \
	--snr 10 \
	--title smallsky-massmodel

clean:
	rm -f test.h5 small-sky-bank-refined.h5 small-sky-bank.h5 *.png
	rm -f mass-model.h5
