<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000099" bgcolor="#FFFFFF">
How do I use this new flag / seed parameter for r.mapcalc in python
scripts? I have for example a script where I can define the seed, or
if left empty I want to set the 's' flag:<br>
<br>
if seed == "": <br>
grass.mapcalc("$tmp_map = rand(${minval},${maxval})", <br>
minval = minval, <br>
maxval = maxval,<br>
tmp_map = tmp_map)<br>
else: <br>
grass.mapcalc("$tmp_map = rand(${minval},${maxval})", <br>
minval = minval, <br>
maxval = maxval,<br>
tmp_map = tmp_map)<br>
<br>
Where I need to set the flag='s' in the first instance or the seed=
in the second instance<br>
<br>
<br>
<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 23-07-14 02:14, Glynn Clements
wrote:<br>
</div>
<blockquote
cite="mid:21454.65096.381946.854955@cerise.gclements.plus.com"
type="cite">
<pre wrap="">
Glynn Clements wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I'm inclined to add both an option (to specify a seed, replacing the
environment variable) and a flag (to seed from the system clock or
whatever), and having the PRNG generate a fatal error if neither of
those are used.
</pre>
</blockquote>
<pre wrap="">
This is now done.
r61350 adds the lrand48/mrand48/drand48 equivalents to lib/gis. Brief
testing suggests that the results are identical to those generated by
GNU libc (which should be identical to any other POSIX implementation).
r61352 changes it to generate a fatal error if used prior to seeding.
r61353 changes r.mapcalc so that seeding is performed via seed= or -s.
The seed (whether specified by seed= or generated for -s) is added to
the history (for r.mapcalc; r3.mapcalc's create_history() function is
a stub; do 3D rasters have history?)
Note that GRASS_RND_SEED is no longer supported. That was a hack from
the time before r.mapcalc used G_parser().
As I write this, it has occurred to me that the behaviour of rand()
may be non-deterministic in the presence of certain forms of
parallelism, e.g. multiple occurences of rand() in the expression(s)
in conjunction with pthreads. Ultimately we may need to expand the
PRNG to support explicit state (as per erand48, nrand48 and jrand48).
</pre>
</blockquote>
<br>
</body>
</html>