
all: science

science: targ_sf1 targ_thar10 targ_thar1 targ_thar30 targ_xefl-o targ_1227+0757_sky targ_1342+0530 targ_2131+1042_1 targ_2131+1042_2 targ_2131+1042_3 targ_hd210501_1 targ_hd210501_2

regenerate:
	magesetup -db ut170530_31MAGE.db -blueflatkey Xe -redflatkey flat -lampkey ThAr -2D -individual -all -noslitfn

log_sf1:=sf1.out$(shell python -c 'import os,glob;p="sf1/sf1.out*";g=glob.glob(p);print len(g)+1')
log_thar10:=thar10.out$(shell python -c 'import os,glob;p="thar10/thar10.out*";g=glob.glob(p);print len(g)+1')
log_thar1:=thar1.out$(shell python -c 'import os,glob;p="thar1/thar1.out*";g=glob.glob(p);print len(g)+1')
log_thar30:=thar30.out$(shell python -c 'import os,glob;p="thar30/thar30.out*";g=glob.glob(p);print len(g)+1')
log_xefl-o:=xefl-o.out$(shell python -c 'import os,glob;p="xefl-o/xefl-o.out*";g=glob.glob(p);print len(g)+1')
log_1227+0757_sky:=1227+0757_sky.out$(shell python -c 'import os,glob;p="1227+0757_sky/1227+0757_sky.out*";g=glob.glob(p);print len(g)+1')
log_1342+0530:=1342+0530.out$(shell python -c 'import os,glob;p="1342+0530/1342+0530.out*";g=glob.glob(p);print len(g)+1')
log_2131+1042_1:=2131+1042_1.out$(shell python -c 'import os,glob;p="2131+1042_1/2131+1042_1.out*";g=glob.glob(p);print len(g)+1')
log_2131+1042_2:=2131+1042_2.out$(shell python -c 'import os,glob;p="2131+1042_2/2131+1042_2.out*";g=glob.glob(p);print len(g)+1')
log_2131+1042_3:=2131+1042_3.out$(shell python -c 'import os,glob;p="2131+1042_3/2131+1042_3.out*";g=glob.glob(p);print len(g)+1')
log_hd210501_1:=hd210501_1.out$(shell python -c 'import os,glob;p="hd210501_1/hd210501_1.out*";g=glob.glob(p);print len(g)+1')
log_hd210501_2:=hd210501_2.out$(shell python -c 'import os,glob;p="hd210501_2/hd210501_2.out*";g=glob.glob(p);print len(g)+1')

targ_sf1: targ_slit
	cd sf1; make -f sf1.pipeline >& $(log_sf1); cd ../

targ_thar10: targ_slit
	cd thar10; make -f thar10.pipeline >& $(log_thar10); cd ../

targ_thar1: targ_slit
	cd thar1; make -f thar1.pipeline >& $(log_thar1); cd ../

targ_thar30: targ_slit
	cd thar30; make -f thar30.pipeline >& $(log_thar30); cd ../

targ_xefl-o: targ_slit
	cd xefl-o; make -f xefl-o.pipeline >& $(log_xefl-o); cd ../

targ_1227+0757_sky: targ_slit
	cd 1227+0757_sky; make -f 1227+0757_sky.pipeline >& $(log_1227+0757_sky); cd ../

targ_1342+0530: targ_slit
	cd 1342+0530; make -f 1342+0530.pipeline >& $(log_1342+0530); cd ../

targ_2131+1042_1: targ_slit
	cd 2131+1042_1; make -f 2131+1042_1.pipeline >& $(log_2131+1042_1); cd ../

targ_2131+1042_2: targ_slit
	cd 2131+1042_2; make -f 2131+1042_2.pipeline >& $(log_2131+1042_2); cd ../

targ_2131+1042_3: targ_slit
	cd 2131+1042_3; make -f 2131+1042_3.pipeline >& $(log_2131+1042_3); cd ../

targ_hd210501_1: targ_slit
	cd hd210501_1; make -f hd210501_1.pipeline >& $(log_hd210501_1); cd ../

targ_hd210501_2: targ_slit
	cd hd210501_2; make -f hd210501_2.pipeline >& $(log_hd210501_2); cd ../


clean: clean_sf1 clean_thar10 clean_thar1 clean_thar30 clean_xefl-o clean_1227+0757_sky clean_1342+0530 clean_2131+1042_1 clean_2131+1042_2 clean_2131+1042_3 clean_hd210501_1 clean_hd210501_2

clean_sf1:
	cd sf1; make clean; cd ../
clean_thar10:
	cd thar10; make clean; cd ../
clean_thar1:
	cd thar1; make clean; cd ../
clean_thar30:
	cd thar30; make clean; cd ../
clean_xefl-o:
	cd xefl-o; make clean; cd ../
clean_1227+0757_sky:
	cd 1227+0757_sky; make clean; cd ../
clean_1342+0530:
	cd 1342+0530; make clean; cd ../
clean_2131+1042_1:
	cd 2131+1042_1; make clean; cd ../
clean_2131+1042_2:
	cd 2131+1042_2; make clean; cd ../
clean_2131+1042_3:
	cd 2131+1042_3; make clean; cd ../
clean_hd210501_1:
	cd hd210501_1; make clean; cd ../
clean_hd210501_2:
	cd hd210501_2; make clean; cd ../

veryclean:
	rm -rf sf1 thar10 thar1 thar30 xefl-o 1227+0757_sky 1342+0530 2131+1042_1 2131+1042_2 2131+1042_3 hd210501_1 hd210501_2

