Esempio n. 1
0
 def test_fails_if_req_percentile_not_in_cube(self):
     """Test it raises a Value Error if req_perc not in cube."""
     plugin = WindGustDiagnostic(self.wg_perc, self.ws_perc)
     msg = ('Could not find required percentile')
     with self.assertRaisesRegex(ValueError, msg):
         plugin.extract_percentile_data(self.cube_wg, 20.0,
                                        "wind_speed_of_gust")
Esempio n. 2
0
 def test_fails_if_data_is_not_cube(self):
     """Test it raises a Type Error if cube is not a cube."""
     plugin = WindGustDiagnostic(self.wg_perc, self.ws_perc)
     msg = ('Expecting wind_speed_of_gust data to be an instance of '
            'iris.cube.Cube but is'
            ' {0}.'.format(type(self.wg_perc)))
     with self.assertRaisesRegex(TypeError, msg):
         plugin.extract_percentile_data(self.wg_perc, self.wg_perc,
                                        "wind_speed_of_gust")
Esempio n. 3
0
 def test_returns_correct_cube_and_coord(self):
     """Test it returns the correct Cube and Coord."""
     plugin = WindGustDiagnostic(self.wg_perc, self.ws_perc)
     result, perc_coord = (plugin.extract_percentile_data(
         self.cube_wg, self.wg_perc, "wind_speed_of_gust"))
     self.assertEqual(perc_coord.name(), "percentile")
     self.assertEqual(result.coord("percentile").points, [self.wg_perc])
Esempio n. 4
0
 def test_basic(self):
     """Test that the function returns a Cube and Coord."""
     plugin = WindGustDiagnostic(self.wg_perc, self.ws_perc)
     result, perc_coord = (plugin.extract_percentile_data(
         self.cube_wg, self.wg_perc, "wind_speed_of_gust"))
     self.assertIsInstance(result, Cube)
     self.assertIsInstance(perc_coord, iris.coords.Coord)
Esempio n. 5
0
 def test_warning_if_standard_names_do_not_match(self, warning_list=None):
     """Test it raises a warning if standard names do not match."""
     plugin = WindGustDiagnostic(self.wg_perc, self.ws_perc)
     warning_msg = ('Warning mismatching name for data expecting')
     result, perc_coord = (plugin.extract_percentile_data(
         self.cube_wg, self.wg_perc, "wind_speed"))
     self.assertTrue(
         any(item.category == UserWarning for item in warning_list))
     self.assertTrue(any(warning_msg in str(item) for item in warning_list))
     self.assertIsInstance(result, Cube)
     self.assertIsInstance(perc_coord, iris.coords.Coord)