def test_land_average(self): """check land average is correct when all neighbours contain missing data.""" data = np.array([[1, -999, 1], [-999, -999, -999], [1, -999, 1]]) pixel_loc = np.array([1, 1]) neighbours = { 'left_nbor': np.array([0, 1]), 'right_nbor': np.array([2, 1]), 'up_nbor': np.array([1, 0]), 'down_nbor': np.array([1, 1]) } expected_average = 1 average = pixel_average(pixel_loc, neighbours, data) self.assertEqual(expected_average, average)
def test_partial_pixel_average(self): """check neighbourhood average is correct when some neighbours contain missing data.""" data = np.array([[3, 4, 5], [4, -999, -999], [2, -999, 5]]) pixel_loc = np.array([1, 1]) neighbours = { 'left_nbor': np.array([0, 1]), 'right_nbor': np.array([2, 1]), 'up_nbor': np.array([1, 0]), 'down_nbor': np.array([1, 1]) } expected_average = 4 average = pixel_average(pixel_loc, neighbours, data) self.assertEqual(expected_average, average)
def test_complete_pixel_average(self): """check neighbourhood average is correct when no neighbours contain missing data.""" data = np.array([[3, 4, 5], [4, -999, 6], [2, 8, 5]]) pixel_loc = np.array([1, 1]) neighbours = { 'left_nbor': np.array([0, 1]), 'right_nbor': np.array([2, 1]), 'up_nbor': np.array([1, 0]), 'down_nbor': np.array([1, 1]) } expected_average = int(5.5) # All values must be integers average = pixel_average(pixel_loc, neighbours, data) self.assertEqual(expected_average, average)
def test_land_average(self): """check land average is correct when all neighbours contain missing data.""" data = np.array([[1,-999,1], [-999,-999,-999], [1,-999,1]]) pixel_loc = np.array([1,1]) neighbours = { 'left_nbor': np.array([0, 1]), 'right_nbor': np.array([2, 1]), 'up_nbor': np.array([1, 0]), 'down_nbor': np.array([1, 1]) } expected_average = 1 average = pixel_average(pixel_loc, neighbours, data) self.assertEqual(expected_average, average)
def test_partial_pixel_average(self): """check neighbourhood average is correct when some neighbours contain missing data.""" data = np.array([[3,4,5], [4,-999,-999], [2,-999,5]]) pixel_loc = np.array([1,1]) neighbours = { 'left_nbor': np.array([0, 1]), 'right_nbor': np.array([2, 1]), 'up_nbor': np.array([1, 0]), 'down_nbor': np.array([1, 1]) } expected_average = 4 average = pixel_average(pixel_loc, neighbours, data) self.assertEqual(expected_average, average)
def test_complete_pixel_average(self): """check neighbourhood average is correct when no neighbours contain missing data.""" data = np.array([[3,4,5], [4,-999,6], [2,8,5]]) pixel_loc = np.array([1,1]) neighbours = { 'left_nbor': np.array([0, 1]), 'right_nbor': np.array([2, 1]), 'up_nbor': np.array([1, 0]), 'down_nbor': np.array([1, 1]) } expected_average = int(5.5) # All values must be integers average = pixel_average(pixel_loc, neighbours, data) self.assertEqual(expected_average, average)