diff --git a/mlair/plotting/data_insight_plotting.py b/mlair/plotting/data_insight_plotting.py index 4395d1574e42e01ced1b11603445ebee28c16b9b..66daf3743363f531927edb75aa2ab4cc954fcb1f 100644 --- a/mlair/plotting/data_insight_plotting.py +++ b/mlair/plotting/data_insight_plotting.py @@ -968,67 +968,70 @@ class PlotClimateFirFilter(AbstractPlotClass): print(it0) # TODO remove viz_data = viz_date_dict[t0] residuum_true = None - for ifilter in sorted(viz_data.keys()): - print(ifilter) # TODO remove - data = viz_data[ifilter] - filter_input = data["filter_input"] - filter_input_nc = data["filter_input_nc"] if residuum_true is None else residuum_true.sel( - {new_dim: filter_input.coords[new_dim]}) - valid_range = data["valid_range"] - time_axis = data["time_range"] - filter_order = data["order"] - h = data["h"] - fig, ax = plt.subplots() - - # plot backgrounds - - print("plot_valid_area") # TODO remove - self._plot_valid_area(ax, t0, valid_range, td_type) - print("plot_t0") # TODO remove - self._plot_t0(ax, t0) - - # original data - print("plot_original_data") # TODO remove - self._plot_original_data(ax, time_axis, filter_input_nc) - - # clim apriori - print("plot_apriori") # TODO remove - self._plot_apriori(ax, time_axis, filter_input, new_dim, ifilter) - - # clim filter response - print("plot_clim_filter") # TODO remove - residuum_estimated = self._plot_clim_filter(ax, time_axis, filter_input, new_dim, h, + try: + for ifilter in sorted(viz_data.keys()): + print(ifilter) # TODO remove + data = viz_data[ifilter] + filter_input = data["filter_input"] + filter_input_nc = data["filter_input_nc"] if residuum_true is None else residuum_true.sel( + {new_dim: filter_input.coords[new_dim]}) + valid_range = data["valid_range"] + time_axis = data["time_range"] + filter_order = data["order"] + h = data["h"] + fig, ax = plt.subplots() + + # plot backgrounds + print("plot_valid_area") # TODO remove + self._plot_valid_area(ax, t0, valid_range, td_type) + print("plot_t0") # TODO remove + self._plot_t0(ax, t0) + + # original data + print("plot_original_data") # TODO remove + self._plot_original_data(ax, time_axis, filter_input_nc) + + # clim apriori + print("plot_apriori") # TODO remove + self._plot_apriori(ax, time_axis, filter_input, new_dim, ifilter) + + # clim filter response + print("plot_clim_filter") # TODO remove + residuum_estimated = self._plot_clim_filter(ax, time_axis, filter_input, new_dim, h, + output_dtypes=filter_input.dtype) + + # ideal filter response + print("plot_ideal_filter") # TODO remove + residuum_true = self._plot_ideal_filter(ax, time_axis, filter_input_nc, new_dim, h, output_dtypes=filter_input.dtype) - # ideal filter response - print("plot_ideal_filter") # TODO remove - residuum_true = self._plot_ideal_filter(ax, time_axis, filter_input_nc, new_dim, h, - output_dtypes=filter_input.dtype) - - # set title, legend, and save plot - xlims = self._set_xlim(ax, t0, filter_order, valid_range, td_type, time_axis) - - plt.title(f"Input of ClimFilter ({str(var)})") - plt.legend() - fig.autofmt_xdate() - plt.tight_layout() - self.plot_name = f"climFIR_{self._name}_{str(var)}_{it0}_{ifilter}" - self._save() - - # plot residuum - fig, ax = plt.subplots() - self._plot_valid_area(ax, t0, valid_range, td_type) - self._plot_t0(ax, t0) - self._plot_series(ax, time_axis, residuum_true.values.flatten(), style="ideal") - self._plot_series(ax, time_axis, residuum_estimated.values.flatten(), style="clim") - ax.set_xlim(xlims) - plt.title(f"Residuum of ClimFilter ({str(var)})") - plt.legend(loc="upper left") - fig.autofmt_xdate() - plt.tight_layout() - - self.plot_name = f"climFIR_{self._name}_{str(var)}_{it0}_{ifilter}_residuum" - self._save() + # set title, legend, and save plot + xlims = self._set_xlim(ax, t0, filter_order, valid_range, td_type, time_axis) + + plt.title(f"Input of ClimFilter ({str(var)})") + plt.legend() + fig.autofmt_xdate() + plt.tight_layout() + self.plot_name = f"climFIR_{self._name}_{str(var)}_{it0}_{ifilter}" + self._save() + + # plot residuum + fig, ax = plt.subplots() + self._plot_valid_area(ax, t0, valid_range, td_type) + self._plot_t0(ax, t0) + self._plot_series(ax, time_axis, residuum_true.values.flatten(), style="ideal") + self._plot_series(ax, time_axis, residuum_estimated.values.flatten(), style="clim") + ax.set_xlim(xlims) + plt.title(f"Residuum of ClimFilter ({str(var)})") + plt.legend(loc="upper left") + fig.autofmt_xdate() + plt.tight_layout() + + self.plot_name = f"climFIR_{self._name}_{str(var)}_{it0}_{ifilter}_residuum" + self._save() + except Exception as e: + logging.info(f"Could not create plot because of:\n{e}") + pass def _set_xlim(self, ax, t0, order, valid_range, td_type, time_axis): """