def test_load_probability_forecast(self):
        # Test GribWrapper interpretation of PDT 4.9 data.
        # NOTE:
        #   Currently Iris has only partial support for PDT 4.9.
        #   Though it can load the data, key metadata (thresholds) is lost.
        #   At present, we are not testing for this.

        # Make a testing grib message in memory, with gribapi.
        grib_message = gribapi.grib_new_from_samples('GRIB2')
        gribapi.grib_set_long(grib_message, 'productDefinitionTemplateNumber',
                              9)
        gribapi.grib_set_string(grib_message, 'stepRange', '10-55')
        grib_wrapper = iris.fileformats.grib.GribWrapper(grib_message)

        # Define two expected datetimes for _periodEndDateTime as
        # gribapi v1.9.16 mis-calculates this.
        # See https://software.ecmwf.int/wiki/display/GRIB/\
        #     GRIB+API+version+1.9.18+released
        try:
            # gribapi v1.9.16 has no __version__ attribute.
            gribapi_ver = gribapi.__version__
        except AttributeError:
            gribapi_ver = gribapi.grib_get_api_version()

        if StrictVersion(gribapi_ver) < StrictVersion('1.9.18'):
            exp_end_date = datetime.datetime(year=2007,
                                             month=3,
                                             day=25,
                                             hour=12,
                                             minute=0,
                                             second=0)
        else:
            exp_end_date = datetime.datetime(year=2007,
                                             month=3,
                                             day=25,
                                             hour=19,
                                             minute=0,
                                             second=0)

        # Check that it captures the statistics time period info.
        # (And for now, nothing else)
        self.assertEqual(
            grib_wrapper._referenceDateTime,
            datetime.datetime(year=2007,
                              month=3,
                              day=23,
                              hour=12,
                              minute=0,
                              second=0))
        self.assertEqual(
            grib_wrapper._periodStartDateTime,
            datetime.datetime(year=2007,
                              month=3,
                              day=23,
                              hour=22,
                              minute=0,
                              second=0))
        self.assertEqual(grib_wrapper._periodEndDateTime, exp_end_date)
Beispiel #2
0
    def test_load_probability_forecast(self):
        # Test GribWrapper interpretation of PDT 4.9 data.
        # NOTE:
        #   Currently iris-grib has only partial support for PDT 4.9.
        #   Though it can load the data, key metadata (thresholds) is lost.
        #   At present, we are not testing for this.

        # Make a testing grib message in memory, with gribapi.
        grib_message = gribapi.grib_new_from_samples('GRIB2')
        gribapi.grib_set_long(grib_message, 'productDefinitionTemplateNumber',
                              9)
        gribapi.grib_set_string(grib_message, 'stepRange', '10-55')
        grib_wrapper = iris.fileformats.grib.GribWrapper(grib_message)

        # Define two expected datetimes for _periodEndDateTime as
        # gribapi v1.9.16 mis-calculates this.
        # See https://software.ecmwf.int/wiki/display/GRIB/\
        #     GRIB+API+version+1.9.18+released
        try:
            # gribapi v1.9.16 has no __version__ attribute.
            gribapi_ver = gribapi.__version__
        except AttributeError:
            gribapi_ver = gribapi.grib_get_api_version()

        if StrictVersion(gribapi_ver) < StrictVersion('1.9.18'):
            exp_end_date = datetime.datetime(year=2007, month=3, day=25,
                                             hour=12, minute=0, second=0)
        else:
            exp_end_date = datetime.datetime(year=2007, month=3, day=25,
                                             hour=19, minute=0, second=0)

        # Check that it captures the statistics time period info.
        # (And for now, nothing else)
        self.assertEqual(
            grib_wrapper._referenceDateTime,
            datetime.datetime(year=2007, month=3, day=23,
                              hour=12, minute=0, second=0)
        )
        self.assertEqual(
            grib_wrapper._periodStartDateTime,
            datetime.datetime(year=2007, month=3, day=23,
                              hour=22, minute=0, second=0)
        )
        self.assertEqual(grib_wrapper._periodEndDateTime, exp_end_date)
Beispiel #3
0
    def test_load_probability_forecast(self):
        # Test GribWrapper interpretation of PDT 4.9 data.
        # NOTE: 
        #   Currently Iris has only partial support for PDT 4.9.
        #   Though it can load the data, key metadata (thresholds) is lost.
        #   At present, we are not testing for this.

        # Make a testing grib message in memory, with gribapi.
        grib_message = gribapi.grib_new_from_samples('GRIB2')
        gribapi.grib_set_long(grib_message, 'productDefinitionTemplateNumber', 9)
        gribapi.grib_set_string(grib_message, 'stepRange', '10-55')
        grib_wrapper = iris.fileformats.grib.GribWrapper(grib_message)
        
        # Check that it captures the statistics time period info.
        # (And for now, nothing else)
        self.assertEqual(
            grib_wrapper._referenceDateTime,
            datetime.datetime(year=2007, month=03, day=23, 
                              hour=12, minute=0, second=0)
        )
Beispiel #4
0
    def test_load_probability_forecast(self):
        # Test GribWrapper interpretation of PDT 4.9 data.
        # NOTE:
        #   Currently Iris has only partial support for PDT 4.9.
        #   Though it can load the data, key metadata (thresholds) is lost.
        #   At present, we are not testing for this.

        # Make a testing grib message in memory, with gribapi.
        grib_message = gribapi.grib_new_from_samples('GRIB2')
        gribapi.grib_set_long(grib_message, 'productDefinitionTemplateNumber',
                              9)
        gribapi.grib_set_string(grib_message, 'stepRange', '10-55')
        grib_wrapper = iris.fileformats.grib.GribWrapper(grib_message)

        # Check that it captures the statistics time period info.
        # (And for now, nothing else)
        self.assertEqual(
            grib_wrapper._referenceDateTime,
            datetime.datetime(year=2007, month=03, day=23,
                              hour=12, minute=0, second=0)
        )