#!/usr/local/bin/bash # much of this follows the "computers do work so humans don't have to" philosophy. # see http://slackology.net/wxnotes.html for more info # screw our time base changing randomly twice a year. move to UTC BASE_DIR="/home/ghz/wx/ext" cd $BASE_DIR/plots/ ||exit TD="../data/last48h" AVG_FILTER=$BASE_DIR/avg_filter SPIKE_FILTER=$BASE_DIR/spike_filter DATEPATH=$BASE_DIR NSAMP=4000 while true; do DATE=`$DATEPATH/date +%Y%m%d` YDATE=`$DATEPATH/date -v-1d +%Y%m%d` YYDATE=`$DATEPATH/date -v-2d +%Y%m%d` YYDATEH=`$DATEPATH/date -v-2d +%Y%m%d%H` TD_DUMP="cat ../data/wswxdat.$YYDATE ../data/wswxdat.$YDATE ../data/wswxdat.$DATE" $BASE_DIR/log2300 $BASE_DIR/data/wswxdat.$DATE $BASE_DIR/open2300.conf $TD_DUMP | grep -A $NSAMP $YYDATEH > $TD $TD_DUMP |awk '{print $1, $4}' | $SPIKE_FILTER | grep -A $NSAMP $YYDATEH > $TD.int_temp $TD_DUMP |awk '{print $1, $5}' | sed 's/\ 80\.[139]/\ \?\?\ /g' |$SPIKE_FILTER | grep -A $NSAMP $YYDATEH > $TD.ext_temp $TD_DUMP |awk '{print $1, $6}' | sed 's/\ 81\.1/\ \?\?\ /g' | $SPIKE_FILTER | grep -A $NSAMP $YYDATEH > $TD.dew_temp $TD_DUMP |awk '{print $1, $7}' | $SPIKE_FILTER | grep -A $NSAMP $YYDATEH > $TD.int_hum $TD_DUMP |awk '{print $1, $8}' |sed 's/\ 110$/\ \?\?\ /g' |$SPIKE_FILTER \ | grep -A $NSAMP $YYDATEH > $TD.ext_hum $TD_DUMP |awk '{print $1, $9}' |sed 's/\ 4[123]\.[1238]/\ \?\?\ /g' \ |sed 's/\ 183\.6/\ \?\?\ /g' | grep -A $NSAMP $YYDATEH | $AVG_FILTER > $TD.wind $TD_DUMP |awk '{print $1, $16}' |sed 's/10[123]0\.000/\ \?\?\ /g'| $SPIKE_FILTER \ | grep -A $NSAMP $YYDATEH > $TD.pressure #$TD_DUMP |awk '{print $1, $16}' | $SPIKE_FILTER | grep -A $NSAMP $YYDATEH > $TD.pressure paste $TD.ext_temp $TD.dew_temp |awk '{print $1, $2, $4}' > $TD.dew_ext_temp $BASE_DIR/gen_index PRESSURE="\"$TD.pressure\" using 1:((\$2/10)) title 'Pressure (kPa)' with lines lt 8" INT_TEMP="\"$TD.int_temp\" using 1:2 title 'Int Temp (C)' with lines lt 1" EXT_TEMP="\"$TD.ext_temp\" using 1:2 title 'Ext Temp (C)' with lines lt 2" DEW_POINT="\"$TD.dew_temp\" using 1:2 title 'Dew Point (C)' with lines lt 3" INT_HUM="\"$TD.int_hum\" using 1:2 title 'Int Humidity (%)' with lines lt 4" EXT_HUM="\"$TD.ext_hum\" using 1:2 title 'Ext Humidity (%)' with lines lt 5" DEW_EXT="\"$TD.dew_ext_temp\" using 1:((\$2-\$3)) title 'ET - DP (C)' with lines 6" WS_AVG="\"$TD.wind\" using 1:2 title 'Filtered Running Average Wind Speed (km/h)' with lines lt 3" WDIR="\"$TD\" using 1:10 title 'Wind Direction' with points lt 4" WCHILL="\"$TD\" using 1:12 title 'Wind Chill (C)' with lines lt 8" RAIN_1H="\"$TD\" using 1:13 title 'Rain (Last 1h) (mm)' with lines lt 8" RAIN_24H="\"$TD\" using 1:14 title 'Rain (Last 24h) (mm)' with lines lt 2" RAIN_TOT="\"$TD\" using 1:15 title 'Rain (Total) (mm)' with lines lt 1" PROLOUGE="set title \"Weather Data for the Last ~48 Hours\";\ set xtics 7200 ;\ set y2tics ;\ set key outside below;\ set xlabel \"Time (UTC)\" 0.0, -1.0;\ set xdata time;\ set format x \"%m/%d\\n%H:%M\";\ set timefmt \"%Y%m%d%H%M%S\";\ set grid;\ set term png size 1235, 480;" echo "$PROLOUGE\ set ylabel \"Deg (C) / %\";\ set output 'all.png';\ plot $INT_TEMP, $EXT_TEMP, $DEW_POINT, $INT_HUM, $EXT_HUM;\ " |gnuplot # set format y "%.3f" ;\ # set format y "%g" ;\ echo "$PROLOUGE\ set ylabel \"kPa\";\ set output 'pressure.png';\ set format y \"%.2f\" ;\ set format y2 \"%.2f\" ;\ plot $PRESSURE;\ set format y \"%g\" ;\ set format y2 \"%g\" ;\ set ylabel \"%\";\ set output 'inthum.png';\ plot $INT_HUM;\ set output 'exthum.png';\ plot $EXT_HUM;\ " |gnuplot echo "$PROLOUGE\ set ylabel \"Deg (C)\";\ set output 'dewexttemp.png';\ plot $DEW_EXT, $EXT_TEMP, $DEW_POINT;\ set output 'inttemp.png';\ plot $INT_TEMP;\ " |gnuplot echo "$PROLOUGE\ set ylabel \"km/h\";\ set output 'windspeed.png';\ plot $WS_AVG;\ " |gnuplot echo "$PROLOUGE\ set ylabel \"Direction (Cardinal/Deg) \" ;\ set yrange [0:360] ;\ set ytics (\"N\" 0, \"NE\" 45, \"E\" 90, \"SE\" 135, \"S\" 180, \"SW\" 225, \"W\" 270, \"NW\" 315, \"N\" 360) ;\ set y2tics 45 ;\ set my2tics 2 ;\ set output 'winddir.png';\ plot $WDIR;\ " |gnuplot echo "$PROLOUGE\ set ylabel \"Rain Accumulation (mm)\";\ set output 'rain.png';\ set yrange [0:] ;\ plot $RAIN_24H, $RAIN_1H;\ " |gnuplot 2>/dev/null cp *.png index.html /wx/ rsync -u $BASE_DIR/l.wx.go $AVG_FILTER $BASE_DIR/gen_index \ $SPIKE_FILTER /wx/scripts/wx/ rsync -qu $BASE_DIR/data/* /wx/data/wx/ echo -n . sleep 50 done