def test_no_percentile_coord(self):
     """
     Check that requesting the desired percentile coordinate results in an
     exception.
     """
     cube = self.current_temperature_cube
     cube.coord("percentile_over_realization").rename("realization")
     plugin = Plugin()
     msg = "The percentile coordinate could not be found"
     with self.assertRaisesRegexp(CoordinateNotFoundError, msg):
         plugin.process(cube)
Example #2
0
 def test_basic(self):
     """
     Test that a cube is produced is produced and the realization
     coordinate is a dimension coordinate, after the percentile coordinate
     is rebadged.
     """
     cube = self.current_temperature_cube
     plugin = Plugin()
     result = plugin.process(cube)
     self.assertIsInstance(result, Cube)
     self.assertIsInstance(result.coord("realization"), DimCoord)
Example #3
0
 def test_still_works_if_percentile_coord_is_different(self):
     """Check this still works if a different percentile coord used"""
     cube = self.current_temperature_cube
     cube.coord("percentile_over_realization").rename(
         "percentile_over_nbhood")
     plen = len(cube.coord("percentile_over_nbhood").points)
     plugin = Plugin()
     result = plugin.process(cube)
     self.assertEqual(len(result.coord("realization").points), plen)
     self.assertArrayAlmostEqual(
         result.coord("realization").points, np.array([0, 1, 2]))
Example #4
0
 def test_number_of_members(self):
     """
     Check the values for the realization coordinate generated without
     specifying the ensemble_member_numbers argument.
     """
     cube = self.current_temperature_cube
     plen = len(cube.coord("percentile_over_realization").points)
     plugin = Plugin()
     result = plugin.process(cube)
     self.assertEqual(len(result.coord("realization").points), plen)
     self.assertArrayAlmostEqual(
         result.coord("realization").points, np.array([0, 1, 2]))
Example #5
0
 def test_specify_member_numbers(self):
     """
     Use the ensemble_member_numbers optional argument to specify particular
     values for the ensemble member numbers.
     """
     cube = self.current_temperature_cube
     plen = len(cube.coord("percentile_over_realization").points)
     ensemble_member_numbers = np.arange(plen) + 12
     plugin = Plugin()
     result = plugin.process(cube, ensemble_member_numbers)
     self.assertEqual(len(result.coord("realization").points), plen)
     self.assertArrayAlmostEqual(
         result.coord("realization").points, np.array([12, 13, 14]))