示例#1
0
 def tearDown(self):
     call_module(
         "g.remove",
         flags="f",
         type_="raster",
         name=[self.average, self.count, self.median, self.sum_],
     )
 def setUpClass(cls):
     cls.use_temp_region()
     call_module('g.region', n=20, s=10, e=25, w=15, res=1)
     cls.elevation = 'fractal_surf'
     cls.runModule('r.in.ascii',
                   input='data/fractal_surf.ascii',
                   output=cls.elevation)
示例#3
0
 def setUpClass(cls):
     cls.use_temp_region()
     call_module("g.region", n=20, s=10, e=25, w=15, res=1)
     cls.elevation = "fractal_surf"
     cls.runModule("r.in.ascii",
                   input="data/fractal_surf.ascii",
                   output=cls.elevation)
示例#4
0
 def tearDownClass(cls):
     cls.del_temp_region()
     call_module(
         'g.remove',
         flags='f',
         type_='raster',
         name=[cls.t_aspect, cls.t_slope, cls.s_slope, cls.s_aspect])
示例#5
0
 def tearDownClass(self):
     self.del_temp_region()
     call_module(
         "g.remove",
         flags="f",
         type_="raster",
         name=self.sum_mapcalc,
     )
示例#6
0
 def tearDown(self):
     self.del_temp_region()
     call_module(
         "g.remove",
         flags="f",
         type_="raster",
         name=[self.slope, self.aspect, self.elevation],
     )
示例#7
0
 def tearDownClass(cls):
     cls.del_temp_region()
     call_module(
         "g.remove",
         flags="f",
         type_="raster",
         name=[cls.t_aspect, cls.t_slope, cls.s_slope, cls.s_aspect],
     )
示例#8
0
 def tearDown(self):
     self.del_temp_region()
     call_module(
         "g.remove",
         flags="f",
         type_="raster",
         name=[self.base, self.cover],
     )
示例#9
0
 def test_area_attrs_to_3d_points(self):
     """Check that values are uploaded to 3D points in areas (dmax=0)"""
     call_module('v.distance', from_=self.points_3d, to=self.areas,
                 dmax=0, upload='to_attr',
                 column='area_label', to_column='label')
     table = call_module('v.db.select', map=self.points_3d,
                         separator='pipe', flags='c')
     self.assertMultiLineEqual(table, table_ref)
示例#10
0
 def test_location_exists(self):
     """Test that different parameter combinations work and return true"""
     db_path = call_module("g.gisenv", get="GISDBASE").strip()
     loc_name = call_module("g.gisenv", get="LOCATION_NAME").strip()
     self.assertTrue(location_exists(db_path, loc_name))
     self.assertTrue(location_exists(os.path.join(db_path, loc_name)))
     self.assertTrue(location_exists(Path(db_path), loc_name))
     self.assertTrue(location_exists(Path(db_path) / loc_name))
示例#11
0
 def test_get_list_of_locations(self):
     """Test that different parameter combinations work and return true"""
     db_path = call_module("g.gisenv", get="GISDBASE").strip()
     current_loc_name = call_module("g.gisenv", get="LOCATION_NAME").strip()
     list_of_locations = get_list_of_locations(db_path)
     self.assertTrue(list_of_locations,
                     msg="No locations in the current db found")
     self.assertIn(current_loc_name, list_of_locations)
示例#12
0
    def test_default_mapset_with_path(self):
        """Check that default mapset is found for path.

        This requires the location (with default mapset) to exists.
        """
        db_path = call_module("g.gisenv", get="GISDBASE").strip()
        loc_name = call_module("g.gisenv", get="LOCATION_NAME").strip()
        mapset_path = resolve_mapset_path(path=Path(db_path) / loc_name)
        self.assertEqual(mapset_path.mapset, "PERMANENT")
示例#13
0
    def test_default_mapset_exists(self):
        """Check that default mapset is found for real path/location.

        The location (or mapset) may not exist, but exist in the test.
        """
        db_path = call_module("g.gisenv", get="GISDBASE").strip()
        loc_name = call_module("g.gisenv", get="LOCATION_NAME").strip()
        mapset_path = resolve_mapset_path(path=db_path, location=loc_name)
        self.assertEqual(mapset_path.mapset, "PERMANENT")
示例#14
0
 def test_area_attrs_to_2d_points(self):
     """Check that values are uploaded to 2D points in areas (dmax=0)"""
     # using call_module because PyGRASS doen't accept form_
     call_module('v.distance', from_=self.points, to=self.areas,
                 dmax=0, upload='to_attr',
                 column='area_label', to_column='label')
     # using call_module because it is easier
     table = call_module('v.db.select', map=self.points,
                         separator='pipe', flags='c')
     self.assertMultiLineEqual(table, table_ref)
