#!/bin/csh

#### This script creates D(prog)/Dt NPJ phase diagram images that verify on today's date, as well as evolutions of the 
#### deterministic and probabilistic forecasts over the past 9 days.

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

## Create list of dates ##

#### Remove the images from 10 days ago and rename the existing images that still remain within 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/dprogdt_scatjet_D10_$archive[$a].gif
rm -f /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D10_$archive[$a].gif
rm -f /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D10_$archive[$a].gif
rm -f /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D10_$archive[$a].gif

mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D9_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D10_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D8_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D9_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D7_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D8_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D6_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D7_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D5_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D6_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D4_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D5_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D3_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D4_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D2_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D3_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D1_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D2_$archive[$a].gif

mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D9_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D10_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D8_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D9_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D7_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D8_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D6_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D7_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D5_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D6_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D4_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D5_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D3_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D4_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D2_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D3_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D1_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D2_$archive[$a].gif

mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D9_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D10_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D8_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D9_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D7_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D8_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D6_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D7_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D5_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D6_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D4_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D5_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D3_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D4_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D2_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D3_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D1_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D2_$archive[$a].gif

mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D9_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D10_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D8_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D9_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D7_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D8_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D6_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D7_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D5_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D6_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D4_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D5_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D3_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D4_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D2_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D3_$archive[$a].gif
mv /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D1_$archive[$a].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D2_$archive[$a].gif

end

### Create files for the d(prog)/dt loops by grabbing the correct files from existing products in the archives and renaming them.  ####

set daynumber = {'D9','D8','D7','D6','D5','D4','D3','D2','D1'}
set filenum = {'1','2','3','4','5','6','7','8','9'}
set filescat = {'10','9','8','7','6','5','4','3','2'}
set filedet = {'20','19','18','17','16','15','14','13','12'}

foreach d (1 2 3 4 5 6 7 8 9)
	
	mv /lb13/aw732728/wpc/realtime/images/dprogdt_scatjet_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D1_$filenum[$d].gif
	cp /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_scat_$daynumber[$d]_$filescat[$d].gif dprogdt_scatjet_$filenum[$d].gif
	#convert -density 400 /winterslab_rit/realtime/images/old_phase_diagrams/$daynumber[$d]ens_$datesdt[$d].pdf dprogdt_scat_$filenum[$d].gif
	#convert dprogdt_scat_$filenum[$d].gif -crop 2800x2300+300+1000 +repage dprogdt_scat_$filenum[$d].gif
	
	mv dprogdt_scatjet_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images
	
	mv /lb13/aw732728/wpc/realtime/images/dprogdt_scatvort_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D1_$filenum[$d].gif
	cp /lb13/aw732728/wpc/realtime/images/image_archive/500hPa_scat_$daynumber[$d]_$filescat[$d].gif dprogdt_scatvort_$filenum[$d].gif
	#convert -density 400 /winterslab_rit/realtime/images/old_phase_diagrams/$daynumber[$d]ens_$datesdt[$d].pdf dprogdt_scat_$filenum[$d].gif
	#convert dprogdt_scat_$filenum[$d].gif -crop 2800x2300+300+1000 +repage dprogdt_scat_$filenum[$d].gif
	
	mv dprogdt_scatvort_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images
	
	mv /lb13/aw732728/wpc/realtime/images/dprogdt_scattemp_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D1_$filenum[$d].gif
	cp /lb13/aw732728/wpc/realtime/images/image_archive/sfcT_scat_$daynumber[$d]_$filescat[$d].gif dprogdt_scattemp_$filenum[$d].gif
	#convert -density 400 /winterslab_rit/realtime/images/old_phase_diagrams/$daynumber[$d]ens_$datesdt[$d].pdf dprogdt_scat_$filenum[$d].gif
	#convert dprogdt_scat_$filenum[$d].gif -crop 2800x2300+300+1000 +repage dprogdt_scat_$filenum[$d].gif
	
	mv dprogdt_scattemp_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images
	
	mv /lb13/aw732728/wpc/realtime/images/dprogdt_scatprecip_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D1_$filenum[$d].gif
	cp /lb13/aw732728/wpc/realtime/images/image_archive/precip_scat_$daynumber[$d]_$filescat[$d].gif dprogdt_scatprecip_$filenum[$d].gif
	#convert -density 400 /winterslab_rit/realtime/images/old_phase_diagrams/$daynumber[$d]ens_$datesdt[$d].pdf dprogdt_scat_$filenum[$d].gif
	#convert dprogdt_scat_$filenum[$d].gif -crop 2800x2300+300+1000 +repage dprogdt_scat_$filenum[$d].gif
	
	mv dprogdt_scatprecip_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images
	
	rm -f /lb13/aw732728/wpc/realtime/images/dprogdt_prob_$filenum[$d].gif
	cp /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_prob_$daynumber[$d]_$filescat[$d].gif dprogdt_prob_$filenum[$d].gif
	#convert -density 400 /winterslab_rit/realtime/images/old_phase_diagrams/probdiagram_$datesdt[$d].pdf dprogdt_prob_$filenum[$d].gif
	#convert dprogdt_prob_$filenum[$d].gif -crop 2800x2300+300+1000 +repage dprogdt_prob_$filenum[$d].gif
	
	mv dprogdt_prob_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images
	
	rm -f /lb13/aw732728/wpc/realtime/images/dprogdt_deterministic_$filenum[$d].gif
	cp /lb13/aw732728/wpc/realtime/images/image_archive/250hPaJet_deterministic_$daynumber[$d]_$filedet[$d].gif dprogdt_deterministic_$filenum[$d].gif
	#convert -density 400 /winterslab_rit/realtime/images/old_phase_diagrams/deterministic_$datesdt[$d].pdf dprogdt_deterministic_$filenum[$d].gif
	#convert dprogdt_deterministic_$filenum[$d].gif -crop 2800x2300+300+1000 +repage dprogdt_deterministic_$filenum[$d].gif
	
	mv dprogdt_deterministic_$filenum[$d].gif /lb13/aw732728/wpc/realtime/images
	
