コード例 #1
0
 def test_flow_properties_02(self):
     # Testing an empty Flow object
     dem = DEM()
     fd = Flow()
     computed = (fd.get_size(), fd.get_dims(), fd.get_ncells(), fd.get_projection(), fd.get_cellsize(), fd.get_geotransform())
     expected = (dem.get_size(), dem.get_dims(), dem.get_ncells(), dem.get_projection(), dem.get_cellsize(), dem.get_geotransform())
     self.assertEqual(computed, expected)    
コード例 #2
0
 def test_flow_properties_01(self):
     files = ["small", "small25", "morocco", "tunez", "jebja30"]
     for file in files:
         dem = DEM(infolder + "/{0}.tif".format(file))
         fd = Flow(infolder +  "/{0}_fd.tif".format(file))
         computed = (fd.get_size(), fd.get_dims(), fd.get_ncells(), fd.get_projection(), fd.get_cellsize(), fd.get_geotransform())
         expected = (dem.get_size(), dem.get_dims(), dem.get_ncells(), dem.get_projection(), dem.get_cellsize(), dem.get_geotransform())
         self.assertEqual(computed, expected)
コード例 #3
0
    def test_drainage_basins_01(self):
        # Test 10 random basins
        files = ["small25", "tunez", "jebja30"]
        for file in files:
            flw_path = infolder + "/{0}_fd.tif".format(file)
            fd = Flow(flw_path)

            # Creamos 10 cuencas aleatorias con 10 ids aleatorios
            ri = np.random.randint(0, fd.get_dims()[0], 10)
            ci = np.random.randint(0, fd.get_dims()[1], 10)
            rdn_ids = np.random.randint(100, 700, 10)
            xi, yi = fd.cell_2_xy(ri, ci)
            # Extract basins
            outlets = np.array((xi, yi, rdn_ids)).T
            basins = fd.get_drainage_basins(outlets)
            basins.save(outfolder + "/rnd_basins_{0}.tif".format(file))
コード例 #4
0
    def test_drainage_basins_00(self):
        # Test 10 random basins
        files = ["small25", "tunez", "jebja30"]
        for file in files:
            flw_path = infolder + "/{0}_fd.tif".format(file)
            fd = Flow(flw_path)

            # Creamos 10 cuencas aleatorias
            ri = np.random.randint(0, fd.get_dims()[0], 10)
            ci = np.random.randint(0, fd.get_dims()[1], 10)
            rdn_ids = np.random.randint(100, 700, 10)
            xi, yi = fd.cell_2_xy(ri, ci)
            # Extract basins
            outlets = np.array((xi, yi, rdn_ids)).T
            threshold = int(fd.get_ncells() * 0.05)
            snap_outlets = fd.snap_points(outlets, threshold, kind="channel")
            snap = np.append(snap_outlets, rdn_ids.reshape(rdn_ids.size, 1), 1)
            basins = fd.get_drainage_basins(snap)

            basins.save(outfolder + "/rnd_snap_basins_{0}.tif".format(file))
コード例 #5
0
ファイル: test_Network.py プロジェクト: NengLu/topopy
 def test_create_load(self):
     dem_files = ['tunez', 'tunez2', 'small25']
     for filename in dem_files:
         fd = Flow("data/fd_{0}.tif".format(filename))
         st = Network(fd, 1000)
         computed = [
             st.get_dims(),
             st.get_size(),
             st.get_ncells(),
             st.get_cellsize(),
             st.get_geotransform(),
             st.get_projection()
         ]
         expected = [
             fd.get_dims(),
             fd.get_size(),
             fd.get_ncells(),
             fd.get_cellsize(),
             fd.get_geotransform(),
             fd.get_projection()
         ]
         self.assertTrue(computed, expected)