Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes in the EnsembleTableProvider and SimulationTimeseriesOneByOne #1234

Merged
merged 4 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- [#1232](https://github.com/equinor/webviz-subsurface/pull/1232) - Removed slow function in `RftPlotter` to improve startup time of plugin.
- [#1234](https://github.com/equinor/webviz-subsurface/pull/1234) - Fixed a bug that occured in `SimulationTimeSeriesOneByOne` when changing between ensembles with different sensitivity names.


### Changed
- [#1231](https://github.com/equinor/webviz-subsurface/pull/1231) - Upgrades to the `EnsembleTableProvider` that improves performance: it no longer relies on `fmu-ensemble` for loading csv-files and parameters into dataframes. Additional: added new plugin argument `drop_failed_realizations` to `VolumetricAnalysis` to be able to load in volumetrics files, if they exist, even though the ensemble has crashed.
Expand Down
5 changes: 2 additions & 3 deletions webviz_subsurface/_models/parameter_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__(
self._possible_selectors = [
col for col in self._possible_selectors if col != "SENSNAME"
]
self._dataframe["SENSNAME"].fillna("None")

self._validate_dframe()
self._sensrun = self._check_if_sensitivity_run()
Expand Down Expand Up @@ -57,7 +56,7 @@ def selectors(self) -> list:

@property
def sensitivities(self) -> list:
return list(self._dataframe["SENSNAME"].unique()) if self.sensrun else []
return list(self._dataframe["SENSNAME"].unique())

@property
def sensrun(self) -> bool:
Expand Down Expand Up @@ -147,7 +146,7 @@ def _check_if_sensitivity_run(self) -> bool:
self._sensitivity_ensembles = []

if "SENSNAME" not in self._dataframe:
return False
self._dataframe["SENSNAME"] = np.nan

# if mix of gen_kw and sensitivity ensembles add
# dummy sensitivvity columns to gen_kw ensembles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ def _load_table_from_parameters_file(entry: FileEntry) -> dict:
data: Dict[str, Any] = {"REAL": int(entry.real)}
with open(entry.filename, "r") as paramfile:
for line in paramfile:
param, value = line.split()
param, *valuelist = line.split()
# Remove leading and trailing qoutation marks.
# This can happen if a parameter value includes a space
if len(valuelist) > 1:
valuelist = [val.strip('"') for val in valuelist]
value = " ".join(valuelist)
data[param] = parse_number_from_string(value)
return data

Expand All @@ -143,7 +148,7 @@ def load_per_real_parameters_file(
globpattern = os.path.join(ens_path, parameter_file)
files_to_process = _discover_files(globpattern, validated_reals)
if len(files_to_process) == 0:
LOGGER.warning(f"No csv files were discovered in: {ens_path}")
LOGGER.warning(f"No 'parameter.txt' files were discovered in: {ens_path}")
LOGGER.warning(f"Glob pattern used: {globpattern}")
return pd.DataFrame()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ def create_from_per_realization_parameter_file(
timer.lap_s()
ensemble_df = load_per_real_parameters_file(ens_path, drop_failed_realizations)

if ensemble_df.empty:
raise ValueError(
f"Failed to load 'parameter.txt' files for ensemble {ens_path}."
)

elapsed_load_parameters_s = timer.lap_s()

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def _update_options(option_values: list, options_id: List[dict]) -> dict:
)
def _update_realization_store(sensitivites: list, ensemble: str) -> List[int]:
"""Update graph with line coloring, vertical line and title"""
if not sensitivites:
raise PreventUpdate
df = self._data_model.get_sensitivity_dataframe_for_ensemble(ensemble)
return self._data_model.get_realizations_for_sensitivies(df, sensitivites)

Expand All @@ -132,6 +134,7 @@ def _update_realization_store(sensitivites: list, ensemble: str) -> List[int]:
SensitivityFilter.Ids.SENSITIVITY_FILTER,
),
"value",
allow_duplicate=True,
),
Input(
self.view_element(self.Ids.TORNADO_PLOT)
Expand Down Expand Up @@ -169,6 +172,14 @@ def _update_sensitivity_filter(
),
"options",
),
Output(
self.settings_group_unique_id(
self.Ids.SENSITIVITY_FILTER,
SensitivityFilter.Ids.SENSITIVITY_FILTER,
),
"value",
allow_duplicate=True,
),
Output(
{
"id": self.settings_group_unique_id(
Expand Down Expand Up @@ -220,9 +231,10 @@ def _update_sensitivity_filter(
},
"value",
),
prevent_initial_call="initial_duplicate",
)
@callback_typecheck
def _update_sensitivity_filter_and_reference(
def _update_sensitivity_filter_reference_and_vector_selector(
ensemble: str, vector: list, reference: str
) -> tuple:
"""Update graph with line coloring, vertical line and title"""
Expand All @@ -241,6 +253,7 @@ def _update_sensitivity_filter_and_reference(
)
return (
[{"label": elm, "value": elm} for elm in sensitivities],
sensitivities,
[{"label": elm, "value": elm} for elm in sensitivities],
self._data_model.get_tornado_reference(sensitivities, reference),
vector_selector_data,
Expand Down