def test_interpolate_edge_case_2d(self):
     """Test that we fill in missing areas under a peaked edge case."""
     plugin = PhaseChangeLevel(phase_change="snow-sleet", grid_point_radius=1)
     result = plugin._horizontally_interpolate_phase(
         self.phase_change_data_2d, self.orography_2d, self.max_nbhood_orog_2d
     )
     self.assertArrayAlmostEqual(result, self.expected_result_2d)
 def test_interpolate_edge_case_2d_crater_grid_point_radius_2(self):
     """Test filling in missing areas under a radius 2 nan crater edge case."""
     plugin = PhaseChangeLevel(phase_change="snow-sleet", grid_point_radius=2)
     max_nbhood_orog = np.full(
         (9, 9), 900.0
     )  # Determined from the grid point radius increase.
     max_nbhood_orog[4, 4] = 600.0
     result = plugin._horizontally_interpolate_phase(
         self.phase_change_data_2d_crater, self.orography_2d_crater, max_nbhood_orog
     )
     self.assertArrayAlmostEqual(result, self.expected_result_2d_crater)
 def test_interpolate_edge_case_2d_nan_peak(self):
     """Test that we fill in missing areas under a nan-peaked edge case."""
     plugin = PhaseChangeLevel(phase_change="snow-sleet", grid_point_radius=1)
     phase_change_data = self.phase_change_data_2d.copy()
     phase_change_data[2][2] = np.nan  # Peak is also nan.
     result = plugin._horizontally_interpolate_phase(
         phase_change_data, self.orography_2d, self.max_nbhood_orog_2d
     )
     expected_result = self.expected_result_2d.copy()
     expected_result[2][2] = self.orography_2d[2][2]
     expected_result[2][3] = self.orography_2d[2][3]
     self.assertArrayAlmostEqual(result, expected_result)
    def test_interpolate_edge_case_2d_grid_point_radius_2(self):
        """Test filling in missing areas under a radius 2 peaked edge case.

        In this case, due to the higher max nbhood orog at the edges, we get
        successful interpolation using the edge points as valid points, with
        the orography at the nan point used as the limit.

        """
        plugin = PhaseChangeLevel(phase_change="snow-sleet", grid_point_radius=2)
        max_nbhood_orog = np.full(
            (5, 5), 850.0
        )  # Determined from the grid point radius increase.
        result = plugin._horizontally_interpolate_phase(
            self.phase_change_data_2d, self.orography_2d, max_nbhood_orog
        )
        expected_result = self.expected_result_2d.copy()
        expected_result[2][3] = self.orography_2d[2][
            3
        ]  # This uses the orography as the limit.
        self.assertArrayAlmostEqual(result, expected_result)