Exemplo n.º 1
0
 def test_multiple_methods(self):
     """Test a list of methods returns the expected string"""
     input1 = iris.coords.CellMethod("max", coords="time")
     input2 = iris.coords.CellMethod("min",
                                     coords=("latitude", "longitude"))
     for method in [input1, input2]:
         self.cube.add_cell_method(method)
     format_cell_methods_for_probability(self.cube, "air_temperature")
     for method in self.cube.cell_methods:
         self.assertEqual(method.comments, ("of air_temperature", ))
Exemplo n.º 2
0
 def test_one_method(self):
     """Test when the input cube has one cell method"""
     input = iris.coords.CellMethod("max",
                                    coords="time",
                                    intervals="1 hour")
     self.cube.add_cell_method(input)
     format_cell_methods_for_probability(self.cube, "air_temperature")
     result = self.cube.cell_methods[0]
     self.assertEqual(result.method, input.method)
     self.assertEqual(result.coord_names, input.coord_names)
     self.assertEqual(result.intervals, input.intervals)
     self.assertEqual(result.comments, ("of air_temperature", ))
Exemplo n.º 3
0
    def _update_metadata(self, cube: Cube) -> None:
        """Rename the cube and add attributes to the threshold coordinate
        after merging
        """
        threshold_coord = cube.coord(self.threshold_coord_name)
        threshold_coord.attributes.update(
            {"spp__relative_to_threshold": self.comparison_operator.spp_string}
        )
        if cube.cell_methods:
            format_cell_methods_for_probability(cube, self.threshold_coord_name)

        cube.rename(
            "probability_of_{parameter}_{relative_to}_threshold".format(
                parameter=self.threshold_coord_name,
                relative_to=probability_is_above_or_below(cube),
            )
        )
        cube.units = Unit(1)