示例#15
0
    def test_band_ref_assign(self):
        # copy raster map to the current mapset
        call_module('g.copy',
                    raster='{m}@PERMANENT,{m}'.format(m=self.raster_map))

        module = SimpleModule('i.band', map=self.raster_map,
                              band=self.band_ref)
        self.assertModule(module)

        # check also using pygrass
        self.assertEqual(self.read_band_ref(), self.band_ref)
示例#16
0
 def test_valid_mapset(self):
     """Test that different parameter combinations work and return true"""
     db_path = call_module("g.gisenv", get="GISDBASE").strip()
     loc_name = call_module("g.gisenv", get="LOCATION_NAME").strip()
     mapset_name = call_module("g.gisenv", get="MAPSET").strip()
     self.assertTrue(is_mapset_valid(db_path, loc_name, mapset_name))
     self.assertTrue(
         is_mapset_valid(os.path.join(db_path, loc_name, mapset_name)))
     self.assertTrue(is_mapset_valid(Path(db_path), loc_name, mapset_name))
     self.assertTrue(is_mapset_valid(
         Path(db_path) / loc_name / mapset_name))
示例#17
0
 def test_small(self):
     elevation = 'small_elevation'
     slope = 'small_slope'
     aspect = 'small_aspect'
     self.runModule('r.in.ascii', input='-', output=elevation,
                    stdin_=SMALL_MAP)
     call_module('g.region', rast=elevation)
     self.assertModule('r.slope.aspect', elevation=elevation,
                       slope=slope, aspect=aspect)
     self.assertRasterMinMax(map=slope, refmin=0, refmax=90,
                             msg="Slope in degrees must be between 0 and 90")
     self.assertRasterMinMax(map=aspect, refmin=0, refmax=360,
                             msg="Aspect in degrees must be between 0 and 360")
示例#18
0
 def test_area_attrs_to_3d_points(self):
     """Check that values are uploaded to 3D points in areas (dmax=0)"""
     call_module(
         "v.distance",
         from_=self.points_3d,
         to=self.areas,
         dmax=0,
         upload="to_attr",
         column="area_label",
         to_column="label",
     )
     table = call_module("v.db.select",
                         map=self.points_3d,
                         separator="pipe",
                         flags="c")
     self.assertMultiLineEqual(table, table_ref)
示例#19
0
 def test_no_output(self):
     output = call_module('m.proj',
                          flags='i',
                          input='-',
                          stdin="50.0 41.5",
                          capture_stdout=False)
     self.assertIsNone(output)
示例#20
0
 def test_no_output(self):
     output = call_module("m.proj",
                          flags="i",
                          input="-",
                          stdin="50.0 41.5",
                          capture_stdout=False)
     self.assertIsNone(output)
示例#21
0
 def test_merge_stderr(self):
     output = call_module('m.proj',
                          flags='i',
                          input='-',
                          stdin="50.0 41.5",
                          verbose=True,
                          merge_stderr=True)
     self.assertLooksLike(output, '...+proj=longlat +datum=WGS84...')
     self.assertLooksLike(output, '...|...\n')
示例#22
0
 def test_area_attrs_to_2d_points(self):
     """Check that values are uploaded to 2D points in areas (dmax=0)"""
     # using call_module because PyGRASS doen't accept form_
     call_module(
         "v.distance",
         from_=self.points,
         to=self.areas,
         dmax=0,
         upload="to_attr",
         column="area_label",
         to_column="label",
     )
     # using call_module because it is easier
     table = call_module("v.db.select",
                         map=self.points,
                         separator="pipe",
                         flags="c")
     self.assertMultiLineEqual(table, table_ref)
示例#23
0
 def test_small(self):
     self.runModule("r.in.ascii",
                    input="-",
                    output=self.elevation,
                    stdin_=SMALL_MAP)
     call_module("g.region", raster=self.elevation)
     self.assertModule(
         "r.slope.aspect",
         elevation=self.elevation,
         slope=self.slope,
         aspect=self.aspect,
     )
     self.assertModule(
         "r.slope.aspect",
         elevation=self.elevation,
         slope=self.slope_threaded,
         aspect=self.aspect_threaded,
         nprocs=8,
     )
     self.assertRasterMinMax(
         map=self.slope,
         refmin=0,
         refmax=90,
         msg="Slope in degrees must be between 0 and 90",
     )
     self.assertRasterMinMax(
         map=self.slope_threaded,
         refmin=0,
         refmax=90,
         msg="Slope in degrees must be between 0 and 90",
     )
     self.assertRasterMinMax(
         map=self.aspect,
         refmin=0,
         refmax=360,
         msg="Aspect in degrees must be between 0 and 360",
     )
     self.assertRasterMinMax(
         map=self.aspect_threaded,
         refmin=0,
         refmax=360,
         msg="Aspect in degrees must be between 0 and 360",
     )
