webviz-subsurface 0.2.39__py3-none-any.whl → 0.2.41__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- webviz_subsurface/_figures/timeseries_figure.py +1 -1
- webviz_subsurface/_providers/ensemble_summary_provider/_provider_impl_arrow_lazy.py +3 -1
- webviz_subsurface/_providers/ensemble_summary_provider/_provider_impl_arrow_presampled.py +3 -1
- webviz_subsurface/_providers/ensemble_table_provider/ensemble_table_provider_impl_arrow.py +3 -1
- webviz_subsurface/_utils/dataframe_utils.py +1 -1
- webviz_subsurface/_version.py +34 -0
- webviz_subsurface/plugins/_bhp_qc/views/_view_functions.py +5 -5
- webviz_subsurface/plugins/_co2_migration/__init__.py +1 -0
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_plugin.py +86 -46
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/callbacks.py +53 -30
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/co2volume.py +283 -40
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/color_tables.py +1 -1
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/containment_data_provider.py +6 -4
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/containment_info.py +6 -0
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/ensemble_well_picks.py +1 -1
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/generic.py +59 -6
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/initialization.py +73 -10
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/polygon_handler.py +1 -1
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/summary_graphs.py +20 -18
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/surface_publishing.py +18 -20
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/unsmry_data_provider.py +8 -8
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/views/mainview/mainview.py +98 -44
- webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/views/mainview/settings.py +7 -5
- webviz_subsurface/plugins/_disk_usage.py +19 -8
- webviz_subsurface/plugins/_line_plotter_fmu/controllers/build_figure.py +4 -4
- webviz_subsurface/plugins/_map_viewer_fmu/layout.py +2 -1
- webviz_subsurface/plugins/_map_viewer_fmu/map_viewer_fmu.py +1 -1
- webviz_subsurface/plugins/_parameter_analysis/_utils/_parameters_model.py +5 -5
- webviz_subsurface/plugins/_property_statistics/property_statistics.py +1 -1
- webviz_subsurface/plugins/_relative_permeability.py +6 -6
- webviz_subsurface/plugins/_reservoir_simulation_timeseries_regional.py +12 -12
- webviz_subsurface/plugins/_running_time_analysis_fmu.py +6 -1
- webviz_subsurface/plugins/_seismic_misfit.py +2 -3
- webviz_subsurface/plugins/_simulation_time_series/_views/_subplot_view/_utils/vector_statistics.py +4 -4
- webviz_subsurface/plugins/_structural_uncertainty/views/intersection_and_map.py +1 -1
- webviz_subsurface/plugins/_swatinit_qc/_business_logic.py +1 -1
- webviz_subsurface-0.2.41.dist-info/METADATA +822 -0
- {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info}/RECORD +51 -102
- {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info}/WHEEL +1 -1
- {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info}/entry_points.txt +1 -1
- {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info}/top_level.txt +0 -1
- tests/integration_tests/test_parameter_filter.py +0 -28
- tests/integration_tests/test_surface_selector.py +0 -53
- tests/unit_tests/abbreviations_tests/test_reservoir_simulation.py +0 -94
- tests/unit_tests/data_input/__init__.py +0 -0
- tests/unit_tests/data_input/test_calc_from_cumulatives.py +0 -178
- tests/unit_tests/data_input/test_image_processing.py +0 -11
- tests/unit_tests/mocks/__init__.py +0 -0
- tests/unit_tests/mocks/ensemble_summary_provider_dummy.py +0 -67
- tests/unit_tests/model_tests/__init__.py +0 -0
- tests/unit_tests/model_tests/test_ensemble_model.py +0 -176
- tests/unit_tests/model_tests/test_ensemble_set_model.py +0 -105
- tests/unit_tests/model_tests/test_gruptree_model.py +0 -89
- tests/unit_tests/model_tests/test_property_statistics_model.py +0 -42
- tests/unit_tests/model_tests/test_surface_set_model.py +0 -48
- tests/unit_tests/model_tests/test_well_attributes_model.py +0 -110
- tests/unit_tests/model_tests/test_well_set_model.py +0 -70
- tests/unit_tests/plugin_tests/__init__.py +0 -0
- tests/unit_tests/plugin_tests/test_grouptree.py +0 -175
- tests/unit_tests/plugin_tests/test_simulation_time_series/__init__.py +0 -0
- tests/unit_tests/plugin_tests/test_simulation_time_series/mocks/__init__.py +0 -0
- tests/unit_tests/plugin_tests/test_simulation_time_series/mocks/derived_vectors_accessor_ensemble_summary_provider_mock.py +0 -60
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/__init__.py +0 -0
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_create_vector_traces_utils.py +0 -530
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_dataframe_utils.py +0 -119
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_datetime_utils.py +0 -51
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_delta_ensemble_utils.py +0 -222
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_delta_ensemble_vectors_accessor_impl.py +0 -319
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_ensemble_vectors_accessor_impl.py +0 -271
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_ensemble_vectors_accessor_utils.py +0 -78
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_vector_accessor.py +0 -57
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_ensemble_summary_provider_set_utils.py +0 -213
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_from_timeseries_cumulatives.py +0 -322
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_history_vectors.py +0 -201
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_trace_line_shape.py +0 -56
- tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_vector_statistics.py +0 -171
- tests/unit_tests/plugin_tests/test_tornado_data.py +0 -130
- tests/unit_tests/plugin_tests/test_well_completions.py +0 -158
- tests/unit_tests/provider_tests/__init__.py +0 -0
- tests/unit_tests/provider_tests/test_ensemble_summary_provider.py +0 -255
- tests/unit_tests/provider_tests/test_ensemble_summary_provider_impl_arrow_lazy.py +0 -388
- tests/unit_tests/provider_tests/test_ensemble_summary_provider_impl_arrow_presampled.py +0 -160
- tests/unit_tests/provider_tests/test_ensemble_summary_provider_resampling.py +0 -320
- tests/unit_tests/provider_tests/test_ensemble_table_provider.py +0 -190
- tests/unit_tests/utils_tests/__init__.py +0 -0
- tests/unit_tests/utils_tests/test_dataframe_utils.py +0 -281
- tests/unit_tests/utils_tests/test_ensemble_summary_provider_set/__init__.py +0 -0
- tests/unit_tests/utils_tests/test_ensemble_summary_provider_set/test_ensemble_summary_provider_set.py +0 -306
- tests/unit_tests/utils_tests/test_formatting.py +0 -10
- tests/unit_tests/utils_tests/test_simulation_timeseries.py +0 -51
- webviz_subsurface/plugins/_co2_leakage/__init__.py +0 -1
- webviz_subsurface/plugins/_co2_leakage/_utilities/__init__.py +0 -0
- webviz_subsurface/plugins/_co2_leakage/views/__init__.py +0 -0
- webviz_subsurface/plugins/_co2_leakage/views/mainview/__init__.py +0 -0
- webviz_subsurface-0.2.39.dist-info/METADATA +0 -147
- /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_error.py +0 -0
- /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_types.py +0 -0
- {tests/integration_tests → webviz_subsurface/plugins/_co2_migration/_utilities}/__init__.py +0 -0
- /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/_misc.py +0 -0
- /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/fault_polygons_handler.py +0 -0
- /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/plume_extent.py +0 -0
- {tests/unit_tests → webviz_subsurface/plugins/_co2_migration/views}/__init__.py +0 -0
- {tests/unit_tests/abbreviations_tests → webviz_subsurface/plugins/_co2_migration/views/mainview}/__init__.py +0 -0
- {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info/licenses}/LICENSE +0 -0
- {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info/licenses}/LICENSE.chromedriver +0 -0
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
|
|
3
|
-
import pandas as pd
|
|
4
|
-
import pytest
|
|
5
|
-
from pandas._testing import assert_frame_equal
|
|
6
|
-
from webviz_subsurface_components.VectorCalculatorWrapper import (
|
|
7
|
-
ExpressionInfo,
|
|
8
|
-
VariableVectorMapInfo,
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
from webviz_subsurface._utils.dataframe_utils import make_date_column_datetime_object
|
|
12
|
-
|
|
13
|
-
# pylint: disable = line-too-long
|
|
14
|
-
from webviz_subsurface.plugins._simulation_time_series._views._subplot_view._utils.derived_vectors_accessor.derived_ensemble_vectors_accessor_impl import (
|
|
15
|
-
DerivedEnsembleVectorsAccessorImpl,
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
from ..mocks.derived_vectors_accessor_ensemble_summary_provider_mock import (
|
|
19
|
-
EnsembleSummaryProviderMock,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
# *******************************************************************
|
|
23
|
-
#####################################################################
|
|
24
|
-
#
|
|
25
|
-
# CONFIGURE TESTDATA
|
|
26
|
-
#
|
|
27
|
-
#####################################################################
|
|
28
|
-
# *******************************************************************
|
|
29
|
-
|
|
30
|
-
# fmt: off
|
|
31
|
-
INPUT_DF = pd.DataFrame(
|
|
32
|
-
columns = ["DATE", "REAL", "A", "B"],
|
|
33
|
-
data = [
|
|
34
|
-
[datetime.datetime(2000,1,1), 1, 1.0, 50.0 ],
|
|
35
|
-
[datetime.datetime(2000,2,1), 1, 2.0, 100.0 ],
|
|
36
|
-
[datetime.datetime(2000,3,1), 1, 3.0, 150.0 ],
|
|
37
|
-
[datetime.datetime(2000,1,1), 2, 6.0, 300.0 ],
|
|
38
|
-
[datetime.datetime(2000,2,1), 2, 7.0, 400.0 ],
|
|
39
|
-
[datetime.datetime(2000,3,1), 2, 8.0, 500.0 ],
|
|
40
|
-
[datetime.datetime(2000,1,1), 4, 11.0, 1000.0],
|
|
41
|
-
[datetime.datetime(2000,2,1), 4, 12.0, 1200.0],
|
|
42
|
-
[datetime.datetime(2000,3,1), 4, 13.0, 1400.0],
|
|
43
|
-
]
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
# PER_INTVL_ calc for col "B" input df
|
|
47
|
-
EXPECTED_PER_INTVL_DF = pd.DataFrame(
|
|
48
|
-
columns = ["DATE", "REAL", "PER_INTVL_B"],
|
|
49
|
-
data = [
|
|
50
|
-
[datetime.datetime(2000,1,1), 1, 50.0 ],
|
|
51
|
-
[datetime.datetime(2000,2,1), 1, 50.0 ],
|
|
52
|
-
[datetime.datetime(2000,3,1), 1, 0.0 ],
|
|
53
|
-
[datetime.datetime(2000,1,1), 2, 100.0],
|
|
54
|
-
[datetime.datetime(2000,2,1), 2, 100.0],
|
|
55
|
-
[datetime.datetime(2000,3,1), 2, 0.0 ],
|
|
56
|
-
[datetime.datetime(2000,1,1), 4, 200.0],
|
|
57
|
-
[datetime.datetime(2000,2,1), 4, 200.0],
|
|
58
|
-
[datetime.datetime(2000,3,1), 4, 0.0 ],
|
|
59
|
-
]
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
# Sum of col "A" and "B" in input df
|
|
63
|
-
EXPECTED_SUM_A_AND_B_DF = pd.DataFrame(
|
|
64
|
-
columns = ["DATE", "REAL", "Sum A and B"],
|
|
65
|
-
data = [
|
|
66
|
-
[datetime.datetime(2000,1,1), 1, 51.0 ],
|
|
67
|
-
[datetime.datetime(2000,2,1), 1, 102.0 ],
|
|
68
|
-
[datetime.datetime(2000,3,1), 1, 153.0 ],
|
|
69
|
-
[datetime.datetime(2000,1,1), 2, 306.0 ],
|
|
70
|
-
[datetime.datetime(2000,2,1), 2, 407.0 ],
|
|
71
|
-
[datetime.datetime(2000,3,1), 2, 508.0 ],
|
|
72
|
-
[datetime.datetime(2000,1,1), 4, 1011.0],
|
|
73
|
-
[datetime.datetime(2000,2,1), 4, 1212.0],
|
|
74
|
-
[datetime.datetime(2000,3,1), 4, 1413.0],
|
|
75
|
-
]
|
|
76
|
-
)
|
|
77
|
-
make_date_column_datetime_object(INPUT_DF)
|
|
78
|
-
make_date_column_datetime_object(EXPECTED_PER_INTVL_DF)
|
|
79
|
-
make_date_column_datetime_object(EXPECTED_SUM_A_AND_B_DF)
|
|
80
|
-
|
|
81
|
-
# Dates AFTER year 2262!
|
|
82
|
-
AFTER_2262_DATES = pd.Series(
|
|
83
|
-
[
|
|
84
|
-
datetime.datetime(2265,1,1),
|
|
85
|
-
datetime.datetime(2265,2,1),
|
|
86
|
-
datetime.datetime(2265,3,1),
|
|
87
|
-
datetime.datetime(2265,1,1),
|
|
88
|
-
datetime.datetime(2265,2,1),
|
|
89
|
-
datetime.datetime(2265,3,1),
|
|
90
|
-
datetime.datetime(2265,1,1),
|
|
91
|
-
datetime.datetime(2265,2,1),
|
|
92
|
-
datetime.datetime(2265,3,1),
|
|
93
|
-
]
|
|
94
|
-
)
|
|
95
|
-
# NOTE: datetime.datetime after year 2262 is not converted to pd.Timestamp, thus
|
|
96
|
-
# no need to make date column datetime object
|
|
97
|
-
INPUT_AFTER_2262_DF = INPUT_DF.copy()
|
|
98
|
-
INPUT_AFTER_2262_DF["DATE"] = AFTER_2262_DATES
|
|
99
|
-
EXPECTED_INVTL_AFTER_2262_DF = EXPECTED_PER_INTVL_DF.copy()
|
|
100
|
-
EXPECTED_INVTL_AFTER_2262_DF["DATE"] = AFTER_2262_DATES
|
|
101
|
-
EXPECTED_SUM_A_AND_B_AFTER_2262_DF = EXPECTED_SUM_A_AND_B_DF.copy()
|
|
102
|
-
EXPECTED_SUM_A_AND_B_AFTER_2262_DF["DATE"] = AFTER_2262_DATES
|
|
103
|
-
|
|
104
|
-
# fmt: on
|
|
105
|
-
TEST_EXPRESSION = ExpressionInfo(
|
|
106
|
-
name="Sum A and B",
|
|
107
|
-
expression="x+y",
|
|
108
|
-
id="TestId",
|
|
109
|
-
variableVectorMap=[
|
|
110
|
-
VariableVectorMapInfo(variableName="x", vectorName=["A"]),
|
|
111
|
-
VariableVectorMapInfo(variableName="y", vectorName=["B"]),
|
|
112
|
-
],
|
|
113
|
-
isValid=True,
|
|
114
|
-
isDeletable=False,
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
TEST_ACCESSOR = DerivedEnsembleVectorsAccessorImpl(
|
|
118
|
-
name="Test accessor",
|
|
119
|
-
provider=EnsembleSummaryProviderMock(INPUT_DF),
|
|
120
|
-
vectors=["A", "B", "PER_INTVL_B", "Sum A and B"],
|
|
121
|
-
expressions=[TEST_EXPRESSION],
|
|
122
|
-
resampling_frequency=None,
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
TEST_AFTER_2262_ACCESSOR = DerivedEnsembleVectorsAccessorImpl(
|
|
126
|
-
name="Test after 2262 accessor",
|
|
127
|
-
provider=EnsembleSummaryProviderMock(INPUT_AFTER_2262_DF),
|
|
128
|
-
vectors=["A", "B", "PER_INTVL_B", "Sum A and B"],
|
|
129
|
-
expressions=[TEST_EXPRESSION],
|
|
130
|
-
resampling_frequency=None,
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
TEST_EMPTY_ACCESSOR = DerivedEnsembleVectorsAccessorImpl(
|
|
134
|
-
name="Empty provider accessor",
|
|
135
|
-
provider=EnsembleSummaryProviderMock(pd.DataFrame()),
|
|
136
|
-
vectors=["A", "B", "PER_INTVL_B", "Sum A and B"],
|
|
137
|
-
expressions=None,
|
|
138
|
-
resampling_frequency=None,
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
# *******************************************************************
|
|
143
|
-
#####################################################################
|
|
144
|
-
#
|
|
145
|
-
# UNIT TESTS
|
|
146
|
-
#
|
|
147
|
-
#####################################################################
|
|
148
|
-
# *******************************************************************
|
|
149
|
-
|
|
150
|
-
TEST_STATUS_CASES = [
|
|
151
|
-
pytest.param(TEST_ACCESSOR, True),
|
|
152
|
-
pytest.param(TEST_AFTER_2262_ACCESSOR, True),
|
|
153
|
-
pytest.param(TEST_EMPTY_ACCESSOR, False),
|
|
154
|
-
]
|
|
155
|
-
TEST_GET_VECTOR_CASES = [
|
|
156
|
-
pytest.param(TEST_ACCESSOR, INPUT_DF),
|
|
157
|
-
pytest.param(TEST_AFTER_2262_ACCESSOR, INPUT_AFTER_2262_DF),
|
|
158
|
-
]
|
|
159
|
-
TEST_CREATE_PER_INTVL_PER_DAY_VECTOR_CASES = [
|
|
160
|
-
pytest.param(TEST_ACCESSOR, EXPECTED_PER_INTVL_DF),
|
|
161
|
-
pytest.param(TEST_AFTER_2262_ACCESSOR, EXPECTED_INVTL_AFTER_2262_DF),
|
|
162
|
-
]
|
|
163
|
-
TEST_CREATE_CALCULATED_VECTOR_CASES = [
|
|
164
|
-
pytest.param(TEST_ACCESSOR, EXPECTED_SUM_A_AND_B_DF),
|
|
165
|
-
pytest.param(TEST_AFTER_2262_ACCESSOR, EXPECTED_SUM_A_AND_B_AFTER_2262_DF),
|
|
166
|
-
]
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
@pytest.mark.parametrize("test_accessor, expected_state", TEST_STATUS_CASES)
|
|
170
|
-
def test_has_provider_vectors(
|
|
171
|
-
test_accessor: DerivedEnsembleVectorsAccessorImpl, expected_state: bool
|
|
172
|
-
) -> None:
|
|
173
|
-
assert test_accessor.has_provider_vectors() == expected_state
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
@pytest.mark.parametrize("test_accessor, expected_state", TEST_STATUS_CASES)
|
|
177
|
-
def test_has_per_interval_and_per_day_vectors(
|
|
178
|
-
test_accessor: DerivedEnsembleVectorsAccessorImpl, expected_state: bool
|
|
179
|
-
) -> None:
|
|
180
|
-
assert test_accessor.has_per_interval_and_per_day_vectors() == expected_state
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
@pytest.mark.parametrize("test_accessor, expected_state", TEST_STATUS_CASES)
|
|
184
|
-
def test_has_vector_calculator_expressions(
|
|
185
|
-
test_accessor: DerivedEnsembleVectorsAccessorImpl, expected_state: bool
|
|
186
|
-
) -> None:
|
|
187
|
-
assert test_accessor.has_vector_calculator_expressions() == expected_state
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
@pytest.mark.parametrize("test_accessor, expected_df", TEST_GET_VECTOR_CASES)
|
|
191
|
-
def test_get_provider_vectors(
|
|
192
|
-
test_accessor: DerivedEnsembleVectorsAccessorImpl, expected_df: pd.DataFrame
|
|
193
|
-
) -> None:
|
|
194
|
-
assert_frame_equal(expected_df, test_accessor.get_provider_vectors_df())
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
@pytest.mark.parametrize("test_accessor, expected_df", TEST_GET_VECTOR_CASES)
|
|
198
|
-
def test_get_provider_vectors_filter_realizations(
|
|
199
|
-
test_accessor: DerivedEnsembleVectorsAccessorImpl, expected_df: pd.DataFrame
|
|
200
|
-
) -> None:
|
|
201
|
-
# Filter realizations
|
|
202
|
-
expected_reals_df = (
|
|
203
|
-
expected_df.loc[expected_df["REAL"].isin([1, 4])]
|
|
204
|
-
.reset_index()
|
|
205
|
-
.drop("index", axis=1)
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
test_df = test_accessor.get_provider_vectors_df(realizations=[1, 4])
|
|
209
|
-
|
|
210
|
-
assert_frame_equal(expected_reals_df, test_df)
|
|
211
|
-
assert list(set(test_df["REAL"].values)) == [1, 4]
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
@pytest.mark.parametrize(
|
|
215
|
-
"test_accessor, expected_df", TEST_CREATE_PER_INTVL_PER_DAY_VECTOR_CASES
|
|
216
|
-
)
|
|
217
|
-
def test_create_per_interval_and_per_day_vectors_df(
|
|
218
|
-
test_accessor: DerivedEnsembleVectorsAccessorImpl, expected_df: pd.DataFrame
|
|
219
|
-
) -> None:
|
|
220
|
-
assert_frame_equal(
|
|
221
|
-
expected_df, test_accessor.create_per_interval_and_per_day_vectors_df()
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
@pytest.mark.parametrize(
|
|
226
|
-
"test_accessor, expected_df", TEST_CREATE_PER_INTVL_PER_DAY_VECTOR_CASES
|
|
227
|
-
)
|
|
228
|
-
def test_create_per_interval_and_per_day_vectors_df_filter_realizations(
|
|
229
|
-
test_accessor: DerivedEnsembleVectorsAccessorImpl, expected_df: pd.DataFrame
|
|
230
|
-
) -> None:
|
|
231
|
-
# Filter realizations
|
|
232
|
-
expected_reals_df = (
|
|
233
|
-
expected_df.loc[expected_df["REAL"].isin([1, 2])]
|
|
234
|
-
.reset_index()
|
|
235
|
-
.drop("index", axis=1)
|
|
236
|
-
)
|
|
237
|
-
|
|
238
|
-
test_df = test_accessor.create_per_interval_and_per_day_vectors_df(
|
|
239
|
-
realizations=[1, 2]
|
|
240
|
-
)
|
|
241
|
-
|
|
242
|
-
assert_frame_equal(expected_reals_df, test_df)
|
|
243
|
-
assert list(set(test_df["REAL"].values)) == [1, 2]
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
@pytest.mark.parametrize(
|
|
247
|
-
"test_accessor, expected_df", TEST_CREATE_CALCULATED_VECTOR_CASES
|
|
248
|
-
)
|
|
249
|
-
def test_create_calculated_vectors_df(
|
|
250
|
-
test_accessor: DerivedEnsembleVectorsAccessorImpl, expected_df: pd.DataFrame
|
|
251
|
-
) -> None:
|
|
252
|
-
assert_frame_equal(expected_df, test_accessor.create_calculated_vectors_df())
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
@pytest.mark.parametrize(
|
|
256
|
-
"test_accessor, expected_df", TEST_CREATE_CALCULATED_VECTOR_CASES
|
|
257
|
-
)
|
|
258
|
-
def test_create_calculated_vectors_df_filter_realizations(
|
|
259
|
-
test_accessor: DerivedEnsembleVectorsAccessorImpl, expected_df: pd.DataFrame
|
|
260
|
-
) -> None:
|
|
261
|
-
# Filter realizations
|
|
262
|
-
expected_reals_df = (
|
|
263
|
-
expected_df.loc[expected_df["REAL"].isin([2, 4])]
|
|
264
|
-
.reset_index()
|
|
265
|
-
.drop("index", axis=1)
|
|
266
|
-
)
|
|
267
|
-
|
|
268
|
-
test_df = test_accessor.create_calculated_vectors_df(realizations=[2, 4])
|
|
269
|
-
|
|
270
|
-
assert_frame_equal(expected_reals_df, test_df)
|
|
271
|
-
assert list(set(test_df["REAL"].values)) == [2, 4]
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
from typing import Dict, List
|
|
2
|
-
|
|
3
|
-
import pandas as pd
|
|
4
|
-
|
|
5
|
-
from webviz_subsurface._utils.ensemble_summary_provider_set import (
|
|
6
|
-
EnsembleSummaryProviderSet,
|
|
7
|
-
)
|
|
8
|
-
from webviz_subsurface.plugins._simulation_time_series._views._subplot_view._types import (
|
|
9
|
-
DeltaEnsemble,
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
# pylint: disable = line-too-long
|
|
13
|
-
from webviz_subsurface.plugins._simulation_time_series._views._subplot_view._utils.derived_ensemble_vectors_accessor_utils import (
|
|
14
|
-
create_derived_vectors_accessor_dict,
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
# pylint: disable = line-too-long
|
|
18
|
-
from webviz_subsurface.plugins._simulation_time_series._views._subplot_view._utils.derived_vectors_accessor.derived_delta_ensemble_vectors_accessor_impl import (
|
|
19
|
-
DerivedDeltaEnsembleVectorsAccessorImpl,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
# pylint: disable = line-too-long
|
|
23
|
-
from webviz_subsurface.plugins._simulation_time_series._views._subplot_view._utils.derived_vectors_accessor.derived_ensemble_vectors_accessor_impl import (
|
|
24
|
-
DerivedEnsembleVectorsAccessorImpl,
|
|
25
|
-
)
|
|
26
|
-
from webviz_subsurface.plugins._simulation_time_series._views._subplot_view._utils.derived_vectors_accessor.derived_vectors_accessor import (
|
|
27
|
-
DerivedVectorsAccessor,
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
from ..mocks.derived_vectors_accessor_ensemble_summary_provider_mock import (
|
|
31
|
-
EnsembleSummaryProviderMock,
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def test_create_derived_vectors_accessor_dict() -> None:
|
|
36
|
-
ensembles = ["ensA", "ensB", "(ensA)-(ensB)", "(ensC)-(ensA)"]
|
|
37
|
-
vectors = ["vector_1", "vector_2"]
|
|
38
|
-
provider_set = EnsembleSummaryProviderSet(
|
|
39
|
-
{
|
|
40
|
-
"ensA": EnsembleSummaryProviderMock(pd.DataFrame()),
|
|
41
|
-
"ensB": EnsembleSummaryProviderMock(pd.DataFrame()),
|
|
42
|
-
"ensC": EnsembleSummaryProviderMock(pd.DataFrame()),
|
|
43
|
-
}
|
|
44
|
-
)
|
|
45
|
-
delta_ensembles: List[DeltaEnsemble] = [
|
|
46
|
-
DeltaEnsemble(ensemble_a="ensA", ensemble_b="ensB"),
|
|
47
|
-
DeltaEnsemble(ensemble_a="ensC", ensemble_b="ensA"),
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
created_result: Dict[
|
|
51
|
-
str, DerivedVectorsAccessor
|
|
52
|
-
] = create_derived_vectors_accessor_dict(
|
|
53
|
-
ensembles=ensembles,
|
|
54
|
-
vectors=vectors,
|
|
55
|
-
provider_set=provider_set,
|
|
56
|
-
expressions=[],
|
|
57
|
-
delta_ensembles=delta_ensembles,
|
|
58
|
-
resampling_frequency=None,
|
|
59
|
-
relative_date=None,
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
assert len(created_result) == len(ensembles)
|
|
63
|
-
|
|
64
|
-
assert created_result.get("ensA", None) is not None
|
|
65
|
-
assert isinstance(created_result["ensA"], DerivedEnsembleVectorsAccessorImpl)
|
|
66
|
-
|
|
67
|
-
assert created_result.get("ensB", None) is not None
|
|
68
|
-
assert isinstance(created_result["ensB"], DerivedEnsembleVectorsAccessorImpl)
|
|
69
|
-
|
|
70
|
-
assert created_result.get("(ensA)-(ensB)", None) is not None
|
|
71
|
-
assert isinstance(
|
|
72
|
-
created_result["(ensA)-(ensB)"], DerivedDeltaEnsembleVectorsAccessorImpl
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
assert created_result.get("(ensC)-(ensA)", None) is not None
|
|
76
|
-
assert isinstance(
|
|
77
|
-
created_result["(ensC)-(ensA)"], DerivedDeltaEnsembleVectorsAccessorImpl
|
|
78
|
-
)
|
tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_vector_accessor.py
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
from typing import Optional, Sequence
|
|
2
|
-
|
|
3
|
-
import pandas as pd
|
|
4
|
-
|
|
5
|
-
# pylint: disable=line-too-long
|
|
6
|
-
from webviz_subsurface.plugins._simulation_time_series._views._subplot_view._utils.derived_vectors_accessor.derived_vectors_accessor import (
|
|
7
|
-
DerivedVectorsAccessor,
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class DerivedVectorsAccessorMock(DerivedVectorsAccessor):
|
|
12
|
-
#####################################################e
|
|
13
|
-
#
|
|
14
|
-
# Interface methods raise NotImplementedError
|
|
15
|
-
#
|
|
16
|
-
#####################################################
|
|
17
|
-
|
|
18
|
-
def has_provider_vectors(self) -> bool:
|
|
19
|
-
raise NotImplementedError("Method not implemented for mock!")
|
|
20
|
-
|
|
21
|
-
def has_per_interval_and_per_day_vectors(self) -> bool:
|
|
22
|
-
raise NotImplementedError("Method not implemented for mock!")
|
|
23
|
-
|
|
24
|
-
def has_vector_calculator_expressions(self) -> bool:
|
|
25
|
-
raise NotImplementedError("Method not implemented for mock!")
|
|
26
|
-
|
|
27
|
-
def get_provider_vectors_df(
|
|
28
|
-
self, realizations: Optional[Sequence[int]] = None
|
|
29
|
-
) -> pd.DataFrame:
|
|
30
|
-
raise NotImplementedError("Method not implemented for mock!")
|
|
31
|
-
|
|
32
|
-
def create_per_interval_and_per_day_vectors_df(
|
|
33
|
-
self, realizations: Optional[Sequence[int]] = None
|
|
34
|
-
) -> pd.DataFrame:
|
|
35
|
-
raise NotImplementedError("Method not implemented for mock!")
|
|
36
|
-
|
|
37
|
-
def create_calculated_vectors_df(
|
|
38
|
-
self, realizations: Optional[Sequence[int]] = None
|
|
39
|
-
) -> pd.DataFrame:
|
|
40
|
-
raise NotImplementedError("Method not implemented for mock!")
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def test_create_valid_realizations_query() -> None:
|
|
44
|
-
realizations = [2, 3, 4, 6, 7, 8]
|
|
45
|
-
test_accessor = DerivedVectorsAccessorMock(accessor_realizations=realizations)
|
|
46
|
-
|
|
47
|
-
# Filter query (get valid realization numbers)
|
|
48
|
-
assert test_accessor.create_valid_realizations_query([1, 2, 3]) == [2, 3]
|
|
49
|
-
assert test_accessor.create_valid_realizations_query([3, 4, 5, 6]) == [3, 4, 6]
|
|
50
|
-
assert test_accessor.create_valid_realizations_query([3, 2, 7, 6]) == [3, 2, 7, 6]
|
|
51
|
-
assert test_accessor.create_valid_realizations_query([1, 5]) == []
|
|
52
|
-
|
|
53
|
-
# When all realizations are selected -> no filter, i.e. None
|
|
54
|
-
assert test_accessor.create_valid_realizations_query(realizations) is None
|
|
55
|
-
assert (
|
|
56
|
-
test_accessor.create_valid_realizations_query([1, 2, 3, 4, 5, 6, 7, 8]) is None
|
|
57
|
-
)
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
from typing import List, Optional
|
|
2
|
-
|
|
3
|
-
from webviz_subsurface_components import (
|
|
4
|
-
ExpressionInfo,
|
|
5
|
-
VariableVectorMapInfo,
|
|
6
|
-
VectorDefinition,
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
from webviz_subsurface._providers import VectorMetadata
|
|
10
|
-
from webviz_subsurface._utils.ensemble_summary_provider_set import (
|
|
11
|
-
EnsembleSummaryProviderSet,
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
# pylint: disable=line-too-long
|
|
15
|
-
from webviz_subsurface.plugins._simulation_time_series._views._subplot_view._utils.ensemble_summary_provider_set_utils import (
|
|
16
|
-
create_calculated_unit_from_provider_set,
|
|
17
|
-
create_vector_plot_titles_from_provider_set,
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
from ....mocks.ensemble_summary_provider_dummy import EnsembleSummaryProviderDummy
|
|
21
|
-
|
|
22
|
-
# *******************************************************************
|
|
23
|
-
#####################################################################
|
|
24
|
-
#
|
|
25
|
-
# CONFIGURE TESTDATA
|
|
26
|
-
#
|
|
27
|
-
#####################################################################
|
|
28
|
-
# *******************************************************************
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class EnsembleSummaryProviderMock(EnsembleSummaryProviderDummy):
|
|
32
|
-
"""Ensemble summary provider mock for testing
|
|
33
|
-
|
|
34
|
-
Note empty list returned in override methods, only to allow constructing
|
|
35
|
-
EnsembleSummaryProviderSet objects!
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
########################################
|
|
39
|
-
#
|
|
40
|
-
# Override methods
|
|
41
|
-
#
|
|
42
|
-
########################################
|
|
43
|
-
def vector_names(self) -> List[str]:
|
|
44
|
-
"""Return empty list only to allow constructing EnsembleSummaryProviderSet object"""
|
|
45
|
-
return ["FGIT", "WGOR:A1", "WBHP:A1", "WOPT:A1"]
|
|
46
|
-
|
|
47
|
-
def realizations(self) -> List[int]:
|
|
48
|
-
"""Return empty list only to allow constructing EnsembleSummaryProviderSet object"""
|
|
49
|
-
return []
|
|
50
|
-
|
|
51
|
-
def vector_metadata(self, vector_name: str) -> Optional[VectorMetadata]:
|
|
52
|
-
# NOTE: All vector names below must be defined in vector_names() method as well!
|
|
53
|
-
if vector_name == "FGIT":
|
|
54
|
-
return VectorMetadata(
|
|
55
|
-
unit="unit_1",
|
|
56
|
-
is_total=False,
|
|
57
|
-
is_rate=False,
|
|
58
|
-
is_historical=False,
|
|
59
|
-
keyword="FGIT",
|
|
60
|
-
wgname=None,
|
|
61
|
-
get_num=None,
|
|
62
|
-
)
|
|
63
|
-
if vector_name == "WGOR:A1":
|
|
64
|
-
return VectorMetadata(
|
|
65
|
-
unit="unit_2",
|
|
66
|
-
is_total=False,
|
|
67
|
-
is_rate=False,
|
|
68
|
-
is_historical=False,
|
|
69
|
-
keyword="A1",
|
|
70
|
-
wgname=None,
|
|
71
|
-
get_num=None,
|
|
72
|
-
)
|
|
73
|
-
if vector_name == "WBHP:A1":
|
|
74
|
-
return VectorMetadata(
|
|
75
|
-
unit="unit_3",
|
|
76
|
-
is_total=False,
|
|
77
|
-
is_rate=False,
|
|
78
|
-
is_historical=False,
|
|
79
|
-
keyword="A1",
|
|
80
|
-
wgname=None,
|
|
81
|
-
get_num=None,
|
|
82
|
-
)
|
|
83
|
-
if vector_name == "WOPT:A1":
|
|
84
|
-
return VectorMetadata(
|
|
85
|
-
unit="unit_4",
|
|
86
|
-
is_total=False,
|
|
87
|
-
is_rate=False,
|
|
88
|
-
is_historical=False,
|
|
89
|
-
keyword="A1",
|
|
90
|
-
wgname=None,
|
|
91
|
-
get_num=None,
|
|
92
|
-
)
|
|
93
|
-
return None
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
FIRST_TEST_EXPRESSION = ExpressionInfo(
|
|
97
|
-
name="First Expression",
|
|
98
|
-
expression="x+y",
|
|
99
|
-
id="FirstId",
|
|
100
|
-
variableVectorMap=[
|
|
101
|
-
VariableVectorMapInfo(variableName="x", vectorName=["FGIT"]),
|
|
102
|
-
VariableVectorMapInfo(variableName="y", vectorName=["WGOR:A1"]),
|
|
103
|
-
],
|
|
104
|
-
isValid=True,
|
|
105
|
-
isDeletable=False,
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
SECOND_TEST_EXPRESSION = ExpressionInfo(
|
|
109
|
-
name="Second Expression",
|
|
110
|
-
expression="x-y",
|
|
111
|
-
id="SecondId",
|
|
112
|
-
variableVectorMap=[
|
|
113
|
-
VariableVectorMapInfo(variableName="x", vectorName=["FGIT"]),
|
|
114
|
-
VariableVectorMapInfo(variableName="y", vectorName=["WBHP:A1"]),
|
|
115
|
-
],
|
|
116
|
-
isValid=True,
|
|
117
|
-
isDeletable=False,
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
THIRD_TEST_EXPRESSION = ExpressionInfo(
|
|
121
|
-
name="Third Expression",
|
|
122
|
-
expression="x/y",
|
|
123
|
-
id="ThirdId",
|
|
124
|
-
variableVectorMap=[
|
|
125
|
-
VariableVectorMapInfo(variableName="x", vectorName=["WBHP:A1"]),
|
|
126
|
-
VariableVectorMapInfo(variableName="y", vectorName=["WGOR:A1"]),
|
|
127
|
-
],
|
|
128
|
-
isValid=True,
|
|
129
|
-
isDeletable=False,
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
INVALID_TEST_EXPRESSION = ExpressionInfo(
|
|
133
|
-
name="Invalid Expression",
|
|
134
|
-
expression="invalid_function(x)", # Invalid function
|
|
135
|
-
id="InvalidId",
|
|
136
|
-
variableVectorMap=[
|
|
137
|
-
VariableVectorMapInfo(variableName="x", vectorName=["WBHP:A1"]),
|
|
138
|
-
],
|
|
139
|
-
isValid=True,
|
|
140
|
-
isDeletable=False,
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
TEST_PROVIDER_SET = EnsembleSummaryProviderSet(
|
|
144
|
-
{"First Provider": EnsembleSummaryProviderMock()}
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
# *******************************************************************
|
|
149
|
-
#####################################################################
|
|
150
|
-
#
|
|
151
|
-
# UNIT TESTS
|
|
152
|
-
#
|
|
153
|
-
#####################################################################
|
|
154
|
-
# *******************************************************************
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
def test_create_calculated_unit_from_provider_set() -> None:
|
|
158
|
-
assert (
|
|
159
|
-
create_calculated_unit_from_provider_set(
|
|
160
|
-
FIRST_TEST_EXPRESSION, TEST_PROVIDER_SET
|
|
161
|
-
)
|
|
162
|
-
== "unit_1+unit_2"
|
|
163
|
-
)
|
|
164
|
-
assert (
|
|
165
|
-
create_calculated_unit_from_provider_set(
|
|
166
|
-
SECOND_TEST_EXPRESSION, TEST_PROVIDER_SET
|
|
167
|
-
)
|
|
168
|
-
== "unit_1-unit_3"
|
|
169
|
-
)
|
|
170
|
-
assert (
|
|
171
|
-
create_calculated_unit_from_provider_set(
|
|
172
|
-
THIRD_TEST_EXPRESSION, TEST_PROVIDER_SET
|
|
173
|
-
)
|
|
174
|
-
== "unit_3/unit_2"
|
|
175
|
-
)
|
|
176
|
-
assert (
|
|
177
|
-
create_calculated_unit_from_provider_set(
|
|
178
|
-
INVALID_TEST_EXPRESSION, TEST_PROVIDER_SET
|
|
179
|
-
)
|
|
180
|
-
is None
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
def test_create_vector_plot_titles_from_provider_set() -> None:
|
|
185
|
-
vector_names = ["FGIT", "WGOR:A1", "PER_DAY_WOPT:A1", "First Expression"]
|
|
186
|
-
expressions = [FIRST_TEST_EXPRESSION]
|
|
187
|
-
|
|
188
|
-
# Test WITHOUT user defined vector definitions
|
|
189
|
-
expected_titles = {
|
|
190
|
-
"FGIT": "Gas Injection Total [unit_1]",
|
|
191
|
-
"WGOR:A1": "Gas-Oil Ratio, well A1 [unit_2]",
|
|
192
|
-
"PER_DAY_WOPT:A1": "Average Oil Production Total Per day, well A1 [unit_4/DAY]",
|
|
193
|
-
"First Expression": "First Expression [unit_1+unit_2]",
|
|
194
|
-
}
|
|
195
|
-
assert expected_titles == create_vector_plot_titles_from_provider_set(
|
|
196
|
-
vector_names, expressions, TEST_PROVIDER_SET, {}
|
|
197
|
-
)
|
|
198
|
-
|
|
199
|
-
# Test WITH user defined vector definitions
|
|
200
|
-
user_defined_definitions = {
|
|
201
|
-
"FGIT": VectorDefinition(description="First Test title", type="field"),
|
|
202
|
-
"WOPT": VectorDefinition(description="Second Test title", type="well"),
|
|
203
|
-
}
|
|
204
|
-
expected_titles = {
|
|
205
|
-
"FGIT": "First Test title [unit_1]",
|
|
206
|
-
"WGOR:A1": "Gas-Oil Ratio, well A1 [unit_2]",
|
|
207
|
-
"PER_DAY_WOPT:A1": "Average Second Test title Per day, well A1 [unit_4/DAY]",
|
|
208
|
-
"First Expression": "First Expression [unit_1+unit_2]",
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
assert expected_titles == create_vector_plot_titles_from_provider_set(
|
|
212
|
-
vector_names, expressions, TEST_PROVIDER_SET, user_defined_definitions
|
|
213
|
-
)
|