def test_gradient_d4_nw(self): """ Test for the gradient_d4 for nw """ # test northwest slope and aspect dem = self.gen_dem_nw() py_slope, asp = gradient.gradient_d4(dem, self.dx, self.dy) ipw_a = gradient.aspect_to_ipw_radians(asp) self.assertTrue(np.all(py_slope == self.slope_val)) self.assertTrue(np.all(asp == 315)) self.assertTrue(np.all(ipw_a == (-np.pi / 2 - np.pi / 4)))
def test_gradient_d4_south(self): """ Test for the gradient_d4 for south """ # test south slope and aspect dem = np.flipud(np.tile(range(10), (10, 1)).transpose()) py_slope, asp = gradient.gradient_d4(dem, self.dx, self.dy) ipw_a = gradient.aspect_to_ipw_radians(asp) self.assertTrue(np.all(py_slope == np.pi / 4)) self.assertTrue(np.all(asp == 180)) self.assertTrue(np.all(ipw_a == 0))
def test_gradient_d4_flat(self): """ Test for the gradient_d4 for flat """ # test south slope and aspect dem = np.ones((10, 10)) py_slope, asp = gradient.gradient_d4(dem, self.dx, self.dy) ipw_a = gradient.aspect_to_ipw_radians(asp) self.assertTrue(np.all(py_slope == 0)) self.assertTrue(np.all(asp == 180)) self.assertTrue(np.all(ipw_a == 0))
def test_gradient_d4_east(self): """ Test for the gradient_d4 for east """ # test east slope and aspect dem = np.fliplr(np.tile(range(10), (10, 1))) py_slope, asp = gradient.gradient_d4(dem, self.dx, self.dy) ipw_a = gradient.aspect_to_ipw_radians(asp) self.assertTrue(np.all(py_slope == np.pi / 4)) self.assertTrue(np.all(asp == 90)) self.assertTrue(np.all(ipw_a == np.pi / 2))
def test_gradient_d4_se(self): """ Test for the gradient_d4 for se """ # test southeast slope and aspect dem = self.gen_dem_se() py_slope, asp = gradient.gradient_d4(dem, self.dx, self.dy) ipw_a = gradient.aspect_to_ipw_radians(asp) self.assertTrue(np.all(py_slope == self.slope_val)) self.assertTrue(np.all(asp == 135)) self.assertTrue(np.all(ipw_a == np.pi / 4))