def test_remove_procedure_exclude(self): """Test that exclude does not list excluded maps""" rmapcalc("test_apples = 100") rmapcalc("test_oranges = 200") rmapcalc("test_apples_big = 300") rmapcalc("test_apples_small = 300") module = SimpleModule('g.remove', type='raster', pattern='test_{apples,oranges}*', exclude="*_small") self.assertModule(module) self.assertMultiLineEqual( module.outputs.stdout, 'raster/test_apples@user1\n' 'raster/test_apples_big@user1\n' 'raster/test_oranges@user1\n'.replace('user1', get_current_mapset())) module = SimpleModule('g.remove', type='raster', pattern='test_{apples,oranges}{_small,_big,*}', flags='f') self.assertModule(module) self.assertMultiLineEqual(module.outputs.stdout, '') self.assertRegexpMatches(module.outputs.stderr, "(.*<.+>[^\n]*\n){4}", msg="4 maps should be removed")
def test_remove_procedure_exclude(self): """Test that exclude does not list excluded maps""" rmapcalc("test_apples = 100") rmapcalc("test_oranges = 200") rmapcalc("test_apples_big = 300") rmapcalc("test_apples_small = 300") module = SimpleModule( "g.remove", type="raster", pattern="test_{apples,oranges}*", exclude="*_small", ) self.assertModule(module) self.assertMultiLineEqual( module.outputs.stdout, "raster/test_apples@user1\n" "raster/test_apples_big@user1\n" "raster/test_oranges@user1\n".replace("user1", get_current_mapset()), ) module = SimpleModule( "g.remove", type="raster", pattern="test_{apples,oranges}{_small,_big,*}", flags="f", ) self.assertModule(module) self.assertMultiLineEqual(module.outputs.stdout, "") self.assertRegexpMatches(module.outputs.stderr, "(.*<.+>[^\n]*\n){4}", msg="4 maps should be removed")
def test_remove_procedure(self): """Test that maps are removed only with -f""" for i in range(0, 10): rmapcalc("test_map_%i = 100" % i) rmapcalc("test_two = 2") module = SimpleModule('g.remove', type='rast', pattern='test_map_*,*two') self.assertModule(module) self.assertMultiLineEqual(module.outputs.stdout, REMOVE_RASTERS.replace('user1', get_current_mapset())) module = SimpleModule('g.remove', type='rast', pattern='test_map_*,*two', flags='f') self.assertModule(module) self.assertMultiLineEqual(module.outputs.stdout, '') self.assertMultiLineEqual(module.outputs.stderr, REMOVING_RASTERS_LOG)
def test_remove_procedure(self): """Test that maps are removed only with -f""" for i in range(0, 10): rmapcalc("test_map_%i = 100" % i) rmapcalc("test_two = 2") module = SimpleModule('g.remove', type='raster', pattern='test_map_*,*two') self.assertModule(module) self.assertMultiLineEqual( module.outputs.stdout, REMOVE_RASTERS.replace('user1', get_current_mapset())) module = SimpleModule('g.remove', type='raster', pattern='test_map_*,*two', flags='f') self.assertModule(module) self.assertMultiLineEqual(module.outputs.stdout, '') self.assertMultiLineEqual(module.outputs.stderr, REMOVING_RASTERS_LOG)
def test_remove_procedure_exclude(self): """Test that exclude does not list excluded maps""" rmapcalc("test_apples = 100") rmapcalc("test_oranges = 200") rmapcalc("test_apples_big = 300") rmapcalc("test_apples_small = 300") module = SimpleModule('g.remove', type='rast', pattern='test_{apples,oranges}*', exclude="*_small") self.assertModule(module) self.assertMultiLineEqual(module.outputs.stdout, 'rast/test_apples@user1\n' 'rast/test_apples_big@user1\n' 'rast/test_oranges@user1\n'.replace( 'user1', get_current_mapset())) module = SimpleModule('g.remove', type='rast', pattern='test_{apples,oranges}{_small,_big,*}', flags='f') self.assertModule(module) self.assertMultiLineEqual(module.outputs.stdout, '') self.assertRegexpMatches(module.outputs.stderr, "(.*<.+>[^\n]*\n){4}", msg="4 maps should be removed")
output=stc_surface_increasing_countours) # invert surface to have time going down the hill #rmapcalc('%s = -%s' % (stc_surface_decreasing_elevation, stc_surface_increasing_elevation)) # compute surface properties # computing slope (surface gradient magnitude) # and aspect (surface gradient direction projected to xy plane) #run_command('r.slope.aspect', elevation=stc_surface_increasing_elevation, # slope=stc_surface_decreasing_slope, # aspect=stc_surface_decreasing_aspect, # format='degrees', precision='FCELL', # zfactor=1.0, min_slp_allowed=0.0) # invert slope to have higher values where slope is lower # to avoid negative values subtract from global max instead of 0 # using 90 as maximum slope possible rmapcalc('eval(t = 1. / tan({slope}))\n{speed} = if(t > 15, 15, t)'.format(speed=speed, slope=stc_surface_increasing_slope)) rmapcalc('eval(f = 180 + {a})\n{d} = if(f > 360, f - 360, f)'.format(d=direction, a=stc_surface_increasing_aspect)) num_elev = len(elevations) expr_eval_values = [] expr_comp_values = [] for i in range(num_elev): if num_elev > i + 1: expr_comp = "" a = elevations[i] b = elevations[i + 1] r = 'rc' + a + b expr_comp += "{r} = xor({a} > {l}, {b} > {l})".format(a=a, b=b, l=level, r=r) expr_comp_values.append(expr_comp) expr_eval_values.append("{r}".format(r=r))