示例#24
0
 def test_small(self):
     self.runModule('r.in.ascii',
                    input='-',
                    output=self.elevation,
                    stdin_=SMALL_MAP)
     call_module('g.region', raster=self.elevation)
     self.assertModule('r.slope.aspect',
                       elevation=self.elevation,
                       slope=self.slope,
                       aspect=self.aspect)
     self.assertRasterMinMax(
         map=self.slope,
         refmin=0,
         refmax=90,
         msg="Slope in degrees must be between 0 and 90")
     self.assertRasterMinMax(
         map=self.aspect,
         refmin=0,
         refmax=360,
         msg="Aspect in degrees must be between 0 and 360")
示例#25
0
 def test_merge_stderr(self):
     output = call_module(
         "m.proj",
         flags="i",
         input="-",
         stdin="50.0 41.5",
         verbose=True,
         merge_stderr=True,
     )
     self.assertLooksLike(output, "...+proj=longlat +datum=WGS84...")
     self.assertLooksLike(output, "...|...\n")
示例#26
0
 def setUpClass(cls):
     cls.use_temp_region()
     call_module('g.region', rast='elevation')
示例#27
0
 def setUpClass(cls):
     cls.use_temp_region()
     call_module('g.region', n=20, s=10, e=25, w=15, res=1)
     cls.elevation = 'fractal_surf'
     cls.runModule('r.in.ascii', input='data/fractal_surf.ascii',
                    output=cls.elevation)
示例#28
0
 def setUp(self):
     self.use_temp_region()
     call_module("g.region", raster="elevation")
示例#29
0
 def setUpClass(cls):
     """Ensures expected computational region"""
     # to not override mapset's region (which might be used by other tests)
     cls.use_temp_region()
     call_module('r.in.ascii',
                 input=cls.grnd_conductivity_file,
                 output=cls.grnd_conductivity,
                 overwrite=True)
     call_module('r.in.ascii',
                 input=cls.norm_time_hs_ref_file,
                 output=cls.norm_time_hs_ref,
                 overwrite=True)
     call_module('r.in.ascii',
                 input=cls.norm_time_lt_ref_file,
                 output=cls.norm_time_lt_ref,
                 overwrite=True)
     call_module('r.in.ascii',
                 input=cls.gmax_ref_file,
                 output=cls.gmax_ref,
                 overwrite=True)
     call_module('r.in.ascii',
                 input=cls.power_ref_file,
                 output=cls.power_ref,
                 overwrite=True)
     call_module('r.in.ascii',
                 input=cls.energy_ref_file,
                 output=cls.energy_ref,
                 overwrite=True)
     call_module('g.region', raster=cls.grnd_conductivity)
示例#30
0
 def setUpClass(cls):
     cls.use_temp_region()
     call_module("g.region", raster=cls.elevation)
     call_module("r.mapcalc",
                 expression=f"{cls.sum_mapcalc} = {cls.elevation} * 4")
示例#31
0
 def setUpClass(cls):
     cls.use_temp_region()
     call_module('g.region', rast='elevation')
示例#32
0
 def test_merge_stderr(self):
     output = call_module('m.proj', flags='i', input='-', stdin="50.0 41.5",
                          verbose=True,
                          merge_stderr=True)
     self.assertLooksLike(output, '...+proj=longlat +datum=WGS84...')
     self.assertLooksLike(output, '...|...\n')
示例#33
0
 def test_no_output(self):
     output = call_module('m.proj', flags='i', input='-', stdin="50.0 41.5",
                          capture_stdout=False)
     self.assertIsNone(output)
示例#34
0
 def test_input_output(self):
     output = call_module('m.proj', flags='i', input='-', stdin="50.0 41.5")
     self.assertLooksLike(output, '...|...\n')
示例#35
0
 def test_dir_contains_location(self):
     """Test that different parameter combinations work and return true"""
     db_path = call_module("g.gisenv", get="GISDBASE").strip()
     self.assertTrue(dir_contains_location(db_path))
     self.assertTrue(dir_contains_location(Path(db_path)))
示例#36
0
 def test_input_output(self):
     output = call_module('m.proj', flags='i', input='-', stdin="50.0 41.5")
     self.assertLooksLike(output, '...|...\n')
示例#37
0
 def test_output(self):
     output = call_module('g.region', flags='pg')
     self.assertLooksLike(output, G_REGION_OUTPUT)