Esempio n. 1
0
 def test_no_vertical(self, mock_set_long):
     grib = None
     cube = iris.cube.Cube([1, 2, 3, 4, 5])
     grib_save_rules.non_hybrid_surfaces(cube, grib)
     mock_set_long.assert_any_call(grib, "typeOfFirstFixedSurface", 1)
     mock_set_long.assert_any_call(grib, "scaleFactorOfFirstFixedSurface", 0)
     mock_set_long.assert_any_call(grib, "scaledValueOfFirstFixedSurface", 0)
     mock_set_long.assert_any_call(grib, "typeOfSecondFixedSurface", -1)
     mock_set_long.assert_any_call(grib, "scaleFactorOfSecondFixedSurface", 255)
     mock_set_long.assert_any_call(grib, "scaledValueOfSecondFixedSurface", -1)
Esempio n. 2
0
 def test_no_vertical(self, mock_set_long):
     grib = None
     cube = iris.cube.Cube([1,2,3,4,5])
     grib_save_rules.non_hybrid_surfaces(cube, grib)
     mock_set_long.assert_any_call(grib, "typeOfFirstFixedSurface", 1)
     mock_set_long.assert_any_call(grib, "scaleFactorOfFirstFixedSurface", 0)
     mock_set_long.assert_any_call(grib, "scaledValueOfFirstFixedSurface", 0)
     mock_set_long.assert_any_call(grib, "typeOfSecondFixedSurface", -1)
     mock_set_long.assert_any_call(grib, "scaleFactorOfSecondFixedSurface", 255)
     mock_set_long.assert_any_call(grib, "scaledValueOfSecondFixedSurface", -1)
Esempio n. 3
0
    def test_height_point(self, mock_set_long):
        grib = None
        cube = iris.cube.Cube([1, 2, 3, 4, 5])
        cube.add_aux_coord(iris.coords.AuxCoord([12345], "height", units="m"))

        grib_save_rules.non_hybrid_surfaces(cube, grib)

        mock_set_long.assert_any_call(grib, "typeOfFirstFixedSurface", 103)
        mock_set_long.assert_any_call(grib, "scaleFactorOfFirstFixedSurface", 0)
        mock_set_long.assert_any_call(grib, "scaledValueOfFirstFixedSurface", 12345)
        mock_set_long.assert_any_call(grib, "typeOfSecondFixedSurface", -1)
        mock_set_long.assert_any_call(grib, "scaleFactorOfSecondFixedSurface", 255)
        mock_set_long.assert_any_call(grib, "scaledValueOfSecondFixedSurface", -1)
 def test_bounded_altitude_feet(self):
     cube = iris.cube.Cube([0])
     cube.add_aux_coord(iris.coords.AuxCoord(
         1500.0, long_name='altitude', units='ft',
         bounds=np.array([1000.0, 2000.0])))
     grib = gribapi.grib_new_from_samples("GRIB2")
     grib_save_rules.non_hybrid_surfaces(cube, grib)
     self.assertEqual(
         gribapi.grib_get_double(grib, "scaledValueOfFirstFixedSurface"),
         304.0)
     self.assertEqual(
         gribapi.grib_get_double(grib, "scaledValueOfSecondFixedSurface"),
         609.0)
Esempio n. 5
0
    def test_height_point(self, mock_set_long):
        grib = None
        cube = iris.cube.Cube([1,2,3,4,5])
        cube.add_aux_coord(iris.coords.AuxCoord([12345], "height", units="m"))

        grib_save_rules.non_hybrid_surfaces(cube, grib)

        mock_set_long.assert_any_call(grib, "typeOfFirstFixedSurface", 103)
        mock_set_long.assert_any_call(grib, "scaleFactorOfFirstFixedSurface", 0)
        mock_set_long.assert_any_call(grib, "scaledValueOfFirstFixedSurface", 12345)
        mock_set_long.assert_any_call(grib, "typeOfSecondFixedSurface", -1)
        mock_set_long.assert_any_call(grib, "scaleFactorOfSecondFixedSurface", 255)
        mock_set_long.assert_any_call(grib, "scaledValueOfSecondFixedSurface", -1)
Esempio n. 6
0
 def test_bounded_altitude_feet(self):
     cube = iris.cube.Cube([0])
     cube.add_aux_coord(
         iris.coords.AuxCoord(1500.0,
                              long_name='altitude',
                              units='ft',
                              bounds=np.array([1000.0, 2000.0])))
     grib = gribapi.grib_new_from_samples("GRIB2")
     grib_save_rules.non_hybrid_surfaces(cube, grib)
     self.assertEqual(
         gribapi.grib_get_double(grib, "scaledValueOfFirstFixedSurface"),
         304.0)
     self.assertEqual(
         gribapi.grib_get_double(grib, "scaledValueOfSecondFixedSurface"),
         609.0)