Skip to content
Snippets Groups Projects
Commit 83fd35e2 authored by lukas leufen's avatar lukas leufen
Browse files

Merge branch 'lukas_issue223_bug_plotavailabilityhistogram-expects-2d-data' into 'develop'

Resolve "BUG: PlotAvailabilityHistogram expects 2D data"

See merge request toar/mlair!199
parents f1b7a14e 63d232d5
Branches
Tags
3 merge requests!226Develop,!225Resolve "release v1.2.0",!199Resolve "BUG: PlotAvailabilityHistogram expects 2D data"
Pipeline #54106 passed with warnings
This commit is part of merge request !225. Comments created here will be created in the context of that merge request.
......@@ -1252,6 +1252,7 @@ class PlotAvailabilityHistogram(AbstractPlotClass):
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]}]
station_data_x = self._reduce_dims(station_data_x)
avail_list.append(station_data_x.notnull())
avail_data = xr.concat(avail_list, dim=self.station_dim).notnull()
avail_data_time_sum[subset] = avail_data.sum(dim=self.station_dim)
......@@ -1268,6 +1269,14 @@ class PlotAvailabilityHistogram(AbstractPlotClass):
self.avail_data_amount = avail_data_amount.reindex({self.temporal_dim: full_time_index})
self.dataset_time_interval = dataset_time_interval
def _reduce_dims(self, dataset):
if len(dataset.dims) > 2:
required = {self.temporal_dim, self.station_dim}
unimportant = set(dataset.dims).difference(required)
sel_dict = {un: dataset[un].values[0] for un in unimportant}
dataset = dataset.loc[sel_dict]
return dataset
@staticmethod
def _get_first_and_last_indexelement_from_xarray(xarray, dim_name, return_type='as_tuple'):
if isinstance(xarray, xr.DataArray):
......
......@@ -121,6 +121,7 @@ class PreProcessing(RunEnvironment):
self.save_to_tex(path=path, filename="station_sample_size.tex", column_format=column_format, df=df)
self.save_to_md(path=path, filename="station_sample_size.md", df=df)
df_nometa = df.drop(meta_data, axis=1)
column_format = self.create_column_format_for_tex(df)
self.save_to_tex(path=path, filename="station_sample_size_short.tex", column_format=column_format, df=df_nometa)
self.save_to_md(path=path, filename="station_sample_size_short.md", df=df_nometa)
# df_nometa.to_latex(os.path.join(path, "station_sample_size_short.tex"), na_rep='---',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment