def run_benchmark(resolution_list, runs, testdict, profile): regions = [] for resolution in resolution_list: core.use_temp_region() core.run_command("g.region", e=50, w=-50, n=50, s=-50, res=resolution, flags="p") # Adjust the computational region for this process region = libgis.Cell_head() libraster.Rast_get_window(ctypes.byref(region)) region.e = 50 region.w = -50 region.n = 50 region.s = -50 region.ew_res = resolution region.ns_res = resolution libgis.G_adjust_Cell_head(ctypes.byref(region), 0, 0) libraster.Rast_set_window(ctypes.byref(region)) libgis.G_set_window(ctypes.byref(region)) # Create two raster maps with random numbers core.mapcalc("test_a = rand(0, 100)", quite=True, overwrite=True) core.mapcalc("test_b = rand(0.0, 1.0)", quite=True, overwrite=True) result = collections.OrderedDict() result["res"] = resolution result["cols"] = region.cols result["rows"] = region.rows result["cells"] = region.rows * region.cols result["results"] = copy.deepcopy(testdict) for execmode, operation in result["results"].items(): print(execmode) for oper, operdict in operation.items(): operdict["time"], operdict["times"] = mytimer( operdict["func"], runs) if profile: filename = "{0}_{1}_{2}".format(execmode, oper, profile) cProfile.runctx( operdict["func"].__name__ + "()", globals(), locals(), filename=filename, ) print((" {0}: {1: 40.6f}s".format(oper, operdict["time"]))) del operdict["func"] regions.append(result) core.del_temp_region() return regions
def set_current(self): """Set the current working region from this region object This function adjusts the values before setting the region so you don't have to call G_adjust_Cell_head(). Attention: Only the current process is affected. The GRASS computational region is not affected. Example:: >>> r = Region() >>> r.north 40.0 >>> r.south 0.0 >>> r.north = 30 >>> r.south = 20 >>> r.set_current() >>> r.north 30.0 >>> r.south 20.0 >>> r.get_current() >>> r.north 30.0 >>> r.south 20.0 >>> r.read(force_read=False) >>> r.north 40.0 >>> r.south 0.0 >>> r.read(force_read=True) >>> r.north 40.0 >>> r.south 0.0 """ libgis.G_set_window(self.byref())
def set_current(self): libgis.G_set_window(self.c_region)
def set_current(self): """Set the Region object to the current GRASS region""" libgis.G_set_window(self.c_region)