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

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

Hallo,

For more efficient batch runs, you might help test r.sun2:
http://thread.gmane.org/gmane.comp.gis.grass.user/20511/focus=20594

I would like to test r.sun2, but I did not manage to install the addon on my Cygwin based system. The "make" command produces the following output:

Makefile:9: ../../include/Make/Module.make: No such file or directory
make: *** No rule to make target `../../include/Make/Module.make'. Stop.

Using GEM, I got
ERROR: 'name' file not readable.
- This might be due to the fact that I do not understand how to prepare the files correctly for the use in GEM - sections 4.2 and 4.3 in its manual seem to be a little bit nebulous at least for a newbie.

Could anyone give me a hint?

Thanks in advance,

Roland

On Tue, Nov 20, 2007 at 05:18:16PM +0100, Roland Pape wrote:

Hallo,

>For more efficient batch runs, you might help test r.sun2:
> http://thread.gmane.org/gmane.comp.gis.grass.user/20511/focus=20594
>
>

I would like to test r.sun2, but I did not manage to install the addon
on my Cygwin based system. The "make" command produces the following output:

Please take a look at the README in Addons:

###############
Compilation

The easiest way to compile modules against your GRASS code is
by setting MODULE_TOPDIR on the fly to tell 'make' where to
find the GRASS source code:

  make MODULE_TOPDIR=$HOME/grass63/

(adapt to your /path/to/grass6/ )

#########################################

Maybe that helps?

Makefile:9: ../../include/Make/Module.make: No such file or directory
make: *** No rule to make target `../../include/Make/Module.make'. Stop.

Markus

Hallo everybody,

yet another newbie question: I would like to compile several addons (gipe, hydrofoss, r.sun_horizon) for my GRASS 6.2.2 that runs on a Windows machine under Cygwin.

As I have installed GRASS from within the Cygwin setup, it seems to me that I have no GRASS source code: The "make" command failed because of "Makefile:9: ../../include/Make/Module.make: No such file or directory". - That's right, there is no such directory on my machine. That's why Markus' tip from below does not work. Do I have to download and compile the source code of GRASS (there I found such a folder) before compiling any addons?

Recently, I have installed GEM in order to facilitate the usage of addons without having the source code of GRASS. But there, I got lost with the gipe-addon while "All you need to do is copy your source files, scripts etc. into the appropriate places in the src directory". Where are these appropriate places? It seems logic to place e.g. any i.xyz in the imagery folder, but the rest?

I appreciate any hints!

Thanks in advance,

Roland

--------------
Roland Pape
Climatology and Landscape Ecology Section
Department of Geography
University of Bonn

The easiest way to compile modules against your GRASS code is
by setting MODULE_TOPDIR on the fly to tell 'make' where to
find the GRASS source code:

make MODULE_TOPDIR=$HOME/grass63/

(adapt to your /path/to/grass6/ )

#########################################

Maybe that helps?

Markus
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user