<p>Hi Paul,</p>
<p>I think one of your problems is... using windows ;) I have heard that the Windows version of GRASS works a LOT better than it used to, but GRASS was actually the reason I switched to Linux a couple of years ago. Back then it just ran better in Linux - a lot better. Since then, I've never gone back to Windows because I'm very satisfied with Linux, not just with GRASS but with everything else I do with the computer. Of course, Linux vs. Windows is a whole different story and doesn't belong in this list, but that was my experience.</p>
<p>If you're wanting to use GRASS in a headless Ubuntu server anyway, why don't you set up a Linux machine or at least a Linux installation in a virtual machine and play around with it there? There everything should work well and the development environment would match your production environment. OSGeo has a great live installation including all of the latest Geo software, Python, etc. - everything the;heart could desire. since I'm out and about at the moment I can't send you the address, but just Google for an OSGeo live installation and you'll see it right away.</p>
<p>Hope that helps,<br>
Daniel</p>
<div class="gmail_quote">Am 28.12.2012 15:28 schrieb "Paul Meems" <<a href="mailto:bontepaarden@gmail.com">bontepaarden@gmail.com</a>>:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div><div><div><div>Hi Sotiris,<br><br></div>Thanks for your help.<br></div>I will have a look at the r.series.<br></div><br>Meanwhile I've discovered the graphical modeler. It is not working 100% in all cases but it does generates a Python script with all the necessary parameters.<br>
<br></div>This is my script so far, which seems to be working:<br><span style="font-family:courier new,monospace">for x in range(1, 10, 1):<br> print "Working on day %d" % (x)<br> # Create radiation for each day:<br>
glob_rad = 'global' + str(x)<br> grass.run_command('r.sun', flags = 's', overwrite = True, elevin = 'w001001@temp', aspin = 'aspect@</span><span style="font-family:courier new,monospace">temp', slopein = 'slope@temp', glob_rad = glob_rad, day = x)<br>
<br> # Combine the radiation file with the previous one:<br> if x == 2:<br> grass.run_command("r.mapcalculator", overwrite = True, amap = "global1", bmap = "global2", formula = "A+B",<br>
outfile = "suntemp2") <br> elif x > 2: <br> # Use temp name or else it won't work:<br> amap = "suntemp" + str(x-1)<br> bmap = "global" + str(x) + "@temp"<br>
outfile = "suntemp" + str(x) <br> grass.run_command("r.mapcalculator", overwrite = True, amap = amap, bmap = bmap, formula = "A+B",<br> outfile = outfile)<br>
<br># Finalize:<br>grass.mapcalc('sun=' + outfile, quiet=False, verbose=True, overwrite=True)<br># Clean up: <br>grass.run_command('g.mremove', flags = 'f', rast = "suntemp*") <br>
grass.run_command('g.mremove', flags = 'f', rast = "global*")<br>print "Done"</span><br><br></div>Thanks<br clear="all"><div class="gmail_extra"><div>
<br>
Paul<br></div><br><div class="gmail_quote">2012/12/28 S. Koukoulas (lists) <span dir="ltr"><<a href="mailto:sotkouklistes@gmail.com" target="_blank">sotkouklistes@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Dear Paul,<br>
<br>
having said all that for r.mapcalc, I wonder whether you really need<br>
mapcalc. In your case,<br>
couldn't you just use the * r.series * command with Sum (and perhaps<br>
g.mlist can help you make a list of all the daily maps).<br>
<br>
I think that it might be faster as well.<br>
best,<br>
sotiris<br>
<div><div><br>
On 12/28/2012 03:08 PM, Paul Meems wrote:<br>
> Thanks Sotiris,<br>
><br>
> I've tried your suggestion but converted it to Python because I'm on<br>
> Windows.<br>
> This is my script:<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>
> grass.run_command('g.rename', flag='o', rast = ('out','sun'))<br>
><br>
> This doesn't result in the expected outcome.<br>
> sun is equal to global1 and no values are added<br>
> out is global1+global2 but is no more values are added. But mapcalc is<br>
> called several times.<br>
> I've tested this with:<br>
> 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>
><br>
> Not only am I a new user to GRASS but I'm also still a novice in<br>
> Python. Most likely it is something in my script.<br>
><br>
> If somebody has a different approach to get the solar radiation of a<br>
> whole year I'm happy to try that.<br>
><br>
> Thanks,<br>
><br>
> Paul<br>
><br>
><br>
><br>
> Date: Fri, 28 Dec 2012 14:36:15 +0200<br>
> From: "S. Koukoulas (lists)" <<a href="mailto:sotkouklistes@gmail.com" target="_blank">sotkouklistes@gmail.com</a><br>
</div></div>> <mailto:<a href="mailto:sotkouklistes@gmail.com" target="_blank">sotkouklistes@gmail.com</a>>><br>
> To: <a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a> <mailto:<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a>><br>
<div>> Subject: Re: [GRASS-user] Grass, Python, mapcalc<br>
</div>> Message-ID: <<a href="mailto:50DD923F.806@gmail.com" target="_blank">50DD923F.806@gmail.com</a> <mailto:<a href="mailto:50DD923F.806@gmail.com" target="_blank">50DD923F.806@gmail.com</a>>><br>
<div>> 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.<br>
> 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<br>
> shell<br>
> script example might help you.<br>
> HTH,<br>
> sotiris<br>
><br>
><br>
><br>
><br>
</div><div><div>> _______________________________________________<br>
> grass-user mailing list<br>
> <a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
<br>
</div></div></blockquote></div><br></div></div>
<br>_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
<br></blockquote></div>