Beispiel #1
0
             "sffraction3h:SFFraction:sffraction tpdec3h_2021_1_10_0_0_0+3.grib,snowdec3h_2021_1_10_0_0_0+3.grib"
             " sffraction3h_2021_1_10_0_0_0+3.grib"] +

            # Snow preprocessing
            self.get_snow_preprocessing_log() +

            # Snow decumulation
            ["snowdec3h:Decumulate:vg6d_transform --comp-frac-valid=0 '--comp-step=0 03'"
             " --comp-stat-proc=1 --comp-full-steps - snowdec3h-decumulated.grib"]
        )

        self.assertRenders(orders[0], step=3)

        self.assertMgribArgsEqual(
                orders[0], cosmo={'grib_automatic_scaling': False}, ifs={'grib_automatic_scaling': False})

    def get_snow_preprocessing_log(self) -> List[str]:
        if self.model_name == "ifs":
            return [f"snow:Or:ifs_sf_2021_1_10_0_0_0+{step}.grib as snow_2021_1_10_0_0_0+{step}.grib"
                    for step in range(3, 13, 3)]
        else:
            return (
                ["snowsum:VG6DTransform:vg6d_transform --output-variable-list=B13205 -"
                 f" snowsum_2021_1_10_0_0_0+{step}.grib" for step in range(0, 13)] +
                [f"snow:Or:snowsum_2021_1_10_0_0_0+{step}.grib as snow_2021_1_10_0_0_0+{step}.grib"
                 for step in range(0, 13)]
            )


add_recipe_test_cases(__name__, "tiles/sffraction3h")
Beispiel #2
0
class RHW700Mixin:
    def test_dispatch(self):
        self.maxDiff = None

        pantry_reftime = "2021_1_10_0_0_0"
        self.fill_pantry(expected=[
            f'{self.model_name}_q700_{pantry_reftime}+12.grib',
            f'{self.model_name}_t700_{pantry_reftime}+12.grib'
        ])

        orders = self.make_orders()
        self.assertEqual(len(orders), 1)

        self.assertProcessLogEqual([
            f'uv700:Cat:cat {self.model_name}_u700_2021_1_10_0_0_0+12.grib,'
            f'{self.model_name}_v700_2021_1_10_0_0_0+12.grib'
            ' uv700_2021_1_10_0_0_0+12.grib',
            'p700:VG6DTransform:vg6d_transform --comp-var-from-lev --trans-level-type=100 -'
            ' p700_2021_1_10_0_0_0+12.grib',
            'rh700:VG6DTransform:vg6d_transform --output-variable-list=B13003 -'
            ' rh700_2021_1_10_0_0_0+12.grib',
        ])

        self.assertRenders(orders[0])

        self.assertMgribArgsEqual(orders[0], cosmo={}, ifs={})


add_recipe_test_cases(__name__, "standalone/rhw700")
Beispiel #3
0
# from __future__ import annotations
from arkimapslib.unittest import add_recipe_test_cases


class T2MAVGMixin:
    def test_dispatch(self):
        self.fill_pantry()

        orders = self.make_orders()
        self.assertEqual(len(orders), 1)

        self.assertProcessLogEqual([
            "t2mavg:Average:vg6d_transform --comp-frac-valid=0 '--comp-step=0 24'"
            " --comp-stat-proc=254:0 - t2mavg-decumulated.grib",
        ])

        self.assertRenders(orders[0], step=24)

        self.assertMgribArgsEqual(orders[0],
                                  cosmo={
                                      'grib_automatic_scaling': False,
                                      'grib_scaling_offset': -273.15,
                                  },
                                  ifs={
                                      'grib_automatic_scaling': False,
                                      'grib_scaling_offset': -273.15,
                                  })


add_recipe_test_cases(__name__, "t2mavg")
Beispiel #4
0
# from __future__ import annotations
from arkimapslib.unittest import add_recipe_test_cases


