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

ProdMisfit- fixed bug related to use of excl_name_contains. #1055

Merged
merged 4 commits into from
Jun 14, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- [#1055](https://github.com/equinor/webviz-subsurface/pull/1055) - `ProdMisfit` - Fixed a bug related to the input argument *excl_name_contains*.
- [#1053](https://github.com/equinor/webviz-subsurface/pull/1046) - `SwatinitQC` - Fixed an issue so that relative paths for the `faultlines` argument works.
- [#1046](https://github.com/equinor/webviz-subsurface/pull/1046) - `MapViewerFMU` - Fixed an issue related to upstream changes in prop specification for the DeckGLMap component.

Expand Down
64 changes: 46 additions & 18 deletions webviz_subsurface/plugins/_prod_misfit/_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ class ProdMisfit(WebvizPluginABC):
---
* **`ensembles`:** Which ensembles in `shared_settings` to include.
* **`rel_file_pattern`:** path to `.arrow` files with summary data.
* **`gruptree_file`:** `.csv` with gruptree information.
* **`sampling`:** Frequency for the data sampling.
* **`well_attributes_file`:** Path to json file containing info of well attributes.
The attribute category values can be used for filtering of well collections.
* **`excl_name_startswith`:** Filter out wells that starts with this string
* **`excl_name_contains`:** Filter out wells that contains this string
* **`phase_weights`:** Dict of "Oil", "Water" and "Gas" (inverse) weight factors that
* **`excl_name_startswith`:** Exclude wells that starts with this string.
* **`excl_name_endswith`:** Exclude wells that ends with this string.
* **`excl_name_contains`:** Exclude wells that contains this string.
* **`phase_weights`:** Dict of "Oil", "Water" and "Gas" inverse weight factors that
are included as weight option for misfit per real calculation.
---

Expand Down Expand Up @@ -91,6 +91,7 @@ def __init__(
sampling: str = Frequency.YEARLY.value,
well_attributes_file: str = None,
excl_name_startswith: list = None,
excl_name_endswith: list = None,
excl_name_contains: list = None,
phase_weights: dict = None,
):
Expand All @@ -103,6 +104,16 @@ def __init__(
self.weight_reduction_factor_wat = phase_weights["Water"]
self.weight_reduction_factor_gas = phase_weights["Gas"]

if excl_name_startswith is None:
excl_name_startswith = []
excl_name_startswith = [str(element) for element in excl_name_startswith]
if excl_name_endswith is None:
excl_name_endswith = []
excl_name_endswith = [str(element) for element in excl_name_endswith]
if excl_name_contains is None:
excl_name_contains = []
excl_name_contains = [str(element) for element in excl_name_contains]

# Must define valid frequency
self._sampling = Frequency(sampling)

Expand Down Expand Up @@ -150,7 +161,10 @@ def __init__(
self.vectors[ens_name],
self.phases[ens_name],
) = _get_wells_vectors_phases(
ens_provider.vector_names(), excl_name_startswith, excl_name_contains
ens_provider.vector_names(),
excl_name_startswith,
excl_name_endswith,
excl_name_contains,
)

# self.well_collections = _get_well_collections_from_attr(well_attrs, self.wells)
Expand Down Expand Up @@ -200,17 +214,13 @@ def set_callbacks(self, app: dash.Dash) -> None:

# ---------------------------
def _get_wells_vectors_phases(
vector_names: list,
excl_name_startswith: Optional[list],
excl_name_contains: Optional[list],
vector_names: List[str],
excl_name_startswith: List[str],
excl_name_endswith: List[str],
excl_name_contains: List[str],
) -> Tuple[List, List, List]:
"""Return lists of wells, vectors and phases."""

if excl_name_startswith is None:
excl_name_startswith = []
if excl_name_contains is None:
excl_name_contains = []

wells, vectors, drop_list = [], [], []
phases = set()

Expand All @@ -225,13 +235,13 @@ def _get_wells_vectors_phases(
continue

well = vector.split(":")[1]
if well.startswith(tuple(excl_name_startswith)):

if _skip_well(
well, excl_name_startswith, excl_name_endswith, excl_name_contains
):
drop_list.append(well)
continue
for excl in excl_name_contains:
if excl in well:
drop_list.append(well)
continue

if well not in wells:
wells.append(well)
if vector not in vectors:
Expand All @@ -255,6 +265,24 @@ def _get_wells_vectors_phases(
return wells, vectors, list(phases)


def _skip_well(
well: str,
excl_name_startswith: List[str],
excl_name_endswith: List[str],
excl_name_contains: List[str],
) -> bool:
"""Check well name against exclude strings and return True if it should be skipped."""

if well.startswith(tuple(excl_name_startswith)):
return True
if well.endswith(tuple(excl_name_endswith)):
return True
for excl in excl_name_contains:
if excl in well:
return True
return False


# --------------------------------
def _get_well_collections_from_attr(
wells: dict,
Expand Down