diff --git a/src/run_modules/post_processing.py b/src/run_modules/post_processing.py index 5105b5d8d30104a06e2d030fc6ab79bcf66e1066..0a61ee4f07d0c6eccf698aa16d3de9d7275e75f6 100644 --- a/src/run_modules/post_processing.py +++ b/src/run_modules/post_processing.py @@ -65,6 +65,8 @@ class PostProcessing(RunEnvironment): with TimeTracking(name="boot predictions"): bootstrap_predictions = self.model.predict_generator(generator=bootstraps.boot_strap_generator(), steps=bootstraps.get_boot_strap_generator_length()) + if isinstance(bootstrap_predictions, list): + bootstrap_predictions = bootstrap_predictions[-1] bootstrap_meta = np.array(bootstraps.get_boot_strap_meta()) variables = np.unique(bootstrap_meta[:, 0]) for station in np.unique(bootstrap_meta[:, 1]): @@ -211,7 +213,7 @@ class PostProcessing(RunEnvironment): return ols_prediction def _create_persistence_forecast(self, data, persistence_prediction, mean, std, transformation_method, normalised): - tmp_persi = data.observation.copy().sel({'window': 0})#.shift(datetime=1) + tmp_persi = data.observation.copy().sel({'window': 0}) if not normalised: tmp_persi = statistics.apply_inverse_transformation(tmp_persi, mean, std, transformation_method) window_lead_time = self.data_store.get("window_lead_time", "general") @@ -234,7 +236,9 @@ class PostProcessing(RunEnvironment): tmp_nn = self.model.predict(input_data) if not normalised: tmp_nn = statistics.apply_inverse_transformation(tmp_nn, mean, std, transformation_method) - if tmp_nn.ndim == 3: + if isinstance(tmp_nn, list): + nn_prediction.values = np.swapaxes(np.expand_dims(tmp_nn[-1], axis=1), 2, 0) + elif tmp_nn.ndim == 3: nn_prediction.values = np.swapaxes(np.expand_dims(tmp_nn[-1, ...], axis=1), 2, 0) elif tmp_nn.ndim == 2: nn_prediction.values = np.swapaxes(np.expand_dims(tmp_nn, axis=1), 2, 0)