#!/bin/sh PCSV="parse-csv -f.pcsv.rc" DAT="data/inst-data" # declare bracket days for each month (note: slight error for leap year) d1=(0 31 60 90 120 151 181 212 243 273 304 334) d2=(32 61 91 121 152 182 213 244 274 305 335 366) mon=(jan feb mar apr may jun jul aug sep oct nov dec) month=(January February March April May June July August September October November December) cd /home/ken/proj/airport/teller/final-results/ ## prepare data sets from the main data file: ## note: all-data file runs from 2100 hours day 141 2002 to 2000 hours day 141 2004 if test ! -e data/all-data; then echo no data file found exit 1 fi test ! -e data/inst-data && parse-csv < data/all-data -o 1-12 > data/inst-data for set in 1 2; do if test ! -e data/windset${set}-data; then echo generating windset $set... parse-csv < data/all-data -i\# -o 1-4 wind_spd_${set}_inst wind_dir_${set}_inst > data/windset${set}-data fi done ## in the following section, create bins using counts, then windrose images DEST="web" for set in 1 2; do DAT=data/windset${set}-data ## check for and create target directories: for dir in $DEST/windset${set}/windrose/bins \ $DEST/windset${set}/windrose/images \ $DEST/windset${set}/windrose/images/small; do if test ! -d $dir; then mkdir --parents $dir; fi done ## windrose data for the entire available data set: NAME="alldata" TITLE="Teller windset$set, all data" PCT3="$DEST/windset${set}/windrose/bins/$NAME-pct3.txt" DOTFMT="$DEST/windset${set}/windrose/bins/$NAME-dotfmt.txt" FAAFMT="$DEST/windset${set}/windrose/bins/$NAME-faafmt.txt" PERCENT="$DEST/windset${set}/windrose/bins/$NAME-percent.txt" COUNTS="$DEST/windset${set}/windrose/bins/$NAME-counts.txt" EPS="$DEST/windset${set}/windrose/images/$NAME.eps" JPEG="$DEST/windset${set}/windrose/images/$NAME.jpg" SMALL="$DEST/windset${set}/windrose/images/small/$NAME.jpg" ## process raw data to textual windrose bins in percent frequency, precision 3: test ! -e $PCT3 && { echo $PCT3 $PCSV <$DAT year day hhmm wind_spd_${set}_inst wind_dir_${set}_inst \ | binify --showtotals --percent --spdheadings --dirheadings --precision=3 --verbose \ --ispeed=mps --ospeed=mph \ --speedbins=8.5,12.5,15.5,18.5,24.5,31.5,38.5,45.5 \ --rounddir --notimestamp --title="$TITLE" - 2>/dev/null > $PCT3 } ## filter the pct3 file to another format: test ! -e $DOTFMT && { bin/pct3-dotfmt $PCT3 > $DOTFMT } ## process raw data to textual windrose bins in percent frequency: test ! -e $PERCENT && { echo $PERCENT $PCSV <$DAT year day hhmm wind_spd_${set}_inst wind_dir_${set}_inst \ | binify --showtotals --percent --spdheadings --dirheadings --precision=1 --verbose \ --ispeed=mps --ospeed=mph \ --speedbins=8.5,12.5,15.5,18.5,24.5,31.5,38.5,45.5 \ --rounddir --title="$TITLE" --hidezero - 2>/dev/null > $PERCENT } ## process raw data to textual windrose bins in event counts: test ! -e $COUNTS && { echo $COUNTS $PCSV <$DAT year day hhmm wind_spd_${set}_inst wind_dir_${set}_inst \ | binify --spdheadings --dirheadings --precision=1 --verbose \ --ispeed=mps --ospeed=mph \ --speedbins=8.5,12.5,15.5,18.5,24.5,31.5,38.5,45.5 \ --rounddir --title="$TITLE" - 2>/dev/null > $COUNTS } ## process raw data to FAA format windrose bins, as 10-degree event counts test ! -e $FAAFMT && { echo $FAAFMT TITLE="Teller Airport, 2002-2004 Data" $PCSV <$DAT year day hhmm wind_spd_${set}_inst wind_dir_${set}_inst \ | binify --dirbinsize=10 --dirheadings --showdirnum --nocenterdir \ --hidetotalsummary --tab --quiet \ --ispeed=mps --ospeed=knots \ --speedbins=0,4,7,11,17,22,28,34,41 \ --rounddir --title="$TITLE" - 2>/dev/null > $FAAFMT } ## create graphical windrose in eps format: test ! -e $EPS && { echo $COUNTS windrose-eps --start=Dir --radius=12% $COUNTS $EPS } ## convert eps image to jpeg: test ! -e $JPEG && { echo $JPEG convert $EPS $JPEG } ## convert jpeg to a small/thumbnail version: test ! -e $SMALL && { echo $SMALL convert -resize 96x96 $JPEG $SMALL } ## do the same for each month's data... ## ... speed vs direction for each month: for i in 0 1 2 3 4 5 6 7 8 9 10 11; do NAME="${mon[$i]}" TITLE="Teller windset$set, ${month[$i]}" PCT3="$DEST/windset${set}/windrose/bins/$NAME-pct3.txt" DOTFMT="$DEST/windset${set}/windrose/bins/$NAME-dotfmt.txt" FAAFMT="$DEST/windset${set}/windrose/bins/$NAME-faafmt.txt" PERCENT="$DEST/windset${set}/windrose/bins/$NAME-percent.txt" COUNTS="$DEST/windset${set}/windrose/bins/$NAME-counts.txt" EPS="$DEST/windset${set}/windrose/images/$NAME.eps" JPEG="$DEST/windset${set}/windrose/images/$NAME.jpg" SMALL="$DEST/windset${set}/windrose/images/small/$NAME.jpg" ## process raw data to textual windrose bins in percent frequency, precision 3: test ! -e $PCT3 && { echo $PCT3 $PCSV <$DAT day\>${d1[i]} day\<${d2[i]} year day hhmm wind_spd_${set}_inst wind_dir_${set}_inst \ | binify --showtotals --percent --spdheadings --dirheadings --precision=3 --verbose \ --ispeed=mps --ospeed=mph \ --speedbins=8.5,12.5,15.5,18.5,24.5,31.5,38.5,45.5 \ --rounddir --notimestamp --title="$TITLE" - 2>/dev/null > $PCT3 } ## filter the pct3 file to another format: test ! -e $DOTFMT && { bin/pct3-dotfmt $PCT3 > $DOTFMT } ## process raw data to textual windrose bins in percent frequency: test ! -e $PERCENT && { echo $PERCENT $PCSV <$DAT day\>${d1[i]} day\<${d2[i]} year day hhmm wind_spd_${set}_inst wind_dir_${set}_inst \ | binify --showtotals --percent --spdheadings --dirheadings --precision=1 --verbose \ --ispeed=mps --ospeed=mph \ --speedbins=8.5,12.5,15.5,18.5,24.5,31.5,38.5,45.5 \ --rounddir --notimestamp --title="$TITLE" --hidezero - 2>/dev/null > $PERCENT } ## process raw data to textual windrose bins in event counts: test ! -e $COUNTS && { echo $COUNTS $PCSV <$DAT day\>${d1[i]} day\<${d2[i]} year day hhmm wind_spd_${set}_inst wind_dir_${set}_inst \ | binify --spdheadings --dirheadings --precision=1 --verbose \ --ispeed=mps --ospeed=mph \ --speedbins=8.5,12.5,15.5,18.5,24.5,31.5,38.5,45.5 \ --rounddir --notimestamp --title="$TITLE" - 2>/dev/null > $COUNTS } ## process raw data to FAA format windrose bins, as 10-degree event counts test ! -e $FAAFMT && { echo $FAAFMT TITLE="Teller Airport, 2002-2004 ${month[i]} Data" $PCSV <$DAT day\>${d1[i]} day\<${d2[i]} year day hhmm wind_spd_${set}_inst wind_dir_${set}_inst \ | binify --dirbinsize=10 --dirheadings --showdirnum --nocenterdir \ --hidetotalsummary --tab --quiet \ --ispeed=mps --ospeed=knots \ --speedbins=0,4,7,11,17,22,28,34,41 \ --rounddir --title="$TITLE" - 2>/dev/null > $FAAFMT } ## create graphical windrose in eps format: test ! -e $EPS && { echo $EPS windrose-eps --start=Dir --radius=12% $COUNTS $EPS } ## convert eps image to jpeg: test ! -e $JPEG && { echo $JPEG convert $EPS $JPEG } ## convert jpeg to a small/thumbnail version: test ! -e $SMALL && { echo $SMALL convert -resize 96x96 $JPEG $SMALL } done done DEST="web/diagnostic" SUFFIX="ws_vs_wd" for set in 1 2; do DAT=data/windset${set}-data ## check for and create target directories: test ! -d $dir && mkdir --parents for dir in $DEST/windset${set}/$SUFFIX; do test ! -d $dir && mkdir --parents $dir done ## first plot speed vs direction for all data and each month: ## ... speed vs direction for all data: TARGET="$DEST/windset${set}/$SUFFIX/alldata.jpg" SMALL="$DEST/windset${set}/$SUFFIX/sm-alldata.jpg" TITLE="Teller, windset$set, all data" test ! -e $TARGET && { echo $TARGET $PCSV <$DAT wind_dir_${set}_inst "mps2mph(wind_spd_${set}_inst)" \ | plotxyz -x0:0,360 -y1:0,24 -b0 -L '-Xwind direction' -i12 '-Ywind speed, MPH' -T"$TITLE" -c# > $TARGET convert -scale 200% -quality 20 $TARGET $TARGET convert -scale 16% -quality 100 $TARGET $SMALL } ## ... speed vs direction for each month: for i in 0 1 2 3 4 5 6 7 8 9 10 11; do TARGET="$DEST/windset${set}/$SUFFIX/${mon[$i]}.jpg" SMALL="$DEST/windset${set}/$SUFFIX/sm-${mon[$i]}.jpg" TITLE="Teller, windset$set, ${month[$i]}" test ! -e $TARGET && { echo $TARGET $PCSV <$DAT day\>${d1[i]} day\<${d2[i]} wind_dir_${set}_inst "mps2mph(wind_spd_${set}_inst)" \ | plotxyz -s400,300 -x0:0,360 -y1:0,24 -b1 -L -i12 '-Xwind direction' '-Ywind speed, MPH' -T"$TITLE" -c# > $TARGET convert -scale 200% -quality 20 $TARGET $TARGET convert -scale 16% -quality 100 $TARGET $SMALL } done done ## plot battery voltage vs time TARGET="$DEST/battery.jpg" SMALL="$DEST/sm-battery.jpg" TITLE="Teller logger battery voltage" DAT="data/inst-data" test ! -e $TARGET && { echo $TARGET $PCSV <$DAT 'yd2y(year,day)' loggerbattery_voltage \ | plotxyz -x0:2002.3,2004.4 -y1:10.5,14.5 -b0 -L -XYear -i21.1 -YVoltage -T"$TITLE" -c# > $TARGET convert -scale 200% -quality 50 $TARGET $TARGET convert -scale 16% -quality 100 $TARGET $SMALL } ## plot count of records for each day and hour TARGET="$DEST/records-per-day-hour.jpg" SMALL="$DEST/sm-records-per-day-hour.jpg" TITLE="Teller, records per day-hour" test ! -e $TARGET && { echo $TARGET $PCSV <$DAT day hhmm \ | perl -F/,/ -ane 'BEGIN{foreach $d (1..366){foreach $h (1..24){$rec{"$d,${h}00"}=0}}}; chomp @F; $rec{"$F[0],$F[1]"}++; END{foreach $k ( keys %rec ){($d,$h)=$k=~m/(\d+),(\d+)00/;printf "%.2f,%d\n", $d+$h/24,$rec{$k}}}' \ | sort -n \ | tee $DEST/records-per-day-hour.dat \ | plotxyz -x0:0,375 -y1:0,3 -b0 -l -X'Day of Year' -i15.0 -Y'Records' -T"$TITLE" -c# \ > $TARGET convert -scale 200% -quality 50 $TARGET $TARGET convert -scale 16% -quality 100 $TARGET $SMALL } ## consecutive hourly records vs time TARGET="$DEST/continous_record.jpg" SMALL="$DEST/sm-continous_record.jpg" TITLE="Teller, continuous records" test ! -e $TARGET && { echo $TARGET $PCSV <$DAT 'ydhm2y(year,day,hhmm)' 'continuous(year,day,hhmm)' | tee /tmp/times.dat \ | plotxyz -s400,300 -x0:2002.3,2004.4 -i24.1 -y1 -b0 -L -X'Day of Year' -Y'Records' -T"$TITLE" -c# \ > $TARGET convert -scale 200% -quality 50 $TARGET $TARGET convert -scale 16% -quality 100 $TARGET $SMALL } ## consecutive hourly records vs time, with reset TARGET="$DEST/continous_records-with_reset.jpg" SMALL="$DEST/sm-continous_records-with_reset.jpg" TITLE="Teller, continuous records" test ! -e $TARGET && { echo $TARGET $PCSV <$DAT 'ydhm2y(year,day,hhmm)' 'continuous(year,day,hhmm,1)' | tee /tmp/times.dat \ | plotxyz -s400,300 -x0:2002.3,2004.4 -i24.1 -y1 -b0 -L -X'Day of Year' -Y'Records' -T"$TITLE" -c# \ > $TARGET convert -scale 200% -quality 50 $TARGET $TARGET convert -scale 16% -quality 100 $TARGET $SMALL } DEST="web" for set in 1 2; do fmt=dotfmt ARCHIVE="windset${set}-bins-$fmt.zip" echo update $ARCHIVE archive... zip -u $DEST/$ARCHIVE $DEST/windset${set}/windrose/bins/*-$fmt.txt fmt=faafmt ARCHIVE="windset${set}-bins-$fmt.zip" echo update $ARCHIVE archive... zip -u $DEST/$ARCHIVE $DEST/windset${set}/windrose/bins/*-$fmt.txt done