#!/bin/csh

###### This script stitches together the verification products that ultimately end up on the web interface #######

##### NEED TO CHANGE THE DIRECTORIES ######

set daynine = `date -d "9 days ago" +%d`
set monnine = `date -d "9 days ago" +%m`
set mondaynin = $monnine$daynine

##### Remove the oldest verification products from the web interface (10 days old) and rename the existing younger products in the archive #####

set archive = {'1','2','3','4','5','6','7','8','9','10'}

foreach a (1 2 3 4 5 6 7 8 9 10)

rm -f /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D9_$archive[$a].gif
rm -f /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D9_$archive[$a].gif
rm -f /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D9_$archive[$a].gif

mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D8_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D9_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D7_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D8_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D6_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D7_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D5_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D6_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D4_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D5_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D3_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D4_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D2_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D3_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D1_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D2_$archive[$a].gif

mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D8_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D9_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D7_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D8_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D6_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D7_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D5_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D6_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D4_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D5_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D3_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D4_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D2_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D3_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D1_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D2_$archive[$a].gif

mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D8_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D9_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D7_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D8_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D6_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D7_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D5_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D6_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D4_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D5_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D3_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D4_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D2_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D3_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D1_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D2_$archive[$a].gif

end

##### Convert the verified deterministic NPJ phase diagram from 9 days ago into a GIF #####
convert -density 400 /winterslab_rit/realtime/images/phase_diagrams/verif_deterministic.pdf verif_deterministic.gif
convert verif_deterministic.gif -crop 2800x2300+150+100 +repage verif_deterministic.gif

##### Convert the verified probabilistic NPJ phase diagram from 9 days ago into a GIF #####
convert -density 400 /winterslab_rit/realtime/images/phase_diagrams/verif_probdiagram.pdf verif_probdiagram.gif
convert verif_probdiagram.gif -crop 2800x2300+150+100 +repage verif_probdiagram.gif

###### Stitch together verified deterministic and probabilistic NPJ phase diagram with corresponding synoptic map #######
set daynummap = {'D9','D8','D7','D6','D5','D4','D3','D2','D1','000'}
set filenum = {'1','2','3','4','5','6','7','8','9','10'}

foreach d (1 2 3 4 5 6 7 8 9 10)
	
	mv /lb13/aw732728/wpc/realtime/images/250hPaJet_verif_deterministic_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_deterministic_D1_$filenum[$d].gif
	convert verif_deterministic.gif /winterslab_rit/realtime/images/jet/250hPaJet_gfs_$daynummap[$d].gif +append 250hPaJet_verif_deterministic_$filenum[$d].gif
	
	mv 250hPaJet_verif_deterministic_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images
	
	mv /lb13/aw732728/wpc/realtime/images/250hPaJet_verif_prob_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_prob_D1_$filenum[$d].gif
	convert verif_probdiagram.gif /winterslab_rit/realtime/images/jet/250hPaJet_gfs_$daynummap[$d].gif +append 250hPaJet_verif_prob_$filenum[$d].gif
	
	mv 250hPaJet_verif_prob_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images
	
end

rm -f verif_deterministic.gif
rm -f verif_probdiagram.gif

####### Stitch together verified ensemble scatterplot NPJ phase diagram with corresponding synoptic map #########
set daynumdiag = {'D1','D2','D3','D4','D5','D6','D7','D8','D9'}
set daynummap = {'D8','D7','D6','D5','D4','D3','D2','D1','000'}
set filenum = {'2','3','4','5','6','7','8','9','10'}

foreach d (1 2 3 4 5 6 7 8 9)
	
	mv /lb13/aw732728/wpc/realtime/images/250hPaJet_verif_scat_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D1_$filenum[$d].gif
	convert -density 400 /winterslab_rit/realtime/images/phase_diagrams/verif_$daynumdiag[$d]ens.pdf verif_$daynumdiag[$d]ens.gif
	convert verif_$daynumdiag[$d]ens.gif -crop 2800x2300+150+100 +repage verif_$daynumdiag[$d]ens.gif
	
	convert verif_$daynumdiag[$d]ens.gif /winterslab_rit/realtime/images/jet/250hPaJet_gfs_$daynummap[$d].gif +append 250hPaJet_verif_scat_$filenum[$d].gif
	
	mv 250hPaJet_verif_scat_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images
	
	rm -f verif_$daynumdiag[$d]ens.gif
	
end

####### Stitch together D0 NPJ phase diagram scatterplot with corresponding synoptic map ########
mv /lb13/aw732728/wpc/realtime/images/250hPaJet_verif_scat_1.gif /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_verif_scat_D1_1.gif
convert -density 400 /winterslab_rit/realtime/images/old_phase_diagrams/D0ens_${mondaynin}.pdf verif_D0ens.gif
convert verif_D0ens.gif -crop 2800x2300+150+100 +repage verif_D0ens.gif

convert verif_D0ens.gif /winterslab_rit/realtime/images/jet/250hPaJet_gfs_D9.gif +append 250hPaJet_verif_scat_1.gif

mv 250hPaJet_verif_scat_1.gif /lb13/aw732728/wpc/realtime/images

rm -f verif_D0ens.gif
	


