Exemplo 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.assertRaisesRegexp(ValueError, msg):
         plugin.extract_percentile_data(self.cube_wg, 20.0,
                                        "wind_speed_of_gust")
Exemplo 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:s}.'.format(type(self.wg_perc)))
     with self.assertRaisesRegexp(TypeError, msg):
         plugin.extract_percentile_data(self.wg_perc, self.wg_perc,
                                        "wind_speed_of_gust")
Exemplo n.º 3
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)
Exemplo n.º 4
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_over_nbhood")
     self.assertEqual(
         result.coord("percentile_over_nbhood").points, [self.wg_perc])
 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)