[GRASSLIST:7310] Re: Nested 'for' statements in batch grass cmd job
Hamish
hamish_nospam at yahoo.com
Sat Jun 25 00:48:58 EDT 2005
> I'm trying to "batch" interpolate vector 3d points using r.surf.rst. I
> want to output different resolutions, using different tension and
> smoothing params on the same input...then do a sink fill and flow dir,
> then convert it all to ESRI ascii. Ideally I'd start this at 5 PM
> today, and come in monday and find dev/sda1 full of all the rasters I
> need.....
Experience shows that it is best to start it at 3pm & watching for a
little while vs. showing up on Monday and finding it broke on the second
step at 6pm. Throw the "time" command in at the start of each loop so
you know how much time things took.
> So far I have the following, but I can't quite figure out how to make
> tension and smoothing part of the for....sequence statement. Obviously
> I can't use i$ for tension and smoothing in the same loop (tension
> range 10 : 60....smoothing range .01 : .1) any ideas would be
> appreciated.
For a limited number of steps, just list them:
INPUT=rastermap
for TENSION in 10 15 20 25 30 35 40 45 50 55 60 ; do
for SMOOTH in 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 ; do
echo "v.surf.rst elev=${INPUT}_t${TENSION}_s${SMOOTH}.rst"
done
done
for many steps use while & expr:
TENSION=10
while [ $TENSION -le 60 ] ; do
echo "t=${TENSION}"
# do stuff
TENSION=`expr $TENSION + 1` # or if bash, i=$(($i + 1))
done
SMOOTH_D=1
while [ $SMOOTH_D -le 10 ] ; do
SMOOTH=`echo $SMOOTH_D | awk '{print $1 * 0.1}'`
echo $SMOOTH
# do stuff
SMOOTH_D=`expr $SMOOTH_D + 1`
done
(while and expr only do integer numbers)
Nest the loops and you're away.
> for RAST in `g.list type=rast | sed 1,2d | grep -v '^-*$'`
Try g.mlist.
Hamish
More information about the grass-user
mailing list