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

CO2Leakage: Add support for residual trapping and AMFG migration time #1295

Merged
merged 9 commits into from
Jun 26, 2024
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- [#1293](https://github.com/equinor/webviz-subsurface/pull/1293) - Added automatic calculation of `STOIIP_TOTAL` / `GIIP_TOTAL` in `VolumetricAnalysis`.

### Changed
- [#1295](https://github.com/equinor/webviz-subsurface/pull/1295) - CO2Leakage: Add support for residual trapping and AMFG migration time. Also changed input format of CSV-files. Various other minor improvements.

### Fixed
- [#1287](https://github.com/equinor/webviz-subsurface/pull/1287) - Fixed bug when grouping on FACIES for non-standard static sources.

Expand Down
19 changes: 11 additions & 8 deletions webviz_subsurface/plugins/_co2_leakage/_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
)
from webviz_subsurface.plugins._co2_leakage._utilities.initialization import (
init_map_attribute_names,
init_menu_options,
init_surface_providers,
init_table_provider,
init_well_pick_provider,
init_zone_and_region_options,
process_files,
)
from webviz_subsurface.plugins._co2_leakage.views.mainview.mainview import (
Expand Down Expand Up @@ -166,12 +166,13 @@ def __init__(
well_pick_dict,
map_surface_names_to_well_pick_names,
)
# Zone and region options
self._zone_and_region_options = init_zone_and_region_options(
# Phase (in case of residual trapping), zone and region options
self._menu_options = init_menu_options(
ensemble_paths,
self._co2_table_providers,
self._co2_actual_volume_table_providers,
self._co2_table_providers,
plume_mass_relpath,
plume_actual_volume_relpath,
)
except Exception as err:
self._error_message = f"Plugin initialization failed: {err}"
Expand All @@ -197,7 +198,7 @@ def __init__(
self._map_attribute_names,
[c["name"] for c in self._color_tables], # type: ignore
self._well_pick_names,
self._zone_and_region_options,
self._menu_options,
),
self.Ids.MAIN_SETTINGS,
)
Expand Down Expand Up @@ -286,7 +287,7 @@ def update_graphs(
color_choice,
mark_choice,
sorting,
self._zone_and_region_options[ensemble][source],
self._menu_options[ensemble][source],
)
if source in [
GraphSource.CONTAINMENT_MASS,
Expand Down Expand Up @@ -359,7 +360,10 @@ def set_dates(ensemble: str) -> Tuple[Dict[int, Dict[str, Any]], Optional[int]]:
Input(self._settings_component(ViewSettings.Ids.PROPERTY), "value"),
)
def toggle_date_slider(attribute: str) -> Dict[str, str]:
if MapAttribute(attribute) == MapAttribute.MIGRATION_TIME:
if MapAttribute(attribute) in [
MapAttribute.MIGRATION_TIME_SGAS,
MapAttribute.MIGRATION_TIME_AMFG,
]:
return {"display": "none"}
return {}

Expand Down Expand Up @@ -511,7 +515,6 @@ def update_map_attribute(
self._summed_co2,
self._visualization_info["unit"],
)
# Plume polygon
plume_polygon = None
if contour_data is not None:
plume_polygon = get_plume_polygon(
Expand Down
38 changes: 29 additions & 9 deletions webviz_subsurface/plugins/_co2_leakage/_utilities/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def property_origin(
return map_attribute_names[MapAttribute.MAX_SGAS]
if attribute == MapAttribute.AMFG_PLUME:
return map_attribute_names[MapAttribute.MAX_AMFG]
raise AssertionError(f"No origin defined for property: {attribute}")
raise AssertionError(f"Map attribute name not found for property: {attribute}")


@dataclass
Expand Down Expand Up @@ -86,7 +86,9 @@ def from_server(
visualization_info,
map_attribute_names,
)
assert surf_meta is not None # Should not occur
if surf_meta is None: # Surface file does not exist
return None, None
assert isinstance(img_url, str)
value_range = (
0.0 if np.ma.is_masked(surf_meta.val_min) else surf_meta.val_min,
0.0 if np.ma.is_masked(surf_meta.val_max) else surf_meta.val_max,
Expand Down Expand Up @@ -132,7 +134,15 @@ def derive_surface_address(
threshold=contour_data["threshold"] if contour_data else 0.0,
smoothing=contour_data["smoothing"] if contour_data else 0.0,
)
date = None if attribute == MapAttribute.MIGRATION_TIME else date
date = (
None
if attribute
in [
MapAttribute.MIGRATION_TIME_SGAS,
MapAttribute.MIGRATION_TIME_AMFG,
]
else date
)
if len(realization) == 1:
return SimulatedSurfaceAddress(
attribute=map_attribute_names[attribute],
Expand All @@ -151,7 +161,10 @@ def derive_surface_address(

def readable_name(attribute: MapAttribute) -> str:
unit = ""
if attribute == MapAttribute.MIGRATION_TIME:
if attribute in [
MapAttribute.MIGRATION_TIME_SGAS,
MapAttribute.MIGRATION_TIME_AMFG,
]:
unit = " [year]"
elif attribute in (MapAttribute.AMFG_PLUME, MapAttribute.SGAS_PLUME):
unit = " [# real.]"
Expand Down Expand Up @@ -198,7 +211,10 @@ def get_plume_polygon(


def _find_legend_title(attribute: MapAttribute, unit: str) -> str:
if attribute == MapAttribute.MIGRATION_TIME:
if attribute in [
MapAttribute.MIGRATION_TIME_SGAS,
MapAttribute.MIGRATION_TIME_AMFG,
]:
return "years"
if attribute in [MapAttribute.MASS, MapAttribute.DISSOLVED, MapAttribute.FREE]:
return unit
Expand Down Expand Up @@ -497,18 +513,22 @@ def process_containment_info(
color_choice: str,
mark_choice: Optional[str],
sorting: str,
zone_and_region_options: Dict[str, List[str]],
menu_options: Dict[str, List[str]],
) -> Dict[str, Union[str, None, List[str], int]]:
if mark_choice is None:
mark_choice = "phase"
zones = zone_and_region_options["zones"]
regions = zone_and_region_options["regions"]
zones = menu_options["zones"]
regions = menu_options["regions"]
if len(zones) > 0:
zones = [zone_name for zone_name in zones if zone_name != "all"]
if len(regions) > 0:
regions = [reg_name for reg_name in regions if reg_name != "all"]
containments = ["hazardous", "outside", "contained"]
phases = ["gas", "aqueous"]
phases = [phase for phase in menu_options["phases"] if phase != "total"]
if "zone" in [mark_choice, color_choice]:
region = "all"
if "region" in [mark_choice, color_choice]:
zone = "all"
return {
"zone": zone,
"region": region,
Expand Down
Loading