示例#1
0
 def test_save(self):
     dem = Grid(infolder + "/small25.tif")
     dem.save(outfolder + "/a_dummy_dem.tif")
     dem2 = Grid(outfolder + "/a_dummy_dem.tif")
     expected = dem.get_value([20, 30, 40, 50], [20, 30, 40, 50])
     computed = dem2.get_value([20, 30, 40, 50], [20, 30, 40, 50])
     self.assertEqual(np.array_equal(computed, expected), True)
示例#2
0
 def test_get_value_05(self):
     dem = Grid(infolder + "/small25.tif")
     # Taking row, col as lists
     expected = np.nansum(self.zi.tolist())
     res =  dem.get_value(self.rows.tolist(), self.cols.tolist())
     computed = np.nansum(res)
     self.assertEqual(computed, expected)
示例#3
0
 def test_get_value_01(self):
     dem = Grid(infolder + "/small25.tif")
     # Taking row, col in a nan position (88)
     ind = 88
     row, col = self.rows[ind], self.cols[ind]
     computed = dem.get_value(row, col)
     self.assertEqual(computed, -9999)
示例#4
0
 def test_get_value_02(self):
     dem = Grid(infolder + "/small25.tif")
     # Taking row, col in other position (with value)
     ind = 25
     row, col = self.rows[ind], self.cols[ind]
     expected = self.zi[ind]
     computed = dem.get_value(row, col)
     self.assertEqual(computed, expected)
示例#5
0
 def test_values_2_nodata(self):
     dem = Grid()
     dem.set_array(np.arange(25).reshape((5, 5)))
     dem.set_nodata(-99.)
     dem.values_2_nodata([10, 11, 12, 13, 14])
     row, col = dem.ind_2_cell([10, 11, 12, 13, 14])
     computed = dem.get_value(row, col)
     expected = np.array([-99, -99, -99, -99, -99])
     res = np.array_equal(computed, expected)
     self.assertEqual(res, True)
示例#6
0
 def test_set_data_00(self):
     arr = np.arange(9).reshape((3, 3))
     arr[[1, 2], [2, 1]] = 8
     dem = Grid()
     dem.set_nodata(8)
     dem.set_array(arr)
     row, col = dem.get_nodata_pos()
     computed = dem.get_value(row, col)
     expected = np.array([8, 8, 8])
     self.assertEqual(np.array_equal(computed, expected), True)
示例#7
0
 def test_set_read_array_02(self):
     # Read array (Sharing memory)
     arr = np.arange(25).reshape(5,5).astype(np.int8)
     dem = Grid()
     dem.set_array(arr)
     out_arr = dem.read_array(False)
     out_arr[0, 0] = 99
     computed = dem.get_value(0, 0)
     expected = 99
     self.assertEqual(computed, expected)    
示例#8
0
 def test_get_value_04(self):
     dem = Grid(infolder + "/small25.tif")
     # Taking row, col as numpy arrays
     expected = self.zi
     computed = dem.get_value(self.rows, self.cols)
     self.assertEqual(np.nansum(computed),np.nansum(expected))