<div dir="ltr"><div>Here I am again with some questions ;)<br><br></div>I'm now trying to use r.sun and r.mapcalc with Python to create my annual solar radiation map.<br clear="all"><div><div><div><div>I'm using the Python shell inside GRASS.<br>

<br></div><div>For testing purposes I start with 9 days.<br></div><div>The r.sun part seems to be working:<span style="font-family:courier new,monospace"><br>for x in range(1, 10, 1):<br>    print "Working on day %d" % (x)<br>

    glob_rad = 'global' + str(x)<br>    grass.run_command('r.sun', flags = 's', elevin = 'w001001@temp', aspin = 'aspect@temp', slopein = 'slope@temp', glob_rad = glob_rad, day = x)</span><br>

</div><div>I do have a question about parsing the --overwrite flag. How to do that. Adding <span style="font-family:courier new,monospace">flags='s, --overwrite</span>' or <span style="font-family:courier new,monospace">flags='s, -overwrite'</span> gives a compile error.<br>

</div><div><br></div><div>Now I try to combine the results of r.sun into 1 raster.<br></div><div>This is working:<br></div><div><span style="font-family:courier new,monospace">for x in range(1, 10, 1):    <br>    if x == 2:<br>

      exp = 'sun = global1@temp + global2@temp'<br>      print exp<br>      grass.mapcalc(exp, quiet=False, verbose=False, overwrite=True)</span><br><br></div><div>This is also working:<br></div><div><span style="font-family:courier new,monospace">for x in range(1, 10, 1):    <br>

    if x == 2:<br>      exp = 'sun = global1@temp + global2@temp'<br>      print exp<br>      grass.mapcalc(exp, quiet=False, verbose=False, overwrite=True)<br>    elif x > 2:  <br>      exp = 'sun = sun@temp + global' + str(x) + '@temp'<br>

      print exp</span><br></div><div>and produces this output:<br><span style="font-family:courier new,monospace">sun = sun@temp + global3@temp <br>sun = sun@temp + global4@temp <br>sun = sun@temp + global5@temp <br>sun = sun@temp + global6@temp <br>

sun = sun@temp + global7@temp <br>sun = sun@temp + global8@temp <br>sun = sun@temp + global9@temp</span><br></div><div>But when I execute this using <br></div><div><span style="font-family:courier new,monospace">grass.mapcalc(exp, quiet=False, verbose=False, overwrite=True)<br>

</span></div><div><span style="font-family:courier new,monospace"></span></div><div>
Grass crashes completely.<br><br></div><div>Has this something to do with having the output file is the input file as well?<br></div><div>If this is not allowed how can I combine all output files from r.sun into 1 raster?<br>

<br></div><div>Thanks,<br></div><div>
<br>Paul</div>
</div></div></div></div>