[GRASS-dev] grass.mapcalc() python wrapper using grass.start_command()

Hamish hamish_b at yahoo.com
Sun Jun 24 19:34:25 PDT 2012


Hi,

in making some of the python modules multithreaded, it would be
useful to have a version of grass.mapcalc() which didn't wait
until it was done, and returned the Popen object instead.

e.g. to process three r,g,b bands in parallel.

I just added an experimental grass.mapcalc_start() fn to trunk/
lib/python/raster.py, any comments or better ideas how to do it?


An alternative is to just use grass.start_command('r.mapcalc', ..)



thanks,
Hamish

ps- besides the already parallelized i.oif.py in trunk/scripts/
(using the grass.start_command() for backgrounding individual
system()-like calls), I've now updated i.landsat.rgb.py for
multi-proc support using a method which spawns at the python
function level using python's multiprocessing module, on systems
where that's available. It is not as clean as method i.oif.py
uses, hints to make it (i.landsat.rgb.py) more elegant are
welcome. It's nice and fast though, it now finishes in 1.6 sec
instead of 8 sec on my test case.


More information about the grass-dev mailing list