示例#1
0
 def test_vicinity_names(self):
     """Test plugin names the cube and threshold coordinate correctly for a
     vicinity diagnostic"""
     input = "lwe_thickness_of_precipitation_amount_in_vicinity"
     output = "thickness_of_rainfall_amount_in_vicinity"
     self.cube.rename(f"probability_of_{input}_above_threshold")
     cubelist = iris.cube.CubeList([self.cube.copy(), self.multiplier])
     result = CubeMultiplier(broadcast_to_threshold=True)(cubelist, output)
     self.assertEqual(result.name(),
                      f"probability_of_{output}_above_threshold")
     self.assertEqual(
         result.coord(var_name="threshold").name(),
         "thickness_of_rainfall_amount")
示例#2
0
 def test_vicinity_names(self):
     """Test plugin names the cube and threshold coordinate correctly for a
     vicinity diagnostic"""
     input = "lwe_thickness_of_precipitation_amount_in_vicinity"
     output = "thickness_of_rainfall_amount_in_vicinity"
     self.cube4.rename(f"probability_of_{input}_above_threshold")
     cube = self.cube4[:, 0, ...].copy()
     cube.data = np.ones_like(cube.data)
     cube.remove_coord("lwe_thickness_of_precipitation_amount")
     cubelist = iris.cube.CubeList([self.cube4.copy(), cube])
     input_copy = deepcopy(cubelist)
     result = CubeMultiplier()(cubelist, output, broadcast_to_threshold=True)
     self.assertEqual(result.name(), f"probability_of_{output}_above_threshold")
     self.assertEqual(
         result.coord(var_name="threshold").name(), "thickness_of_rainfall_amount"
     )
示例#3
0
 def test_broadcast_coord(self):
     """Test that plugin broadcasts to threshold coord without changing inputs.
     Using the broadcast_to_coords argument including a value of "threshold"
     will result in the returned cube maintaining the probabilistic elements
     of the name of the first input cube."""
     cubelist = iris.cube.CubeList([self.cube.copy(), self.multiplier])
     input_copy = deepcopy(cubelist)
     result = CubeMultiplier(broadcast_to_threshold=True)(cubelist,
                                                          "new_cube_name")
     self.assertIsInstance(result, Cube)
     self.assertEqual(result.name(),
                      "probability_of_new_cube_name_above_threshold")
     self.assertEqual(
         result.coord(var_name="threshold").name(), "new_cube_name")
     self.assertArrayAlmostEqual(result.data, self.cube.data)
     self.assertCubeListEqual(input_copy, cubelist)
示例#4
0
 def test_broadcast_coord(self):
     """Test that plugin broadcasts to threshold coord without changing inputs.
     Using the broadcast_to_coords argument including a value of "threshold"
     will result in the returned cube maintaining the probabilistic elements
     of the name of the first input cube."""
     cube = self.cube4[:, 0, ...].copy()
     cube.data = np.ones_like(cube.data)
     cube.remove_coord("lwe_thickness_of_precipitation_amount")
     cubelist = iris.cube.CubeList([self.cube4.copy(), cube])
     input_copy = deepcopy(cubelist)
     result = CubeMultiplier()(
         cubelist, "new_cube_name", broadcast_to_threshold=True
     )
     self.assertIsInstance(result, Cube)
     self.assertEqual(result.name(), "probability_of_new_cube_name_above_threshold")
     self.assertEqual(result.coord(var_name="threshold").name(), "new_cube_name")
     self.assertArrayAlmostEqual(result.data, self.cube4.data)
     self.assertCubeListEqual(input_copy, cubelist)