コード例 #1
0
 def test_raises_error_points_mismatch_and_no_bounds(self):
     """Test raises Value Error if points mismatch and no bounds """
     cube_wg = self.cube_wg
     cube_wg.coord('time').points = [402192.5, 402194.5]
     plugin = WindGustDiagnostic(self.wg_perc, self.ws_perc)
     msg = ('Could not match time coordinate')
     with self.assertRaisesRegexp(ValueError, msg):
         plugin.process(cube_wg, self.cube_ws)
コード例 #2
0
 def test_raises_error_points_mismatch_and_invalid_bounds(self):
     """Test raises Value Error if points mismatch and bounds are invalid"""
     cube_wg = self.cube_wg
     cube_wg.coord('time').points = [402192.0, 402193.0]
     cube_wg.coord('time').bounds = [[402191.5], [402193.5]]
     plugin = WindGustDiagnostic(self.wg_perc, self.ws_perc)
     msg = ('Could not match time coordinate')
     with self.assertRaisesRegex(ValueError, msg):
         plugin.process(cube_wg, self.cube_ws)
コード例 #3
0
 def test_raises_error_for_no_time_coord(self):
     """Test raises Value Error if cubes have no time coordinate """
     cube_wg = self.cube_wg[:, 0, ::]
     cube_ws = self.cube_ws[:, 0, ::]
     cube_wg.remove_coord('time')
     cube_wg = iris.util.squeeze(cube_wg)
     plugin = WindGustDiagnostic(self.wg_perc, self.ws_perc)
     msg = ('Could not match time coordinate')
     with self.assertRaisesRegexp(ValueError, msg):
         plugin.process(cube_wg, cube_ws)
コード例 #4
0
 def test_raises_error_for_mismatching_perc_coords(self):
     """Test raises an error for mismatching perc coords. """
     plugin = WindGustDiagnostic(self.wg_perc, self.ws_perc)
     data_wg = np.zeros((1, 2, 2, 2))
     data_wg[0, 0, :, :] = 3.0
     data_wg[0, 1, :, :] = 1.5
     gust = "wind_speed_of_gust"
     cube_wg = (create_cube_with_percentile_coord(
         data=data_wg,
         perc_values=[self.wg_perc],
         standard_name=gust,
         perc_name='percentile_dummy'))
     msg = ('Percentile coord of wind-gust data'
            'does not match coord of wind-speed data')
     with self.assertRaisesRegexp(ValueError, msg):
         plugin.process(cube_wg, self.cube_ws)
コード例 #5
0
 def test_returns_wind_gust_diagnostic(self):
     """Test that the plugin returns a Cube. """
     plugin = WindGustDiagnostic(self.wg_perc, self.ws_perc)
     result = plugin.process(self.cube_wg, self.cube_ws)
     expected_data = np.zeros((2, 2, 2))
     expected_data[0, :, :] = 3.0
     expected_data[1, :, :] = 2.0
     self.assertArrayAlmostEqual(result.data, expected_data)
     self.assertEqual(result.attributes['wind_gust_diagnostic'],
                      'Typical gusts')
コード例 #6
0
    def test_no_raises_error_if_ws_point_in_bounds(self):
        """Test raises no Value Error if wind-speed point in bounds """
        cube_wg = self.cube_wg
        cube_wg.coord('time').points = [402192.0, 402193.0]
        cube_wg.coord('time').bounds = [[402191.5, 402192.5],
                                        [402192.5, 402193.5]]

        plugin = WindGustDiagnostic(self.wg_perc, self.ws_perc)
        result = plugin.process(cube_wg, self.cube_ws)
        self.assertIsInstance(result, Cube)
コード例 #7
0
 def test_basic(self):
     """Test that the plugin returns a Cube. """
     plugin = WindGustDiagnostic(self.wg_perc, self.ws_perc)
     result = plugin.process(self.cube_wg, self.cube_ws)
     self.assertIsInstance(result, Cube)