Ejemplo n.º 1
0
    def test_get_ensemble(self):
        """
        Simple ensemble regression test of OpenDAP data repository.
        """
        epsg, bbox = self.epsg_bbox

        dem_file = path.join(shyftdata_dir, "netcdf", "etopo180.nc")

        # Period start
        (year, month, day), hour = self.start_date, 9
        n_hours = 30
        utc = api.Calendar()  # No offset gives Utc
        t0 = api.YMDhms(year, month, day, hour)
        period = api.UtcPeriod(utc.time(t0),
                               utc.time(t0) + api.deltahours(n_hours))
        t_c = utc.time(t0) + api.deltahours(7)

        repos = GFSDataRepository(epsg, dem_file, bounding_box=bbox)
        data_names = ("temperature", "wind_speed", "precipitation",
                      "relative_humidity", "radiation")
        ensembles = repos.get_forecast_ensemble(data_names, period, t_c, None)
        for sources in ensembles:
            self.assertEqual(set(data_names), set(sources.keys()))
            self.assertEqual(len(sources["temperature"]), 6)
            data1 = sources["temperature"][0]
            data2 = sources["temperature"][1]
            self.assertNotEqual(data1.mid_point().x, data2.mid_point().x)
            self.assertNotEqual(data1.mid_point().y, data2.mid_point().y)
            self.assertNotEqual(data1.mid_point().z, data2.mid_point().z)
            h_dt = (data1.ts.time(1) - data1.ts.time(0)) / 3600
            self.assertEqual(data1.ts.size(), 30 // h_dt)
Ejemplo n.º 2
0
    def test_get_ensemble(self):
        """
        Simple ensemble regression test of OpenDAP data repository.
        """
        epsg, bbox = self.epsg_bbox

        dem_file = path.join(shyftdata_dir, "netcdf", "etopo180.nc")

        # Period start
        (year, month, day), hour = self.start_date, 9
        n_hours = 30
        utc = api.Calendar()  # No offset gives Utc
        t0 = api.YMDhms(year, month, day, hour)
        period = api.UtcPeriod(utc.time(t0), utc.time(t0) + api.deltahours(n_hours))
        t_c = utc.time(t0) + api.deltahours(7)

        repos = GFSDataRepository(epsg, dem_file, bounding_box=bbox)
        data_names = ("temperature", "wind_speed", "precipitation",
                      "relative_humidity", "radiation")
        ensembles = repos.get_forecast_ensemble(data_names, period, t_c, None)
        for sources in ensembles:
            self.assertEqual(set(data_names), set(sources.keys()))
            self.assertEqual(len(sources["temperature"]), 6)
            data1 = sources["temperature"][0]
            data2 = sources["temperature"][1]
            self.assertNotEqual(data1.mid_point().x, data2.mid_point().x)
            self.assertNotEqual(data1.mid_point().y, data2.mid_point().y)
            self.assertNotEqual(data1.mid_point().z, data2.mid_point().z)
            h_dt = (data1.ts.time(1) - data1.ts.time(0))/3600
            self.assertEqual(data1.ts.size(), 30//h_dt)
Ejemplo n.º 3
0
    def test_get_ensemble(self):
        """
        Simple ensemble regression test of OpenDAP data repository.
        """
        epsg, bbox = self.epsg_bbox
        dem_file = path.join(shyftdata_dir, "netcdf", "etopo180.nc")
        n_hours = 30
        t0 = self.start_date + api.deltahours(
            9)  # api.YMDhms(year, month, day, hour)
        period = api.UtcPeriod(t0, t0 + api.deltahours(n_hours))
        t_c = t0

        repos = GFSDataRepository(epsg, dem_file, bounding_box=bbox)
        data_names = (
            "temperature",
        )  # this is the full set: "wind_speed", "precipitation", "relative_humidity", "radiation")
        ensembles = repos.get_forecast_ensemble(data_names, period, t_c, None)
        for sources in ensembles:
            self.assertEqual(set(data_names), set(sources.keys()))
            self.assertEqual(len(sources["temperature"]), 6)
            data1 = sources["temperature"][0]
            data2 = sources["temperature"][1]
            self.assertNotEqual(data1.mid_point().x, data2.mid_point().x)
            self.assertNotEqual(data1.mid_point().y, data2.mid_point().y)
            self.assertNotEqual(data1.mid_point().z, data2.mid_point().z)
            self.assertLessEqual(
                data1.ts.time(0), period.start,
                'expect returned fc ts to cover requested period')
            self.assertGreaterEqual(
                data1.ts.total_period().end, period.end,
                'expect returned fc ts to cover requested period')
Ejemplo n.º 4
0
 def test_get_timeseries(self):
     """
     Simple regression test of OpenDAP data repository.
     """
     epsg, bbox = self.epsg_bbox
     dem_file = path.join(shyftdata_dir, "netcdf", "etopo180.nc")
     n_hours = 30
     t0 = self.start_date + api.deltahours(7)
     period = api.UtcPeriod(t0, t0 + api.deltahours(n_hours))
         
     repos = GFSDataRepository(epsg, dem_file, t0, bounding_box=bbox)
     data_names = ("temperature", "wind_speed", "precipitation", "relative_humidity", "radiation")
     sources = repos.get_timeseries(data_names, period, None)
     self.assertEqual(set(data_names), set(sources.keys()))
     self.assertEqual(len(sources["temperature"]), 6)
     data1 = sources["temperature"][0]
     data2 = sources["temperature"][1]
     self.assertNotEqual(data1.mid_point().x, data2.mid_point().x)
     self.assertNotEqual(data1.mid_point().y, data2.mid_point().y)
     self.assertNotEqual(data1.mid_point().z, data2.mid_point().z)
     self.assertLessEqual(data1.ts.time(0), period.start, 'expect returned fc ts to cover requested period')
     self.assertGreaterEqual(data1.ts.total_period().end, period.end, 'expect returned fc ts to cover requested period')