Skip to content

Commit

Permalink
Raise descriptive error if no surfaces are found (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kallekleiv authored Mar 24, 2021
1 parent 726893c commit c595811
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- [#594](https://github.com/equinor/webviz-subsurface/pull/594) - Fixed bug in SurfaceViewerFMU where surfaces with only undefined values was not handled properly.
- [#584](https://github.com/equinor/webviz-subsurface/pull/584) - Fixed bug for in RelativePermeability plugin where it was not possible to plot against oil saturation axis when using relperm data of "family 2".
- [#595](https://github.com/equinor/webviz-subsurface/pull/595) - Raise a descriptive error in SurfaceViewerFMU plugin if no surfaces are available.

## [0.1.9] - 2021-02-23
### Fixed
Expand Down
18 changes: 16 additions & 2 deletions webviz_subsurface/_datainput/fmu_input.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
import warnings
import glob
from typing import Union, Optional

Expand Down Expand Up @@ -142,19 +143,32 @@ def find_surfaces(
"""
# Create list of all files in all realizations in all ensembles
files = []
for path in ensemble_paths.values():
for ens, path in ensemble_paths.items():
path = Path(path)
ens_files = []
for realpath in glob.glob(str(path / "share" / "results" / "maps" / suffix)):
stem = Path(realpath).stem.split(delimiter)

if len(stem) >= 2:
files.append(
ens_files.append(
{
"ENSEMBLE": ens,
"path": realpath,
"name": stem[0],
"attribute": stem[1],
"date": stem[2] if len(stem) >= 3 else None,
}
)
if not ens_files:
warnings.warn(f"No surfaces found for ensemble located at {path}.")
else:
files.extend(ens_files)

# Store surface name, attribute and date as Pandas dataframe
if not files:
raise ValueError(
"No surfaces found! Ensure that surfaces file are stored "
"at share/results/maps in each ensemble and is following "
"the FMU naming standard (name--attribute[--date].gri)"
)
return pd.DataFrame(files)
16 changes: 12 additions & 4 deletions webviz_subsurface/plugins/_surface_viewer_fmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ def __init__(

# Find surfaces
self.surfacedf = find_surfaces(self.ens_paths)
# Extract realizations and sensitivity information
self.ens_df = get_realizations(
ensemble_paths=self.ens_paths, ensemble_set_name="EnsembleSet"
)

# Drop any ensembles that does not have surfaces
self.ens_df = self.ens_df.loc[
self.ens_df["ENSEMBLE"].isin(self.surfacedf["ENSEMBLE"].unique())
]
self.surfacedf.drop("ENSEMBLE", axis=1, inplace=True)

if attributes is not None:
self.surfacedf = self.surfacedf[
self.surfacedf["attribute"].isin(attributes)
Expand All @@ -130,10 +141,7 @@ def __init__(
if self.wellfiles
else None
)
# Extract realizations and sensitivity information
self.ens_df = get_realizations(
ensemble_paths=self.ens_paths, ensemble_set_name="EnsembleSet"
)

self.selector = SurfaceSelector(app, self.surfaceconfig, ensembles)
self.selector2 = SurfaceSelector(app, self.surfaceconfig, ensembles)

Expand Down

0 comments on commit c595811

Please sign in to comment.