def setUp(self): """Set up the plugin and cubes for testing.""" frt_dt = datetime.datetime(2017, 11, 10, 0, 0) time_dt = datetime.datetime(2017, 11, 10, 4, 0) data = np.ones((3, 3), dtype=np.float32) self.historic_forecast = (_create_historic_forecasts( data, time_dt, frt_dt, standard_grid_metadata="uk_det").merge_cube()) data_with_realizations = np.ones((3, 3, 3), dtype=np.float32) self.historic_forecast_with_realizations = (_create_historic_forecasts( data_with_realizations, time_dt, frt_dt, standard_grid_metadata="uk_det", realizations=[0, 1, 2]).merge_cube()) self.optimised_coeffs = np.array([0, 1, 2, 3], np.int32) coeff_names = ["gamma", "delta", "alpha", "beta"] self.expected, self.x_coord, self.y_coord = create_coefficients_cube( self.historic_forecast, coeff_names, self.optimised_coeffs) self.distribution = "gaussian" self.current_cycle = "20171110T0000Z" self.desired_units = "degreesC" self.predictor_of_mean_flag = "mean" self.plugin = (Plugin( distribution=self.distribution, current_cycle=self.current_cycle, desired_units=self.desired_units, predictor_of_mean_flag=self.predictor_of_mean_flag))
def setUp(self): """Set up temperature and wind speed cubes for testing.""" # Note: test_temperature_realizations_data_check produces ~0.5K # different results when the temperature forecast cube is float32 # below. A bug? data = (np.tile(np.linspace(-45.0, 45.0, 9), 3).reshape(3, 3, 3) + 273.15) data[0] -= 2 data[1] += 2 data[2] += 4 data = data.astype(np.float32) self.current_temperature_forecast_cube = set_up_variable_cube( data, units="Kelvin", realizations=[0, 1, 2]) self.historic_temperature_forecast_cube = (_create_historic_forecasts( self.current_temperature_forecast_cube)) self.temperature_truth_cube = (_create_truth( self.current_temperature_forecast_cube)) data = np.tile(np.linspace(0, 60, 9), 3).reshape(3, 3, 3) data[1] += 2 data[2] += 4 data = data.astype(np.float32) self.current_wind_speed_forecast_cube = set_up_variable_cube( data, name="wind_speed", units="m s-1", realizations=[0, 1, 2]) self.historic_wind_speed_forecast_cube = (_create_historic_forecasts( self.current_wind_speed_forecast_cube)) self.wind_speed_truth_cube = (_create_truth( self.current_wind_speed_forecast_cube))
def setUp(self): """Set up the plugin and cubes for testing.""" data = np.ones((3, 3), dtype=np.float32) self.historic_forecast = (_create_historic_forecasts( set_up_variable_cube(data, standard_grid_metadata="uk_det"))) data_with_realizations = np.ones((3, 3, 3), dtype=np.float32) self.historic_forecast_with_realizations = (_create_historic_forecasts( set_up_variable_cube(data_with_realizations, realizations=[0, 1, 2], standard_grid_metadata="uk_det"))) self.optimised_coeffs = np.array([0, 1, 2, 3], np.int32) coeff_names = ["gamma", "delta", "alpha", "beta"] coefficient_index = iris.coords.DimCoord(self.optimised_coeffs, long_name="coefficient_index", units="1") dim_coords_and_dims = [(coefficient_index, 0)] coefficient_name = iris.coords.AuxCoord(coeff_names, long_name="coefficient_name", units="no_unit") time_point = (np.max(self.historic_forecast.coord("time").points) + 60 * 60 * 24) time_coord = self.historic_forecast.coord("time").copy(time_point) frt_orig_coord = ( self.historic_forecast.coord("forecast_reference_time")) frt_point = np.max(frt_orig_coord.points) + 60 * 60 * 24 frt_coord = frt_orig_coord.copy(frt_point) aux_coords_and_dims = [ (coefficient_name, 0), (time_coord, None), (frt_coord, None), (self.historic_forecast[-1].coord("forecast_period"), None) ] attributes = { "mosg__model_configuration": "uk_det", "diagnostic_standard_name": "air_temperature" } self.expected = iris.cube.Cube(self.optimised_coeffs, long_name="emos_coefficients", units="1", dim_coords_and_dims=dim_coords_and_dims, aux_coords_and_dims=aux_coords_and_dims, attributes=attributes) self.distribution = "gaussian" self.current_cycle = "20171110T0000Z" self.desired_units = "degreesC" self.predictor_of_mean_flag = "mean" self.plugin = (Plugin( distribution=self.distribution, current_cycle=self.current_cycle, desired_units=self.desired_units, predictor_of_mean_flag=self.predictor_of_mean_flag))
def setUp(self): """Set up multiple cubes for testing.""" self.current_temperature_forecast_cube = ( add_forecast_reference_time_and_forecast_period( set_up_temperature_cube())) self.historic_temperature_forecast_cube = (_create_historic_forecasts( self.current_temperature_forecast_cube)) self.temperature_truth_cube = (_create_truth( self.current_temperature_forecast_cube)) self.current_wind_speed_forecast_cube = ( add_forecast_reference_time_and_forecast_period( set_up_wind_speed_cube())) self.historic_wind_speed_forecast_cube = (_create_historic_forecasts( self.current_wind_speed_forecast_cube)) self.wind_speed_truth_cube = (_create_truth( self.current_wind_speed_forecast_cube))
def setUp(self): """Set up temperature and wind speed cubes for testing.""" # Note: test_temperature_realizations_data_check produces ~0.5K # different results when the temperature forecast cube is float32 # below. A bug? self.current_temperature_forecast_cube = ( add_forecast_reference_time_and_forecast_period( set_up_temperature_cube())) self.historic_temperature_forecast_cube = (_create_historic_forecasts( self.current_temperature_forecast_cube)) self.temperature_truth_cube = (_create_truth( self.current_temperature_forecast_cube)) self.current_wind_speed_forecast_cube = ( add_forecast_reference_time_and_forecast_period( set_up_wind_speed_cube())) self.historic_wind_speed_forecast_cube = (_create_historic_forecasts( self.current_wind_speed_forecast_cube)) self.wind_speed_truth_cube = (_create_truth( self.current_wind_speed_forecast_cube))