示例#1
0
    def _downscaling(self, forecast, target_grid, ta_fixed_dt):
        # Using idw for time being
        prep_fcst = {}
        for src_type, fcst in forecast.items():
            if src_type == 'precipitation':
                # just setting som idw_params for time being
                idw_params = api.IDWPrecipitationParameter()
                idw_params.max_distance = 15000
                idw_params.max_members = 4
                idw_params.scale_factor = 1.0
                prep_fcst[src_type] = api.idw_precipitation(
                    fcst, target_grid, ta_fixed_dt, idw_params)
            elif src_type == 'temperature':
                # just setting som idw_params for time being
                idw_params = api.IDWTemperatureParameter()
                idw_params.max_distance = 15000
                idw_params.max_members = 4
                idw_params.gradient_by_equation = False
                prep_fcst[src_type] = api.idw_temperature(
                    fcst, target_grid, ta_fixed_dt, idw_params)
            elif src_type == 'radiation':
                # just setting som idw_params for time being
                idw_params = api.IDWParameter()
                idw_params.max_distance = 15000
                idw_params.max_members = 4
                idw_params.distance_measure_factor = 1
                slope_factor = api.DoubleVector([0.9] * len(target_grid))
                prep_fcst[src_type] = api.idw_radiation(
                    fcst, target_grid, ta_fixed_dt, idw_params, slope_factor)
            elif src_type == 'wind_speed':
                # just setting som idw_params for time being
                idw_params = api.IDWParameter()
                idw_params.max_distance = 15000
                idw_params.max_members = 4
                idw_params.distance_measure_factor = 1
                prep_fcst[src_type] = api.idw_wind_speed(
                    fcst, target_grid, ta_fixed_dt, idw_params)
            elif src_type == 'relative_humidity':
                # just setting som idw_params for time being
                idw_params = api.IDWParameter()
                idw_params.max_distance = 15000
                idw_params.max_members = 4
                idw_params.distance_measure_factor = 1
                prep_fcst[src_type] = api.idw_relative_humidity(
                    fcst, target_grid, ta_fixed_dt, idw_params)

        return prep_fcst
示例#2
0
    def test_idw_rel_hum_from_set_to_grid(self):
        """
        Test IDW interpolation transforms wind_speed time-series according to time-axis and range.

        """
        idw_p = api.IDWParameter()
        self.assertEqual(idw_p.max_distance, 200000)
        self.assertEqual(idw_p.max_members, 10)
        fx = lambda z : [15 for x in range(self.n)]
        arome_grid = self._create_geo_rel_hum_grid(self.nx, self.ny, self.dx_arome, fx)
        dest_grid_points = self._create_geo_point_grid(self.mnx, self.mny, self.dx_model)
        ta = api.TimeAxisFixedDeltaT(self.t, self.d * 3, int(self.n / 3))
        dest_grid = api.idw_relative_humidity(arome_grid, dest_grid_points, ta, idw_p)
        self.assertIsNotNone(dest_grid)
        self.assertEqual(len(dest_grid), self.mnx * self.mny)
示例#3
0
    def test_idw_radiation_transform_from_set_to_grid(self):
        """
        Test IDW interpolation transforms wind_speed time-series according to time-axis and range.

        """
        idw_p = api.IDWParameter()
        self.assertEqual(idw_p.max_distance, 200000)
        self.assertEqual(idw_p.max_members, 10)
        fx = lambda z : [15 for x in range(self.n)]
        arome_grid = self._create_geo_radiation_grid(self.nx, self.ny, self.dx_arome, fx)
        dest_grid_points = self._create_geo_point_grid(self.mnx, self.mny, self.dx_model)
        ta = api.TimeAxisFixedDeltaT(self.t, self.d * 3, int(self.n / 3))
        radiation_slope_factors = api.DoubleVector()
        radiation_slope_factors[:] = [ 0.9 for i in range(len(dest_grid_points))]
        dest_grid = api.idw_radiation(arome_grid, dest_grid_points, ta, idw_p, radiation_slope_factors)
        self.assertIsNotNone(dest_grid)
        self.assertEqual(len(dest_grid), self.mnx * self.mny)