diff --git a/webviz_ert/controllers/response_correlation_controller.py b/webviz_ert/controllers/response_correlation_controller.py index c50a7619..cdbfb344 100644 --- a/webviz_ert/controllers/response_correlation_controller.py +++ b/webviz_ert/controllers/response_correlation_controller.py @@ -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 @@ -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) @@ -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"]) @@ -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], @@ -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"]) @@ -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}**, " diff --git a/webviz_ert/data_loader/__init__.py b/webviz_ert/data_loader/__init__.py index 755cb2f6..a9d20efe 100644 --- a/webviz_ert/data_loader/__init__.py +++ b/webviz_ert/data_loader/__init__.py @@ -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) diff --git a/webviz_ert/models/plot_model.py b/webviz_ert/models/plot_model.py index 54300c3b..301a841b 100644 --- a/webviz_ert/models/plot_model.py +++ b/webviz_ert/models/plot_model.py @@ -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)