class TCCMixin:
    def test_dispatch(self):
        self.fill_pantry()

        orders = self.make_orders()
        self.assertEqual(len(orders), 1)

        self.assertRenders(orders[0])

        self.assertMgribArgsEqual(
            orders[0],
            cosmo={
                'grib_automatic_scaling': False,
                'grib_scaling_factor': 0.08
            },
            ifs={
                'grib_automatic_scaling': False,
                'grib_scaling_factor': 8
            },
        )


add_recipe_test_cases(__name__, "tcc")
Beispiel #5
0
# from __future__ import annotations
from arkimapslib.unittest import add_recipe_test_cases


class LCCMixin:
    def test_dispatch(self):
        self.fill_pantry()

        orders = self.make_orders()
        self.assertEqual(len(orders), 1)

        self.assertRenders(orders[0])

        self.assertMgribArgsEqual(
            orders[0],
            cosmo={
                'grib_automatic_scaling': False,
                'grib_scaling_factor': 0.08
            },
            ifs={
                'grib_automatic_scaling': False,
                'grib_scaling_factor': 8
            },
        )


add_recipe_test_cases(__name__, "tiles/lcc")
Beispiel #6
0
        litota3 = self.kitchen.pantry.inputs.get("litota3")
        for i in litota3:
            self.assertEqual(i.__class__.__name__, "Source")
        sottozone_allerta_er = self.kitchen.pantry.inputs.get(
            "sottozoneAllertaER")
        for i in sottozone_allerta_er:
            self.assertEqual(i.__class__.__name__, "Shape")
        punti_citta = self.kitchen.pantry.inputs.get("puntiCitta")
        for i in punti_citta:
            self.assertEqual(i.__class__.__name__, "Static")

        orders = self.make_orders()
        self.assertEqual(len(orders), 1)

        input_files = orders[0].input_files
        self.assertEqual(os.path.basename(input_files["litota3"].pathname),
                         "litota3_2021_3_4_0_0_0+12.grib")
        self.assertEqual(
            os.path.basename(input_files["sottozoneAllertaER"].pathname),
            "Sottozone_allerta_ER")
        self.assertEqual(os.path.basename(input_files["puntiCitta"].pathname),
                         "puntiCitta.geo")

        self.assertRenders(orders[0], reftime=datetime.datetime(2021, 3, 4))

        self.assertMgribArgsEqual(orders[0], cosmo={}, ifs={})


add_recipe_test_cases(__name__, "litota3")
add_recipe_test_cases(__name__, "litota3", test_mixin=LITOTA3NordMixin)
Beispiel #7
0
# from __future__ import annotations
from arkimapslib.unittest import add_recipe_test_cases


class WFLAGS10MMixin:
    def test_dispatch(self):
        self.fill_pantry()

        orders = self.make_orders()
        self.assertEqual(len(orders), 1)

        self.assertRenders(orders[0])

        self.assertMgribArgsEqual(orders[0], cosmo={}, ifs={})


add_recipe_test_cases(__name__, "tiles/wflags10m")
Beispiel #8
0
        # that test
        if self.model_name == "ifs":
            raise unittest.SkipTest("tp1h tests for IFS skipped, see code for reason")

        pantry_reftime = "2021_1_10_0_0_0"
        self.fill_pantry(expected=[f"{self.model_name}_tp_{pantry_reftime}+{step}.grib" for step in range(0, 13)])

        # Check that the right input was selected
        tpdec1h = self.kitchen.pantry.inputs.get("tpdec1h")
        for i in tpdec1h:
            self.assertEqual(i.__class__.__name__, "Decumulate")

        orders = self.make_orders()
        # Preprocessing means we cannot reduce test input to only get one
        # order, so we get orders from every step from 0 to 12. We filter
        # later to keep only +12h to test
        if self.model_name == "ifs":
            self.assertEqual(len(orders), 0)
            return
        else:
            self.assertGreaterEqual(len(orders), 12)
        orders = [o for o in orders if o.basename == "tp1h+012"]
        self.assertEqual(len(orders), 1)

        self.assertRenders(orders[0])

        self.assertMgribArgsEqual(orders[0], cosmo={}, ifs={})


