RolandPape wrote:
> I am a quite novice user of GRASS and therefore my question might be rather
> simple: I would like to calculate global radiation for each day of the year
> by using r.sun. Instead of doing so day by day I thought about using a
> script defining a loop - but as common Windows user I am not familiar with
> writing Unix-shell scripts. I appreciate any suggestions!
Dylan Beaudette wrote:
Not sure how to do this on windows, but on a linux / unix machine the
construct is like this:for x in `seq 1 365`
do
echo "Running r.sun for day $x: Linke turbidity factor= ${linke[$x]}"
r.sun --q --o -s elevin=$elev aspin=$aspect slopein=$slope \
diff_rad=diffuse_0$x beam_rad=beam_0$x insol_time=time_0$x \
day=$x \
lin=${linke[$x]}
done & # run in the background
...
also note that i am specifying a daily TL value, from an array like this:
linke[1]=4.1175
linke[2]=4.1108
linke[3]=4.104
...
linke[365]=4.2324
Ubuntu users beware that variable arrays are specific to Bash, so your scripts
need to use #!/bin/bash
Dylan:
specify a smaller range of days, and run multiple instances of the above to
use multiple cores/ processors on such a machine.
Here is another approach to spawning jobs on a multi-proc system:
# set the priority to low so you can still
# use your machine while the model runs:
renice +17 -p $$
NPROCS=4
for DAY in `seq 1 365` ; do
while [ `pgrep -c r.sun` -ge $NPROCS ] ; do
echo "`date`: Waiting for a slot ... "
sleep 10
done
DAY_NUM=`echo $DAY | awk '{printf("%03d", $1)}'`
echo "[Day $DAY]"
r.sun day=$DAY .... &
# or save output for each day to a file
# r.sun day=$DAY .... 2>&1 | cat > rsun_log_${DAY_NUM}.txt &
done
For more efficient batch runs, you might help test r.sun2:
http://thread.gmane.org/gmane.comp.gis.grass.user/20511/focus=20594
Roland wrote:
> In one post Dylan and Hamish discussed about a r.sun manual - is it already
> available? I did not found it except the one at
> http://grass.itc.it/grass62/manuals/html62_user/r.sun.html
UNIX help pages are traditionally viewed with the "man" program, hence the
"r.sun manual". In GRASS 6 these man pages are generated from the HTML help
pages with the tools/g.html2man/ script. There is no other user guide out
there.
There are some journal articles worth reading though, see the REFs section of
the r.sun help page.
Hamish
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs