[GRASS-user] Loop - How To? R.sun manual?

Dylan Beaudette dylan.beaudette at gmail.com
Mon Nov 12 13:19:26 EST 2007


On Monday 12 November 2007 10:08:40 am RolandPape wrote:
> Hallo,
>
> 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!
>
> 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
>
> Many thanks!
>
> Kind regards,
>
> Roland Pape
> ----------------
> Department of Geography
> University of Bonn

Hi,

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



note that i am using a variable to store the map names:
elev=elev_meters at solar
aspect=aspect at solar
slope=slope at solar


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

specify a smaller range of days, and run multiple instances of the above to 
use multiple cores/ processors on such a machine. You may need to do some 
googling to convert the above for-loop construct into a windows-compatible 
version.

cheers,

Dylan




More information about the grass-user mailing list