add_recipe_test_cases(__name__, "tiles/tp1h")
Beispiel #9
0
# from __future__ import annotations
from arkimapslib.unittest import add_recipe_test_cases


class CP3HMixin:
    def test_dispatch(self):
        pantry_reftime = "2021_1_10_0_0_0"
        self.fill_pantry(expected=[f"{self.model_name}_cp_{pantry_reftime}+{step}.grib" for step in range(3, 13, 3)])

        # Check that the right input was selected
        cpdec3h = self.kitchen.pantry.inputs.get("cpdec3h")
        for i in cpdec3h:
            self.assertEqual(i.__class__.__name__, "Decumulate")

        orders = self.make_orders()
        self.assertGreaterEqual(len(orders), 4)
        orders = [o for o in orders if o.basename == "cp3h+012"]
        self.assertEqual(len(orders), 1)

        self.assertRenders(orders[0])

        self.assertMgribArgsEqual(orders[0], cosmo={}, ifs={})


add_recipe_test_cases(__name__, "cp3h")
Beispiel #10
0
# from __future__ import annotations
from arkimapslib.unittest import add_recipe_test_cases


class MSLPMixin:
    def test_dispatch(self):
        self.fill_pantry()

        orders = self.make_orders()
        self.assertEqual(len(orders), 1)

        self.assertRenders(orders[0])

        self.assertMgribArgsEqual(
            orders[0],
            cosmo={
                'grib_automatic_scaling': False,
                'grib_scaling_factor': 0.01
            },
            ifs={
                'grib_automatic_scaling': False,
                'grib_scaling_factor': 0.01
            },
        )


add_recipe_test_cases(__name__, "mslp")
Beispiel #11
0
        ])

        self.assertRenders(orders[0])

        self.assertMgribArgsEqual(orders[0], cosmo={}, ifs={})


class RH2MERG5Mixin:
    def test_dispatch(self):
        self.fill_pantry(step=0)

        # Check that the right input was selected
        cpdec3h = self.kitchen.pantry.inputs.get("rh2m")
        for i in cpdec3h:
            if i.model == "erg5":
                self.assertEqual(i.__class__.__name__, "Source")
            else:
                self.assertEqual(i.__class__.__name__, "VG6DTransform")

        orders = self.make_orders()
        self.assertEqual(len(orders), 1)

        self.assertEqual(self.kitchen.pantry.process_log, [])

        self.assertRenders(orders[0], step=0)

        self.assertMgribArgsEqual(orders[0], erg5={})


add_recipe_test_cases(__name__, "rh2m", models=("IFS", "Cosmo", "ERG5"))
Beispiel #12
0
        self.maxDiff = None
        pantry_reftime = "2021_1_10_0_0_0"
        self.fill_pantry(expected=[
            f"{self.model_name}_sf_{pantry_reftime}+{step}.grib"
            for step in range(3, 13, 3)
        ])

        orders = self.make_orders()
        self.assertGreaterEqual(len(orders), 4)
        orders = [o for o in orders if o.basename == "sf3h+012"]
        self.assertEqual(len(orders), 1)

        self.assertProcessLogEqual([
            f"snow:Or:ifs_sf_2021_1_10_0_0_0+{step}.grib as snow_2021_1_10_0_0_0+{step}.grib"
            for step in range(3, 13, 3)
        ] + [
            "snowdec3h:Decumulate:vg6d_transform --comp-frac-valid=0 '--comp-step=0 03'"
            " --comp-stat-proc=1 --comp-full-steps - snowdec3h-decumulated.grib"
        ])

        self.assertRenders(orders[0])

        self.assertMgribArgsEqual(orders[0], cosmo={}, ifs={})


add_recipe_test_cases(__name__, "sf3h")
add_recipe_test_cases(__name__,
                      "sf3h",
                      models=["Cosmo"],
                      test_mixin=SF3HNoConvMixin)