Markus wrote:
The d.polar is waiting for a volunteer to change the xgraph
dependency to GRASS' d.graph. Maybe done in a few minutes for someone
who knows the syntax of d.graph input... The xgraph input
is just a title and coordinate pairs to draw the polar
diagram.
well, here's a proof of concept; messy, but it does plot something--
`cat` and $FOO in d.graph's stdin is the required magic..
I've done it after-the-fact, but factoring x,y to 0-100% could be done
right in the "sin()*r, cos()*r" step to save time & space.
notes:
my 1000x1000 aspect grid made 50mb temp files!
I got weird output when trying from r.slope.aspect (elev from
r.surf.contour). Spikes every 45degree. I thought I had my awk
wrong.. [d.histogram of it attached]. Probably an artifact of blocky
r.surf.contour output? That histogram is interesting.. smaller peaks
22.5deg out of phase with the 45deg spikes..? odd.
Is 0deg north-up or does it have to be rotated? angle_n_up = 90-theta
The script could use lots of optimization.. move $2*$3/$4 stuff into one
coefficient before running awk, etc., e.g.
echo "\"All Data incl. NULL" > ${TMP}_outercircle
RADIUS_COEFF=`echo "$TOTALNUMBER $TOTALVALIDNUMBER $MAXRADIUS" | \
awk '{printf "%.8f", $1/$2 * $3}'`
for i in `seq 0 360` ; do
echo "$i $RADIUS_COEFF" | awk ...
The following doesn't honour the undef= option, is it on purpose?
# unit vector on raw data converted to radians without no data:
cat ${TMP}_raw | grep -v '^*'| awk 'BEGIN {sum = 0.0}
d.polar code follows (insert at end of script before cleanup)
---------------------
RING=0.95 # percent of frame to use
cat ${TMP}_sine_cosine_replic | tail +2 | awk -v RING=$RING -v MAX=$MAXRADIUS \
'{printf "%f %f\n", (($1 / MAX * RING) +1)*50, (($2 / MAX * RING)+1)*50}' \
> ${TMP}_sine_cosine_replic_normalized
VECT=`cat ${TMP}_vector | tail -n 1 | awk -v RING=$RING -v MAX=$MAXRADIUS \
'{printf "%f %f\n", (($1 / MAX * RING) +1)*50, (($2 / MAX * RING)+1)*50}'`
#d.erase
d.graph << EOF
# draw the goods
color red
polygon
`cat ${TMP}_sine_cosine_replic_normalized`
# draw axes
color black
width 0
move 0 50
draw 100 50
move 50 0
draw 50 100
# draw circle
# mandatory! as drawing is proportional to non-square frame
# draw vector
color green
width 2
move 50 50
draw $VECT
# draw compass text
color black
width 2
move 50.5 95
text N
# move 50.5 1
# text S
# move 1 50.5
# text W
# move 95 50.5
# text E
EOF
Hamish