diff --git a/mlair/plotting/postprocessing_plotting.py b/mlair/plotting/postprocessing_plotting.py index 581af2a009133c0e994ba3e33b105b5125f129dd..578a71b4cc1c9a68c55aeabcba141ba9a59eb1af 100644 --- a/mlair/plotting/postprocessing_plotting.py +++ b/mlair/plotting/postprocessing_plotting.py @@ -723,9 +723,15 @@ class PlotBootstrapSkillScore(AbstractPlotClass): (score_only=True, default). Y-axis is adjusted following the data and not hard coded. The plot is saved under plot_folder path with name skill_score_clim_{extra_name_tag}{model_setup}.pdf and resolution of 500dpi. + By passing a list `separate_vars` containing variable names, a second plot is created showing the `separate_vars` + and the remaining variables side by side with different scaling. + .. image:: ../../../../../_source/_plots/skill_score_bootstrap.png :width: 400 + .. image:: ../../../../../_source/_plots/skill_score_bootstrap_separated.png + :width: 400 + """ def __init__(self, data: Dict, plot_folder: str = ".", model_setup: str = "", separate_vars: List = None): @@ -1071,8 +1077,10 @@ class PlotAvailability(AbstractPlotClass): # create standard Gantt plot for all stations (currently in single pdf file with single page) super().__init__(plot_folder, "data_availability") self.dim = time_dimension - self.linewidth = None self.sampling = self._get_sampling(sampling) + self.linewidth = None + if self.sampling == 'h': + self.linewidth = 0.001 plot_dict = self._prepare_data(generators) lgd = self._plot(plot_dict) self._save(bbox_extra_artists=(lgd,), bbox_inches="tight") @@ -1087,13 +1095,6 @@ class PlotAvailability(AbstractPlotClass): lgd = self._plot(plot_dict_summary) self._save(bbox_extra_artists=(lgd,), bbox_inches="tight") - def _get_sampling(self, sampling): - if sampling == "daily": - return "D" - elif sampling == "hourly": - self.linewidth = 0.001 - return "h" - def _prepare_data(self, generators: Dict[str, DataCollection]): plt_dict = {} for subset, data_collection in generators.items(): @@ -1195,19 +1196,27 @@ class PlotAvailabilityHistogram(AbstractPlotClass): 2) data_availability_histogram_cumulative: number of samples (xaxis) vs. number of stations having at least number of samples (yaxis) + .. image:: ../../../../../_source/_plots/data_availability_histogram_hist.png + :width: 400 + + .. image:: ../../../../../_source/_plots/data_availability_histogram_hist_cum.png + :width: 400 + """ - def __init__(self, generators: Dict[str, DataCollection], plot_folder: str = ".", sampling="daily", - subset_dim: str = 'DataSet', temporal_dim: str = 'datetime', history_dim: str = 'window', - station_dim: str = 'Stations', target_dim='variables'): + def __init__(self, generators: Dict[str, DataCollection], plot_folder: str = ".", + subset_dim: str = 'DataSet', history_dim: str = 'window', + station_dim: str = 'Stations',): super().__init__(plot_folder, "data_availability_histogram") - self.freq = self._get_sampling(sampling) + self.subset_dim = subset_dim - self.temporal_dim = temporal_dim self.history_dim = history_dim self.station_dim = station_dim - self.target_dim = target_dim + + self.freq = None + self.temporal_dim = None + self.target_dim = None self._prepare_data(generators) for plt_type in self.allowed_plot_types: @@ -1217,6 +1226,11 @@ class PlotAvailabilityHistogram(AbstractPlotClass): self._save() self.plot_name = plot_name_tmp + def _set_dims_from_datahandler(self, data_handler): + self.temporal_dim = data_handler.id_class.time_dim + self.target_dim = data_handler.id_class.target_dim + self.freq = self._get_sampling(data_handler.id_class.sampling) + @property def allowed_plot_types(self): plot_types = ['hist', 'hist_cum'] @@ -1234,6 +1248,7 @@ class PlotAvailabilityHistogram(AbstractPlotClass): for subset, generator in generators.items(): avail_list = [] for station in generator: + self._set_dims_from_datahandler(data_handler=station) station_data_x = station.get_X(as_numpy=False)[0] station_data_x = station_data_x.loc[{self.history_dim: 0, # select recent window frame self.target_dim: station_data_x[self.target_dim].values[0]}]