Skip to content

Commit

Permalink
Enable support for ensembles with no data inside
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSava committed Nov 9, 2021
1 parent c256203 commit 495e6dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
11 changes: 8 additions & 3 deletions webviz_ert/controllers/response_correlation_controller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import List, Optional, Dict, Mapping, Tuple, Any

import pandas as pd
from dash.development.base_component import Component
from webviz_ert.plugins._webviz_ert import WebvizErtPluginABC

Expand Down Expand Up @@ -77,6 +78,8 @@ def update_correlation_plot(
for ensemble_id, color in ensembles.items():
ensemble = load_ensemble(parent, ensemble_id)
parameter_df = ensemble.parameters_df(parameters)
if parameter_df.empty:
continue
for response in responses:
response_df = ensemble.responses[response].data_df()
x_index = corr_xindex.get(response, 0)
Expand Down Expand Up @@ -167,6 +170,8 @@ def update_response_overview_plot(
ensemble = load_ensemble(parent, ensemble_id)
response = ensemble.responses[selected_response]
x_axis = response.axis
if isinstance(x_axis, pd.Index) and x_axis.empty:
continue
if x_axis is not None:
if str(x_axis[0]).isnumeric():
style = deepcopy(assets.ERTSTYLE["response-plot"]["response-index"])
Expand Down Expand Up @@ -200,7 +205,7 @@ def update_response_overview_plot(
fig.update_layout(_layout)

x_index = corr_xindex.get(selected_response, 0)
if x_axis is not None:
if isinstance(x_axis, pd.Index) and not x_axis.empty:
fig.add_shape(
type="line",
x0=x_axis[x_index],
Expand Down Expand Up @@ -269,7 +274,7 @@ def update_response_parameter_scatterplot(
y_data = ensemble.parameters[selected_parameter].data_df()
response = ensemble.responses[selected_response]

if response.axis is not None:
if isinstance(response.axis, pd.Index) and not response.axis.empty:
x_index = corr_xindex.get(selected_response, 0)
x_data = response.data_df().iloc[x_index]
style = deepcopy(assets.ERTSTYLE["response-plot"]["response-index"])
Expand Down Expand Up @@ -327,7 +332,7 @@ def update_response_parameter_scatterplot(
final_text = []
for response_name in responses:
x_axis = ensemble.responses[response_name].axis
if x_axis is not None:
if isinstance(x_axis, pd.Index) and not x_axis.empty:
x_value = x_axis[corr_xindex.get(response_name, 0)]
if response_name == selected_response:
res_text = f"**{response_name} @ {x_value}**, "
Expand Down
2 changes: 1 addition & 1 deletion webviz_ert/data_loader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def get_ensemble_record_data(
logger.error(e)

if dfs == []:
raise DataLoaderException(f"No data found for {record_name}")
return pd.DataFrame()

return pd.concat(dfs, axis=1)

Expand Down
4 changes: 4 additions & 0 deletions webviz_ert/models/plot_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,16 @@ def repr(self) -> go.Figure:
names = []
realization_nums = []
for name in self._data_df_dict:
if self._data_df_dict[name].empty:
continue
data.append(list(self._data_df_dict[name].values.flatten()))
colors.append(self._colors[name])
names.append(self._names[name])
realization_nums.append(
[f"Realization {num}" for num in self._data_df_dict[name].columns]
)
if data == []:
return go.Figure()
_max = float(np.hstack(data).max())
_min = float(np.hstack(data).min())
bin_size = float((_max - _min) / self.bin_count)
Expand Down

0 comments on commit 495e6dd

Please sign in to comment.