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

WellLogViewer to WLF #1105

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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 webviz_subsurface/plugins/_new_well_log_viewer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .well_log import WellLogViewer
from .shared_settings import Filter
5 changes: 5 additions & 0 deletions webviz_subsurface/plugins/_new_well_log_viewer/_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dash import html


def error(error_message: str) -> html.Div:
return html.Div(children=error_message, style={"color": "red"})
11 changes: 11 additions & 0 deletions webviz_subsurface/plugins/_new_well_log_viewer/_plugin_ids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class PluginIds:
class Stores:
WELL = "well"
LOG_TEMPLATE = "log-template"

class SharedSettings:
FILTER = "filter"

class WellLogViewerID:
GROUP_NAME = "Well Log Viewer"
INDICATORS = "well-log-indicators"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._filter import Filter
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from typing import List

from dash import callback, Input, Output
from dash.development.base_component import Component

from webviz_config.webviz_plugin_subclasses import SettingsGroupABC
from webviz_core_components import SelectWithLabel

from .._plugin_ids import PluginIds


class Filter(SettingsGroupABC):
class Ids:
# pylint: disable=too-few-public-methods

WELL_SELECT = "well-select"
LOG_SELECT = "log-select"

def __init__(self):
super().__init__("Filter")

# self.countries = population_df["Country Name"].drop_duplicates().to_list()
self.wells = ["well1", "well2", "well3"]
self.logs = ["All logs"]

def layout(self) -> List[Component]:
return [
SelectWithLabel(
id=self.register_component_unique_id(Filter.Ids.WELL_SELECT),
label="Well",
options=[{"label": i, "value": i} for i in self.wells],
value=[self.wells[0]],
multi=False,
size=min(15, len(self.wells)),
),
SelectWithLabel(
id=self.register_component_unique_id(Filter.Ids.LOG_SELECT),
label="Log template",
options=[{"label": i, "value": i} for i in self.logs],
value=[self.logs[0]],
multi=False,
size=min(15, len(self.logs)),
),
]

def set_callbacks(self) -> None:
@callback(
Output(self.get_store_unique_id(PluginIds.Stores.WELL), "data"),
Input(
self.component_unique_id(Filter.Ids.WELL_SELECT).to_string(), "value"
),
)
def _set_well(well: str) -> str:
return well

@callback(
Output(self.get_store_unique_id(PluginIds.Stores.LOG_TEMPLATE), "data"),
Input(self.component_unique_id(Filter.Ids.LOG_SELECT).to_string(), "value"),
)
def _set_log(log: str) -> str:
return log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._well_log_viewer import WellLogViewer
Original file line number Diff line number Diff line change
Expand Up @@ -4,84 +4,36 @@

import webviz_core_components as wcc
from dash import Dash, html
from webviz_config import WebvizPluginABC
from webviz_subsurface_components import WellLogViewer as WellLogViewerComponent
from webviz_config.webviz_plugin_subclasses import (
ViewABC,
ViewElementABC,
SettingsGroupABC,
)

from webviz_subsurface._models.well_set_model import WellSetModel
from webviz_subsurface._utils.webvizstore_functions import find_files, get_path

from dash import callback, Input, Output
import pandas as pd
import plotly.colors

from .._plugin_ids import PluginIds
from ..shared_settings._filter import Filter

from ._validate_log_templates import load_and_validate_log_templates
from .controllers import well_controller
from .utils.default_color_tables import default_color_tables
from .utils.xtgeo_well_log_to_json import xtgeo_well_logs_to_json_format
from typing import Any, Callable, Dict, Tuple

from dash import Dash, Input, Output

