#! /bin/csh -f

set start_time = `date +%s`
source /aca1/nb965428/.cshrc

set mm = `date -u +%m`
set dd = `date -u +%d`
set hh = `date -u +%k`
set yy = `date -u +%y`
echo The Current Date Is $yy$mm$dd

cd /aca1/nb965428/wrf2gem/mesonet/climate/daily

set currentdate = 20${yy}${mm}${dd}
set startday = -3
set endday   = -1
while ( $startday <= $endday)

set dd = `date +%d -d "$currentdate UTC + $startday day"`
set mm = `date +%m -d "$currentdate UTC + $startday day"`
set yy = `date +%y -d "$currentdate UTC + $startday day"`
set date = $yy$mm$dd

cd $date
#echo "-80,-80,0" >>   monthly.dat
#echo "-80,-80,0" >>   monthlycooling.dat
#echo "-80,-80,0" >>   monthlyheating.dat
#echo "-80,-80,0" >>   monthlyhighanomaly.dat
#echo "-80,-80,0" >>   monthlyhigh.dat
#echo "-80,-80,0" >>   monthlylowanomaly.dat
#echo "-80,-80,0" >>   monthlylow.dat
#echo "-80,-80,0" >>   monthlymean.dat
#echo "-80,-80,0" >>   solarmonthly.dat
#echo "-80,-80,0" >>   precipmonthly.dat
#echo "-80,-80,0" >>   preciptotalmonthly.dat
#echo "-80,-80,0" >>   weekly.dat
#echo "-80,-80,0" >>   weeklycooling.dat
#echo "-80,-80,0" >>   weeklyheating.dat
#echo "-80,-80,0" >>   weeklyhighanomaly.dat
#echo "-80,-80,0" >>   weeklyhigh.dat
#echo "-80,-80,0" >>   weeklylowanomaly.dat
#echo "-80,-80,0" >>   weeklylow.dat
#echo "-80,-80,0" >>   weeklymean.dat
#echo "-80,-80,0" >>   solarweekly.dat
#echo "-80,-80,0" >>   precipweekly.dat
#echo "-80,-80,0" >>   preciptotalweekly.dat

cp ../savepast/maps.ncl .
cp ../savepast/usp01.dat .
ncl maps.ncl

convert daily.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png daily.png
convert dailyhigh.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png dailyhigh.png
convert dailylow.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png dailylow.png
convert dailymean.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png dailymean.png
convert dailyhighanomaly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png dailyhighanomaly.png
convert dailylowanomaly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png dailylowanomaly.png
convert weekly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png weekly.png
convert weeklyhigh.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png weeklyhigh.png
convert weeklylow.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png weeklylow.png
convert weeklymean.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png weeklymean.png
convert weeklyhighanomaly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png weeklyhighanomaly.png
convert weeklylowanomaly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png weeklylowanomaly.png
convert monthly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png monthly.png
convert monthlyhigh.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png monthlyhigh.png
convert monthlylow.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png monthlylow.png
convert monthlymean.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png monthlymean.png
convert monthlyhighanomaly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png monthlyhighanomaly.png
convert monthlylowanomaly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png monthlylowanomaly.png
convert solarweekly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png solarweekly.png
convert solarmonthly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png solarmonthly.png
convert solardaily.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png solardaily.png
convert precipweekly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png precipweekly.png
convert precipdaily.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png precipdaily.png
convert precipmonthly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png precipmonthly.png
convert preciptotaldaily.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png preciptotaldaily.png
convert preciptotalweekly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png preciptotalweekly.png
convert preciptotalmonthly.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png preciptotalmonthly.png
convert weeklyheating.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png weeklyheating.png
convert monthlyheating.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png monthlyheating.png
convert dailyheating.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png dailyheating.png
convert weeklycooling.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png weeklycooling.png
convert monthlycooling.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png monthlycooling.png
convert dailycooling.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png dailycooling.png
#convert threemonthlycooling.png -gravity North -chop 0x50 temp.png
#convert -shave 175x300 temp.png threemonthlycooling.png
#convert threemonthlyheating.png -gravity North -chop 0x50 temp.png
#convert -shave 175x300 temp.png threemonthlyheating.png
#convert preciptotalthreemonthly.png -gravity North -chop 0x50 temp.png
#convert -shave 175x300 temp.png preciptotalthreemonthly.png
#convert precipthreemonthly.png -gravity North -chop 0x50 temp.png
#convert -shave 175x300 temp.png precipthreemonthly.png
#convert threemonthly.png -gravity North -chop 0x50 temp.png
#convert -shave 175x300 temp.png threemonthly.png
#convert solarthreemonthly.png -gravity North -chop 0x50 temp.png
#convert -shave 175x300 temp.png solarthreemonthly.png
#convert threemonthlyhigh.png -gravity North -chop 0x50 temp.png
#convert -shave 175x300 temp.png threemonthlyhigh.png
#convert threemonthlylow.png -gravity North -chop 0x50 temp.png
#convert -shave 175x300 temp.png threemonthlylow.png
#convert threemonthlymean.png -gravity North -chop 0x50 temp.png
#convert -shave 175x300 temp.png threemonthlymean.png
#convert threemonthlyhighanomaly.png -gravity North -chop 0x50 temp.png
#convert -shave 175x300 temp.png threemonthlyhighanomaly.png
#convert threemonthlylowanomaly.png -gravity North -chop 0x50 temp.png
#convert -shave 175x300 temp.png threemonthlylowanomaly.png

cd ..

@ startday ++
end

set end_time   = `date  +%s`
@ length_time  = $end_time - $start_time
echo "It took this long to run getdaily.csh: $length_time seconds"
