Beispiel #1
0
    def test_unit_conversion(self):
        """Test that the values for the source_points, target_points,
        source_weights, axis and fill_value are as expected when a unit
        conversion has been required."""
        config_dict = {
            "uk_det": {
                "forecast_period": [420, 720, 2880, 3240],
                "weights": [0, 1, 1, 0],
                "units": "minutes",
            }
        }

        plugin = ChooseWeightsLinear(self.weighting_coord_name, config_dict)

        (
            source_points,
            target_points,
            source_weights,
            fill_value,
        ) = plugin._get_interpolation_inputs_from_dict(self.cube)

        self.assertArrayAlmostEqual(source_points, self.expected_source_points)
        self.assertArrayAlmostEqual(target_points, self.expected_target_points)
        self.assertArrayAlmostEqual(source_weights,
                                    self.expected_source_weights)
        self.assertEqual(fill_value[0], self.expected_fill_value[0])
        self.assertEqual(fill_value[1], self.expected_fill_value[1])
Beispiel #2
0
    def test_basic(self):
        """Test that the values for the source_points, target_points,
        source_weights, axis and fill_value are as expected."""
        config_dict = CONFIG_DICT_UKV

        plugin = ChooseWeightsLinear(self.weighting_coord_name, config_dict)

        source_points, target_points, source_weights, fill_value = (
            plugin._get_interpolation_inputs_from_dict(self.cube))

        self.assertArrayAlmostEqual(source_points, self.expected_source_points)
        self.assertArrayAlmostEqual(target_points, self.expected_target_points)
        self.assertArrayAlmostEqual(source_weights,
                                    self.expected_source_weights)
        self.assertEqual(fill_value[0], self.expected_fill_value[0])
        self.assertEqual(fill_value[1], self.expected_fill_value[1])