<div dir="ltr"><div><div><div>Dear all,<br></div>I am working on a module to extract the phenological parameters (like timesat) from a time series implemented in python/cython and making use of gscript and other grass stuff.<br></div>It works great on a 256x256 and as the plan is applying it over Australia at 250m over 17 years, I need to split the process in small tiles. The idea is to run this processes in parallel and I am having issues implementing it. <br></div><div><br></div><div>This would be the first part of the process that runs on each tile:<br></div><div><br></div><div><span style="font-family:monospace,monospace">def tile_process(tile_index):<br>    '''<br>    Function for every worker:<br>    Applies any function to the sub_region corresponding to the tile_index.<br>    '''<br>    global Rows<br>    global Cols<br>    global RowBlockSize<br>    global ColBlockSize<br>    global full_region<br>    global dates<br>    global years<br>    global indices<br>    global data_serie<br>    global yr_limits_extra<br>    global yr_limits<br>    global dbif<br><br>    sub_name='block'<br>    TileRow, TileCol, sr = sub_region(tile_index,full_region,RowBlockSize,ColBlockSize)<br>    # # Define a temporary region based on the parameters caluculated with the<br>    start_row = TileRow * RowBlockSize<br>    start_col = TileCol * ColBlockSize<br>    n_rows = sr['rows']<br>    n_cols = sr['cols']<br><br>    strds = tgis.SpaceTimeRasterDataset(data_serie)<br>    strds.select(dbif=dbif)<br>    maps = strds.get_registered_maps_as_objects(dbif=dbif)<br>    <br>    # Numer of time steps<br>    steps = len(maps)<br>    # Make an empty array<br>    #print(steps)<br>    EVI = np.empty([steps,n_rows,n_cols])<br>    # fill the array<br>    for step, map in enumerate(maps):<br>         map.select(dbif=dbif)<br>         image_name = map.get_name()+'@'+data_serie.split('@')[1]<br>         #print("reading: {}".format(image_name))<br>         EVI[step,:] = raster2numpy_sub(image_name,start_row,n_rows,start_col,n_cols)<br>    mean = EVI.mean()<br>    print(mean)<br></span></div><div><span style="font-family:monospace,monospace">    ....</span></div><div><span style="font-family:monospace,monospace">    ....</span></div><div><span style="font-family:monospace,monospace">    ....<br></span></div><div><br></div><div><br></div><div>and this is how I start the multiprocess pool.</div><div><br></div><div><span style="font-family:monospace,monospace">    pool.map(tile_process, xrange(RowBlockN*ColBlockN))<br>    pool.close()<br>    pool.join()</span><br></div><br clear="all"><div><div><div><div><div>and it gives me:</div><div><br></div><div><span style="font-family:monospace,monospace">AssertionError: can only test a child process</span><br></div><div><br></div><div><br></div><div>of course if I do: <span style="font-family:monospace,monospace">tile_process</span>(0) or <span style="font-family:monospace,monospace">tile_process</span>(1) etc ,the right result comes out.</div><div><br></div><div>Does any of you have experience with this? Any suggestion would be welcome!</div><div>Sorry for the messy code. Is still in early stage.<br></div><div><br></div><div><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><span style="font-family:times new roman,serif">Dr. Leonardo A. Hardtke   <br><span>C3 UTS, Scientific Officer<br></span>CB04.06.315.06<br></span></div><div><span style="font-family:times new roman,serif">Email:<a href="mailto:leonardoandres.hardtke@uts.edu.au" target="_blank">leonardoandres.hardtke@uts.edu.au</a> or<a href="mailto:leohardtke@gmail.com" target="_blank"> leohardtke@gmail.com</a></span><br></div></div></div></div></div></div>
</div></div></div></div></div></div>