def test_unit_conversion(self):
        """Tests that input cubes have the same units at the end of the
        function as they do at input"""

        self.temperature_cube.convert_units('fahrenheit')
        self.wind_speed_cube.convert_units('knots')

        calculate_wind_chill(self.temperature_cube, self.wind_speed_cube)

        temp_units = self.temperature_cube.units
        wind_speed_units = self.wind_speed_cube.units

        self.assertEqual(temp_units, 'fahrenheit')
        self.assertEqual(wind_speed_units, 'knots')
 def test_name_and_units(self):
     """Test correct outputs for name and units."""
     expected_name = "wind_chill"
     expected_units = 'K'
     result = calculate_wind_chill(self.temperature_cube,
                                   self.wind_speed_cube)
     self.assertEqual(result.name(), expected_name)
     self.assertEqual(result.units, expected_units)
    def test_wind_chill_values(self):
        """Test output values when from the wind chill equation."""

        # use a temperature less than 10 degrees C.
        self.temperature_cube.data = np.full((1, 3), 274.85)
        self.wind_speed_cube.data = np.full((1, 3), 3)
        expected_result = np.full((1, 3), 271.674652, dtype=np.float32)
        result = calculate_wind_chill(self.temperature_cube,
                                      self.wind_speed_cube)
        self.assertArrayAlmostEqual(result.data, expected_result)
    def test_different_units(self):
        """Test that values are correct from input cubes with
        different units"""

        self.temperature_cube.convert_units('fahrenheit')
        self.wind_speed_cube.convert_units('knots')

        data = np.array([[257.05949633, 220.76791229, 231.12778024]])
        # convert to fahrenheit
        expected_result = (data * (9.0 / 5.0) - 459.67).astype(np.float32)
        result = calculate_wind_chill(self.temperature_cube,
                                      self.wind_speed_cube)
        self.assertArrayAlmostEqual(result.data, expected_result)