From c7f4a9203a809a0ee78ddd7288380c51ed556a87 Mon Sep 17 00:00:00 2001 From: leufen1 <l.leufen@fz-juelich.de> Date: Fri, 16 Jul 2021 14:50:19 +0200 Subject: [PATCH] cleanup, remove commented code --- mlair/plotting/postprocessing_plotting.py | 3 --- mlair/run_modules/post_processing.py | 14 ++------------ 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py index e5080f6e..eef9208a 100644 --- a/mlair/plotting/postprocessing_plotting.py +++ b/mlair/plotting/postprocessing_plotting.py @@ -741,7 +741,6 @@ class PlotBootstrapSkillScore(AbstractPlotClass): data = self._data self.raise_error_if_separate_vars_do_not_exist(data, separate_vars, self._x_name) all_variables = self._get_unique_values_from_column_of_df(data, self._x_name) - # remaining_vars = helpers.list_pop(all_variables, separate_vars) #remove_items remaining_vars = helpers.remove_items(all_variables, separate_vars) data_first = self._select_data(df=data, variables=separate_vars, column_name=self._x_name) data_second = self._select_data(df=data, variables=remaining_vars, column_name=self._x_name) @@ -945,8 +944,6 @@ class PlotTimeSeries: def _plot_obs(self, ax, data): ahead = 1 obs_data = data.sel(type="obs", ahead=ahead).shift(index=ahead) - # index = data.index + np.timedelta64(1, self._sampling) - # ax.plot(index, obs_data.values, color=matplotlib.colors.cnames["green"], label="obs") ax.plot(obs_data, color=matplotlib.colors.cnames["green"], label="obs") @staticmethod diff --git a/mlair/run_modules/post_processing.py b/mlair/run_modules/post_processing.py index 0c530400..c4ce0088 100644 --- a/mlair/run_modules/post_processing.py +++ b/mlair/run_modules/post_processing.py @@ -185,7 +185,6 @@ class PostProcessing(RunEnvironment): number_of_bootstraps = self.data_store.get("number_of_bootstraps", "postprocessing") dims = ["index", self.ahead_dim, "type"] for station in self.test_data: - # logging.info(str(station)) X, Y = None, None bootstraps = BootStraps(station, number_of_bootstraps, bootstrap_type=bootstrap_type, bootstrap_method=bootstrap_method) @@ -252,7 +251,6 @@ class PostProcessing(RunEnvironment): boot_var = boot_set if isinstance(boot_set, str) else f"{boot_set[0]}_{boot_set[1]}" file_name = os.path.join(forecast_path, f"bootstraps_{station}_{boot_var}_{bootstrap_type}_{bootstrap_method}.nc") - # boot_data = xr.open_dataarray(file_name) with xr.open_dataarray(file_name) as da: boot_data = da.load() boot_data = boot_data.combine_first(labels).combine_first(orig) @@ -271,14 +269,12 @@ class PostProcessing(RunEnvironment): if prediction_name is None: prediction_name = self.forecast_indicator file = os.path.join(path, file_name) - # prediction = xr.open_dataarray(file).sel(type=prediction_name).squeeze() with xr.open_dataarray(file) as da: prediction = da.load().sel(type=prediction_name).squeeze() return self.repeat_data(prediction, number_of_bootstraps) - # vals = np.tile(prediction.data, (number_of_bootstraps, 1)) - # return vals[~np.isnan(vals).any(axis=1), :] - def repeat_data(self, data, number_of_repetition): + @staticmethod + def repeat_data(data, number_of_repetition): if isinstance(data, xr.DataArray): data = data.data vals = np.tile(data, (number_of_repetition, 1)) @@ -349,9 +345,6 @@ class PostProcessing(RunEnvironment): model_setup=self.forecast_indicator, sampling=self._sampling, ahead_dim=self.ahead_dim, separate_vars=to_list(self.target_var), bootstrap_type=boot_type, bootstrap_method=boot_method) - # PlotBootstrapSkillScore(self.bootstrap_skill_scores, plot_folder=self.plot_path, - # model_setup=self.forecast_indicator, sampling=self._sampling, - # ahead_dim=self.ahead_dim, separate_vars=to_list(self.target_var)) except Exception as e: logging.error(f"Could not create plot PlotBootstrapSkillScore due to the following error: {e}") @@ -530,7 +523,6 @@ class PostProcessing(RunEnvironment): file = os.path.join(path, f"forecasts_{station_name}_test.nc") with xr.open_dataarray(file) as da: data = da.load() - # data = xr.open_dataarray(file) forecast = data.sel(type=[self.forecast_indicator]) forecast.coords["type"] = [competitor_name] return forecast @@ -688,7 +680,6 @@ class PostProcessing(RunEnvironment): file = os.path.join(path, f"forecasts_{str(station)}_train_val.nc") with xr.open_dataarray(file) as da: return da.load() - # return xr.open_dataarray(file) except (IndexError, KeyError, FileNotFoundError): return None @@ -705,7 +696,6 @@ class PostProcessing(RunEnvironment): file = os.path.join(path, f"forecasts_{str(station)}_test.nc") with xr.open_dataarray(file) as da: return da.load() - # return xr.open_dataarray(file) except (IndexError, KeyError, FileNotFoundError): return None -- GitLab