end

### Create files for today's forecast ####

mv /lb13/aw732728/wpc/realtime/images/dprogdt_scatjet_10.gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatjet_D1_10.gif
cp /lb13/aw732728/wpc/realtime/images/250hPaJet_scat_1.gif dprogdt_scatjet_10.gif
#convert -density 400 /winterslab_rit/realtime/images/phase_diagrams/D0ens.pdf dprogdt_scat_10.gif
#convert dprogdt_scat_10.gif -crop 2800x2300+300+1000 +repage dprogdt_scat_10.gif
	
mv dprogdt_scatjet_10.gif /lb13/aw732728/wpc/realtime/images

mv /lb13/aw732728/wpc/realtime/images/dprogdt_scatvort_10.gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatvort_D1_10.gif
cp /lb13/aw732728/wpc/realtime/images/500hPa_scat_1.gif dprogdt_scatvort_10.gif
#convert -density 400 /winterslab_rit/realtime/images/phase_diagrams/D0ens.pdf dprogdt_scat_10.gif
#convert dprogdt_scat_10.gif -crop 2800x2300+300+1000 +repage dprogdt_scat_10.gif
	
mv dprogdt_scatvort_10.gif /lb13/aw732728/wpc/realtime/images

mv /lb13/aw732728/wpc/realtime/images/dprogdt_scattemp_10.gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scattemp_D1_10.gif
cp /lb13/aw732728/wpc/realtime/images/sfcT_scat_1.gif dprogdt_scattemp_10.gif
#convert -density 400 /winterslab_rit/realtime/images/phase_diagrams/D0ens.pdf dprogdt_scat_10.gif
#convert dprogdt_scat_10.gif -crop 2800x2300+300+1000 +repage dprogdt_scat_10.gif
	
mv dprogdt_scattemp_10.gif /lb13/aw732728/wpc/realtime/images
	
mv /lb13/aw732728/wpc/realtime/images/dprogdt_scatprecip_10.gif /lb13/aw732728/wpc/realtime/images/image_archive/dprogdt_scatprecip_D1_10.gif
cp /lb13/aw732728/wpc/realtime/images/precip_scat_1.gif dprogdt_scatprecip_10.gif
#convert -density 400 /winterslab_rit/realtime/images/phase_diagrams/D0ens.pdf dprogdt_scat_10.gif
#convert dprogdt_scat_10.gif -crop 2800x2300+300+1000 +repage dprogdt_scat_10.gif
	
mv dprogdt_scatprecip_10.gif /lb13/aw732728/wpc/realtime/images
	
rm -f /lb13/aw732728/wpc/realtime/images/dprogdt_prob_10.gif
cp /lb13/aw732728/wpc/realtime/images/250hPaJet_prob_1.gif dprogdt_prob_10.gif
#convert -density 400 /winterslab_rit/realtime/images/phase_diagrams/probdiagram.pdf dprogdt_prob_10.gif
#convert dprogdt_prob_10.gif -crop 2800x2300+300+1000 +repage dprogdt_prob_10.gif
	
mv dprogdt_prob_10.gif /lb13/aw732728/wpc/realtime/images
	
rm -f /lb13/aw732728/wpc/realtime/images/dprogdt_deterministic_10.gif
cp /lb13/aw732728/wpc/realtime/images/250hPaJet_deterministic_11.gif dprogdt_deterministic_10.gif
#convert -density 400 /winterslab_rit/realtime/images/phase_diagrams/deterministic.pdf dprogdt_deterministic_10.gif
#convert dprogdt_deterministic_10.gif -crop 2800x2300+300+1000 +repage dprogdt_deterministic_10.gif
	
mv dprogdt_deterministic_10.gif /lb13/aw732728/wpc/realtime/images

