<div dir="ltr"><div><div><div><div><div><div><div><div><div><div>Thanks Sotiris,<br><br></div>I've tried your suggestion but converted it to Python because I'm on Windows.<br></div>This is my script:<span style="font-family:courier new,monospace"><br>

grass.run_command('g.mremove', rast = ('out*'))<br>grass.mapcalc('sun=global1', quiet=False, verbose=False, overwrite=True)<br>for x in range(2, 10, 1):<br>  exp = 'out=sun+global' + str(x)<br>

  print exp<br>  grass.mapcalc(exp, quiet=False, verbose=False, overwrite=True)<br></span></div><span style="font-family:courier new,monospace">  grass.run_command('g.rename', flag='o', rast = ('out','sun'))</span><br>

<br></div>This doesn't result in the expected outcome.<br></div>sun is equal to global1 and no values are added<br></div></div>out is global1+global2 but is no more values are added. But mapcalc is called several times.<br>

I've tested this with:<br><span style="font-family:courier new,monospace">r.what --v -f -n input=global1 east_north=156287.225281,383024.737026<br>r.what --v -f -n input=sun east_north=156287.225281,383024.737026<br>
r.what --v -f -n input=out east_north=156287.225281,383024.737026<br>
</span><br></div>Not only am I a new user to GRASS but I'm also still a novice in Python. Most likely it is something in my script.<br><br></div>If somebody has a different approach to get the solar radiation of a whole year I'm happy to try that.<br>

<br></div>Thanks,<br><br>Paul<br><br><div><div><div><div><br><div><div><div><div><div><div><div><div><div class="gmail_extra"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


Date: Fri, 28 Dec 2012 14:36:15 +0200<br>
From: "S. Koukoulas (lists)" <<a href="mailto:sotkouklistes@gmail.com">sotkouklistes@gmail.com</a>><br>
To: <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
Subject: Re: [GRASS-user] Grass, Python, mapcalc<br>
Message-ID: <<a href="mailto:50DD923F.806@gmail.com">50DD923F.806@gmail.com</a>><br>
Content-Type: text/plain; charset=windows-1252<br>
<br>
To my experience with r.mapcalc you cannot do what yo do with<br>
programming languages... e.g. i=i+1 will not work directly. Instead you<br>
could try a more indirect way, something like (here is an example with<br>
bash shell script):<br>
<br>
#g.mremove rast=out* (to remove previous stuff, if needed)<br>
r.mapcalc sun=global1<br>
for a in ?seq 2 10?; do<br>
r.mapcalc out = sun + global$a<br>
g.rename --o rast=out,sun<br>
done<br>
<br>
basically the main idea is to use an intermediate map and then before<br>
the loop ends, pass it (with g.rename) to the map variable you want.<br>
There might be a more elegant way with python, but hopefully this shell<br>
script example might help you.<br>
HTH,<br>
sotiris<br></blockquote></div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div>