Skip to content

Commit c7b388a

Browse files
CO2Leakage: Add support for residual trapping and AMFG migration time (#1295)
* CO2Leakage: Add support for residual trapping. Add support for AMFG migration time. Plus other improvements. * Black fix * Bug fix * CO2Leakage: Update changelog.md * Temp update links in subsurface.yml * New update subsurface.yml, hack to test PR * Update subsurface.yml, use standard fork name again * Remove a comment as hack to rerun tests * Revert temp changes in subsurface.yml --------- Co-authored-by: AudunSektnanNR <sek@nr.no> Co-authored-by: Audun Sektnan <99661468+AudunSektnanNR@users.noreply.github.com>
1 parent 784e462 commit c7b388a

File tree

8 files changed

+391
-573
lines changed

8 files changed

+391
-573
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
### Added
1212
- [#1293](https://github.com/equinor/webviz-subsurface/pull/1293) - Added automatic calculation of `STOIIP_TOTAL` / `GIIP_TOTAL` in `VolumetricAnalysis`.
1313

14+
### Changed
15+
- [#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.
16+
1417
### Fixed
1518
- [#1287](https://github.com/equinor/webviz-subsurface/pull/1287) - Fixed bug when grouping on FACIES for non-standard static sources.
1619

webviz_subsurface/plugins/_co2_leakage/_plugin.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
)
3636
from webviz_subsurface.plugins._co2_leakage._utilities.initialization import (
3737
init_map_attribute_names,
38+
init_menu_options,
3839
init_surface_providers,
3940
init_table_provider,
4041
init_well_pick_provider,
41-
init_zone_and_region_options,
4242
process_files,
4343
)
4444
from webviz_subsurface.plugins._co2_leakage.views.mainview.mainview import (
@@ -166,12 +166,13 @@ def __init__(
166166
well_pick_dict,
167167
map_surface_names_to_well_pick_names,
168168
)
169-
# Zone and region options
170-
self._zone_and_region_options = init_zone_and_region_options(
169+
# Phase (in case of residual trapping), zone and region options
170+
self._menu_options = init_menu_options(
171171
ensemble_paths,
172172
self._co2_table_providers,
173173
self._co2_actual_volume_table_providers,
174-
self._co2_table_providers,
174+
plume_mass_relpath,
175+
plume_actual_volume_relpath,
175176
)
176177
except Exception as err:
177178
self._error_message = f"Plugin initialization failed: {err}"
@@ -197,7 +198,7 @@ def __init__(
197198
self._map_attribute_names,
198199
[c["name"] for c in self._color_tables], # type: ignore
199200
self._well_pick_names,
200-
self._zone_and_region_options,
201+
self._menu_options,
201202
),
202203
self.Ids.MAIN_SETTINGS,
203204
)
@@ -286,7 +287,7 @@ def update_graphs(
286287
color_choice,
287288
mark_choice,
288289
sorting,
289-
self._zone_and_region_options[ensemble][source],
290+
self._menu_options[ensemble][source],
290291
)
291292
if source in [
292293
GraphSource.CONTAINMENT_MASS,
@@ -359,7 +360,10 @@ def set_dates(ensemble: str) -> Tuple[Dict[int, Dict[str, Any]], Optional[int]]:
359360
Input(self._settings_component(ViewSettings.Ids.PROPERTY), "value"),
360361
)
361362
def toggle_date_slider(attribute: str) -> Dict[str, str]:
362-
if MapAttribute(attribute) == MapAttribute.MIGRATION_TIME:
363+
if MapAttribute(attribute) in [
364+
MapAttribute.MIGRATION_TIME_SGAS,
365+
MapAttribute.MIGRATION_TIME_AMFG,
366+
]:
363367
return {"display": "none"}
364368
return {}
365369

@@ -511,7 +515,6 @@ def update_map_attribute(
511515
self._summed_co2,
512516
self._visualization_info["unit"],
513517
)
514-
# Plume polygon
515518
plume_polygon = None
516519
if contour_data is not None:
517520
plume_polygon = get_plume_polygon(

webviz_subsurface/plugins/_co2_leakage/_utilities/callbacks.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def property_origin(
5656
return map_attribute_names[MapAttribute.MAX_SGAS]
5757
if attribute == MapAttribute.AMFG_PLUME:
5858
return map_attribute_names[MapAttribute.MAX_AMFG]
59-
raise AssertionError(f"No origin defined for property: {attribute}")
59+
raise AssertionError(f"Map attribute name not found for property: {attribute}")
6060

6161

6262
@dataclass
@@ -86,7 +86,9 @@ def from_server(
8686
visualization_info,
8787
map_attribute_names,
8888
)
89-
assert surf_meta is not None # Should not occur
89+
if surf_meta is None: # Surface file does not exist
90+
return None, None
91+
assert isinstance(img_url, str)
9092
value_range = (
9193
0.0 if np.ma.is_masked(surf_meta.val_min) else surf_meta.val_min,
9294
0.0 if np.ma.is_masked(surf_meta.val_max) else surf_meta.val_max,
@@ -132,7 +134,15 @@ def derive_surface_address(
132134
threshold=contour_data["threshold"] if contour_data else 0.0,
133135
smoothing=contour_data["smoothing"] if contour_data else 0.0,
134136
)
135-
date = None if attribute == MapAttribute.MIGRATION_TIME else date
137+
date = (
138+
None
139+
if attribute
140+
in [
141+
MapAttribute.MIGRATION_TIME_SGAS,
142+
MapAttribute.MIGRATION_TIME_AMFG,
143+
]
144+
else date
145+
)
136146
if len(realization) == 1:
137147
return SimulatedSurfaceAddress(
138148
attribute=map_attribute_names[attribute],
@@ -151,7 +161,10 @@ def derive_surface_address(
151161

152162
def readable_name(attribute: MapAttribute) -> str:
153163
unit = ""
154-
if attribute == MapAttribute.MIGRATION_TIME:
164+
if attribute in [
165+
MapAttribute.MIGRATION_TIME_SGAS,
166+
MapAttribute.MIGRATION_TIME_AMFG,
167+
]:
155168
unit = " [year]"
156169
elif attribute in (MapAttribute.AMFG_PLUME, MapAttribute.SGAS_PLUME):
157170
unit = " [# real.]"
@@ -198,7 +211,10 @@ def get_plume_polygon(
198211

199212

200213
def _find_legend_title(attribute: MapAttribute, unit: str) -> str:
201-
if attribute == MapAttribute.MIGRATION_TIME:
214+
if attribute in [
215+
MapAttribute.MIGRATION_TIME_SGAS,
216+
MapAttribute.MIGRATION_TIME_AMFG,
217+
]:
202218
return "years"
203219
if attribute in [MapAttribute.MASS, MapAttribute.DISSOLVED, MapAttribute.FREE]:
204220
return unit
@@ -497,18 +513,22 @@ def process_containment_info(
497513
color_choice: str,
498514
mark_choice: Optional[str],
499515
sorting: str,
500-
zone_and_region_options: Dict[str, List[str]],
516+
menu_options: Dict[str, List[str]],
501517
) -> Dict[str, Union[str, None, List[str], int]]:
502518
if mark_choice is None:
503519
mark_choice = "phase"
504-
zones = zone_and_region_options["zones"]
505-
regions = zone_and_region_options["regions"]
520+
zones = menu_options["zones"]
521+
regions = menu_options["regions"]
506522
if len(zones) > 0:
507523
zones = [zone_name for zone_name in zones if zone_name != "all"]
508524
if len(regions) > 0:
509525
regions = [reg_name for reg_name in regions if reg_name != "all"]
510526
containments = ["hazardous", "outside", "contained"]
511-
phases = ["gas", "aqueous"]
527+
phases = [phase for phase in menu_options["phases"] if phase != "total"]
528+
if "zone" in [mark_choice, color_choice]:
529+
region = "all"
530+
if "region" in [mark_choice, color_choice]:
531+
zone = "all"
512532
return {
513533
"zone": zone,
514534
"region": region,

0 commit comments

Comments
 (0)