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)
pp = np.zeros(dims, dtype=np.int32) IX = np.arange(ncells, dtype=np.int32) pp = pp.ravel() pp[ix] = IX pp = pp.reshape(dims) demarr = dem.fill_sinks().read_array() f_dem = demarr.ravel() # Get cardinal neighbors footprint = np.array([[0, 1, 0], [1, 1, 1], [0, 1, 0]], dtype=np.int) IXC1 = ndimage.morphology.grey_dilation(pp, footprint=footprint) xxx1 = np.copy(IXC1) IX = IXC1.ravel()[ix] IXC1 = ix[IX] G1 = (rdem[ix] - rdem[IXC1]) / (dem.get_cellsize()) # Get diagonal neighbors footprint = np.array([[1, 0, 1], [0, 1, 0], [1, 0, 1]], dtype=np.int) IXC2 = ndimage.morphology.grey_dilation(pp, footprint=footprint) xxx2 = np.copy(IXC2) IX = IXC2.ravel()[ix] IXC2 = ix[IX] G2 = (rdem[ix] - rdem[IXC2]) / (dem.get_cellsize() * np.sqrt(2)) del IX # Get the steepest one I = (G1 <= G2) & (xxx2.ravel()[ix] > xxx1.ravel()[ix]) ixc = IXC1 ixc[I] = IXC2[I]
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)