class WellLogViewer(WebvizPluginABC):
"""Uses [videx-welllog](https://github.com/equinor/videx-wellog) to visualize well logs
from files stored in RMS well format.

?> Currently tracks for visualizing discrete logs are not included. This will
be added in later releases.

---

* **`wellfolder`:** Path to a folder with well files stored in RMS well format.
* **`wellsuffix`:** File suffix of well files
* **`logtemplates`:** List of yaml based log template configurations. \
See the data section for description of the format.
* **`mdlog`:** Name of the md log. If not specified, MD will be calculated.
* **`well_tvdmin`:** Truncate well data values above this depth.
* **`well_tvdmax`:** Truncate well data values below this depth.
* **`well_downsample_interval`:** Sampling interval used for coarsening a well trajectory
* **`colortables`:** Color tables on json format. See https://git.io/JDLyb \
for an example file.
* **`initial_settings`:** Configuration for initializing the plugin with various \
properties set. All properties are optional.
See the data section for available properties.

---

?> The format and documentation of the log template configuration will be improved \
in later releases. A small configuration sample is provided below.
class WellLogViewer(ViewABC):
class Ids:
# pylint: disable=too-few-public-methods
WELL_LOG_VIEWER = "well-log-viewer"

```yaml
name: All logs # Name of the log template
scale:
primary: MD # Which reference track to visualize as default (MD/TVD)
allowSecondary: False # Set to True to show both MD and TVD reference tracks.
tracks: # The list of log tracks
- title: Porosity # Optional title of log track
plots: # List of which logs to include in the track
- name: PHIT # Upper case name of log
type: area # Type of visualiation (area, line, linestep, dot)
color: green # Color of log
- name: PHIT_ORIG
type: line
- plots:
- name: ZONE
type: area
- plots:
- name: FACIES
type: area
- plots:
- name: VSH
type: area
- plots:
- name: SW
type: dot
styles: # List of styles that can be added to tracks
```


Format of the `initial_settings` argument:
```yaml
initial_settings:
well: str # Name of well
logtemplate: str # Name of log template
```
"""

# pylint: disable=too-many-arguments
def __init__(
self,
app: Dash,
Expand All @@ -94,7 +46,7 @@ def __init__(
well_tvdmax: Union[int, float] = None,
well_downsample_interval: int = None,
initial_settings: Dict = None,
):
) -> None:

super().__init__()
self._wellfolder = wellfolder
Expand Down Expand Up @@ -126,7 +78,6 @@ def __init__(
self.initial_log_template = initial_settings.get(
"logtemplate", list(self._log_templates.keys())[0]
)
self.set_callbacks(app)

@property
def layout(self) -> html.Div:
Expand Down Expand Up @@ -175,23 +126,13 @@ def layout(self) -> html.Div:
]
)

def set_callbacks(self, app: Dash) -> None:
well_controller(
app=app,
well_set_model=self._well_set_model,
log_templates=self._log_templates,
get_uuid=self.uuid,
)

def add_webvizstore(self) -> List[Tuple[Callable, list]]:
store_functions = [
(find_files, [{"folder": self._wellfolder, "suffix": self._wellsuffix}])
]

store_functions.extend([(get_path, [{"path": fn}]) for fn in self._wellfiles])
store_functions.extend(
[(get_path, [{"path": fn}]) for fn in self._logtemplatefiles]
def set_callbacks(self) -> None:
@callback(
Output(self.get_store_unique_id(PluginIds.Stores.WELL), "data"),
Output(self.get_store_unique_id(PluginIds.Stores.LOG_TEMPLATE), "data"),
Input(self.get_store_unique_id(Filter.Ids.WELL_SELECT), "data"),
Input(self.get_store_unique_id(Filter.Ids.LOG_SELECT), "data"),
)
if self.colortable_file is not None:
store_functions.append((get_path, [{"path": self.colortable_file}]))
return store_functions
def _update_log_data(well_name: str, template: str) -> Tuple[Any, Any]:
well = WellSetModel.get_well(well_name)
return xtgeo_well_logs_to_json_format(well), Dict.get(template)
1 change: 0 additions & 1 deletion webviz_subsurface/plugins/_well_log_viewer/__init__.py

This file was deleted.

This file was deleted.

This file was deleted.