#! /bin/csh -f

set start_time = `date +%s`
source ~/.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
set date = $yy$mm$dd

cd /network/rit/lab/mesonet/mesonet/climate/daily

rm *png precip*.dat solar*.dat monthly*.dat weekly*.dat daily*.dat *three*dat

foreach station (SCHU WHIT WATE CSQR SPRA COLD JORD WEST BERK BELD ESSX CHES STEP OTIS LAUR GABR COBL TICO WFMB COPE BATA SBRI SHER DELE WOLC JOHN LOUI TULL WARW WALT CINC FRED BRAN WELL CAPE BELL WARS BELM COHO BURD TYRO PENN CLYM RAND OLEA BURT BROC SCHA REDF HARR OSCE WALL MORR CAMD ELMI PHIL POTS OSWE CHAZ SARA RUSH TUPP CLIF FAYE EDIN MEDI GROV OWEG NBRA DUAN ILAK OPPE REDH COPA ANDE HARP BROO EAUR YORK HART HERK ADDI SPRI MALO VOOR HAMM EDWA SUFF BSPA BEAC DEPO MEDU ROXB ELDR GFLD WGAT ELLE KIND WBOU OLDF NHUD SCIP BING NEWC CLAR ONTA CROG RAQU WANT SOUT HFAL DOVE GROT SCHO TANN SOME BUFF GFAL PISE BREW QUEE STAT BKLN MANH BRON STON LKPL)

cp ../../meta/$station.txt station.ascii
ncl thirty.ncl
convert $station.png -gravity North -chop 0x100 temp.png
convert -shave 150x60 temp.png $station.png
rm temp.png
pngquant ${station}.png
mv ${station}-fs8.png ${station}.png

scp $station.png nbassill@operations.nysmesonet.org:/home/nbassill/public_html/plots/climate/daily/$station.png

ncl ninety.ncl
convert ${station}90.png -gravity North -chop 0x100 temp.png
convert -shave 150x60 temp.png ${station}90.png
rm temp.png
pngquant ${station}90.png
mv ${station}90-fs8.png ${station}90.png

rm /home/nb965428/public_html/climate/daily/${station}90.png
scp ${station}90.png nbassill@operations.nysmesonet.org:/home/nbassill/public_html/plots/climate/daily/${station}90.png

end

ncl maps.ncl
ncl extremes.ncl

foreach map (daily dailyhigh dailylow dailymean dailyhighanomaly dailylowanomaly weekly weeklyhigh weeklylow weeklymean weeklyhighanomaly weeklylowanomaly \
         monthly monthlyhigh monthlylow monthlymean monthlyhighanomaly monthlylowanomaly solarweekly solarmonthly solardaily precipweekly precipdaily  \
         precipmonthly preciptotaldaily preciptotalweekly preciptotalmonthly weeklyheating monthlyheating dailyheating weeklycooling monthlycooling    \
         dailycooling threemonthlycooling threemonthlyheating preciptotalthreemonthly precipthreemonthly threemonthly solarthreemonthly threemonthlyhigh \
         threemonthlylow threemonthlymean threemonthlyhighanomaly threemonthlylowanomaly dailyhighsigmaanomaly dailylowsigmaanomaly threemonthlymaximum threemonthlyminimum)

       
convert $map.png -gravity North -chop 0x50 temp.png
convert -shave 175x300 temp.png $map.png
convert ${map}.png logo/mediummaplogo.png -geometry +200+20 -composite ${map}.png
pngquant ${map}.png
mv ${map}-fs8.png ${map}.png

end

sleep 1s

rm temp.png
scp daily*.png weekly*.png monthly*.png threemonthly*.png solar*png precip*png nbassill@operations.nysmesonet.org:/home/nbassill/public_html/plots/climate/daily/

makespatialclimate.csh #make spatial map version of above maps

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