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.
Files changed (105) hide show
  1. webviz_subsurface/_figures/timeseries_figure.py +1 -1
  2. webviz_subsurface/_providers/ensemble_summary_provider/_provider_impl_arrow_lazy.py +3 -1
  3. webviz_subsurface/_providers/ensemble_summary_provider/_provider_impl_arrow_presampled.py +3 -1
  4. webviz_subsurface/_providers/ensemble_table_provider/ensemble_table_provider_impl_arrow.py +3 -1
  5. webviz_subsurface/_utils/dataframe_utils.py +1 -1
  6. webviz_subsurface/_version.py +34 -0
  7. webviz_subsurface/plugins/_bhp_qc/views/_view_functions.py +5 -5
  8. webviz_subsurface/plugins/_co2_migration/__init__.py +1 -0
  9. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_plugin.py +86 -46
  10. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/callbacks.py +53 -30
  11. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/co2volume.py +283 -40
  12. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/color_tables.py +1 -1
  13. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/containment_data_provider.py +6 -4
  14. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/containment_info.py +6 -0
  15. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/ensemble_well_picks.py +1 -1
  16. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/generic.py +59 -6
  17. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/initialization.py +73 -10
  18. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/polygon_handler.py +1 -1
  19. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/summary_graphs.py +20 -18
  20. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/surface_publishing.py +18 -20
  21. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/unsmry_data_provider.py +8 -8
  22. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/views/mainview/mainview.py +98 -44
  23. webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/views/mainview/settings.py +7 -5
  24. webviz_subsurface/plugins/_disk_usage.py +19 -8
  25. webviz_subsurface/plugins/_line_plotter_fmu/controllers/build_figure.py +4 -4
  26. webviz_subsurface/plugins/_map_viewer_fmu/layout.py +2 -1
  27. webviz_subsurface/plugins/_map_viewer_fmu/map_viewer_fmu.py +1 -1
  28. webviz_subsurface/plugins/_parameter_analysis/_utils/_parameters_model.py +5 -5
  29. webviz_subsurface/plugins/_property_statistics/property_statistics.py +1 -1
  30. webviz_subsurface/plugins/_relative_permeability.py +6 -6
  31. webviz_subsurface/plugins/_reservoir_simulation_timeseries_regional.py +12 -12
  32. webviz_subsurface/plugins/_running_time_analysis_fmu.py +6 -1
  33. webviz_subsurface/plugins/_seismic_misfit.py +2 -3
  34. webviz_subsurface/plugins/_simulation_time_series/_views/_subplot_view/_utils/vector_statistics.py +4 -4
  35. webviz_subsurface/plugins/_structural_uncertainty/views/intersection_and_map.py +1 -1
  36. webviz_subsurface/plugins/_swatinit_qc/_business_logic.py +1 -1
  37. webviz_subsurface-0.2.41.dist-info/METADATA +822 -0
  38. {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info}/RECORD +51 -102
  39. {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info}/WHEEL +1 -1
  40. {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info}/entry_points.txt +1 -1
  41. {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info}/top_level.txt +0 -1
  42. tests/integration_tests/test_parameter_filter.py +0 -28
  43. tests/integration_tests/test_surface_selector.py +0 -53
  44. tests/unit_tests/abbreviations_tests/test_reservoir_simulation.py +0 -94
  45. tests/unit_tests/data_input/__init__.py +0 -0
  46. tests/unit_tests/data_input/test_calc_from_cumulatives.py +0 -178
  47. tests/unit_tests/data_input/test_image_processing.py +0 -11
  48. tests/unit_tests/mocks/__init__.py +0 -0
  49. tests/unit_tests/mocks/ensemble_summary_provider_dummy.py +0 -67
  50. tests/unit_tests/model_tests/__init__.py +0 -0
  51. tests/unit_tests/model_tests/test_ensemble_model.py +0 -176
  52. tests/unit_tests/model_tests/test_ensemble_set_model.py +0 -105
  53. tests/unit_tests/model_tests/test_gruptree_model.py +0 -89
  54. tests/unit_tests/model_tests/test_property_statistics_model.py +0 -42
  55. tests/unit_tests/model_tests/test_surface_set_model.py +0 -48
  56. tests/unit_tests/model_tests/test_well_attributes_model.py +0 -110
  57. tests/unit_tests/model_tests/test_well_set_model.py +0 -70
  58. tests/unit_tests/plugin_tests/__init__.py +0 -0
  59. tests/unit_tests/plugin_tests/test_grouptree.py +0 -175
  60. tests/unit_tests/plugin_tests/test_simulation_time_series/__init__.py +0 -0
  61. tests/unit_tests/plugin_tests/test_simulation_time_series/mocks/__init__.py +0 -0
  62. tests/unit_tests/plugin_tests/test_simulation_time_series/mocks/derived_vectors_accessor_ensemble_summary_provider_mock.py +0 -60
  63. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/__init__.py +0 -0
  64. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_create_vector_traces_utils.py +0 -530
  65. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_dataframe_utils.py +0 -119
  66. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_datetime_utils.py +0 -51
  67. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_delta_ensemble_utils.py +0 -222
  68. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_delta_ensemble_vectors_accessor_impl.py +0 -319
  69. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_ensemble_vectors_accessor_impl.py +0 -271
  70. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_ensemble_vectors_accessor_utils.py +0 -78
  71. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_derived_vector_accessor.py +0 -57
  72. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_ensemble_summary_provider_set_utils.py +0 -213
  73. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_from_timeseries_cumulatives.py +0 -322
  74. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_history_vectors.py +0 -201
  75. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_trace_line_shape.py +0 -56
  76. tests/unit_tests/plugin_tests/test_simulation_time_series/test_utils/test_vector_statistics.py +0 -171
  77. tests/unit_tests/plugin_tests/test_tornado_data.py +0 -130
  78. tests/unit_tests/plugin_tests/test_well_completions.py +0 -158
  79. tests/unit_tests/provider_tests/__init__.py +0 -0
  80. tests/unit_tests/provider_tests/test_ensemble_summary_provider.py +0 -255
  81. tests/unit_tests/provider_tests/test_ensemble_summary_provider_impl_arrow_lazy.py +0 -388
  82. tests/unit_tests/provider_tests/test_ensemble_summary_provider_impl_arrow_presampled.py +0 -160
  83. tests/unit_tests/provider_tests/test_ensemble_summary_provider_resampling.py +0 -320
  84. tests/unit_tests/provider_tests/test_ensemble_table_provider.py +0 -190
  85. tests/unit_tests/utils_tests/__init__.py +0 -0
  86. tests/unit_tests/utils_tests/test_dataframe_utils.py +0 -281
  87. tests/unit_tests/utils_tests/test_ensemble_summary_provider_set/__init__.py +0 -0
  88. tests/unit_tests/utils_tests/test_ensemble_summary_provider_set/test_ensemble_summary_provider_set.py +0 -306
  89. tests/unit_tests/utils_tests/test_formatting.py +0 -10
  90. tests/unit_tests/utils_tests/test_simulation_timeseries.py +0 -51
  91. webviz_subsurface/plugins/_co2_leakage/__init__.py +0 -1
  92. webviz_subsurface/plugins/_co2_leakage/_utilities/__init__.py +0 -0
  93. webviz_subsurface/plugins/_co2_leakage/views/__init__.py +0 -0
  94. webviz_subsurface/plugins/_co2_leakage/views/mainview/__init__.py +0 -0
  95. webviz_subsurface-0.2.39.dist-info/METADATA +0 -147
  96. /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_error.py +0 -0
  97. /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_types.py +0 -0
  98. {tests/integration_tests → webviz_subsurface/plugins/_co2_migration/_utilities}/__init__.py +0 -0
  99. /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/_misc.py +0 -0
  100. /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/fault_polygons_handler.py +0 -0
  101. /webviz_subsurface/plugins/{_co2_leakage → _co2_migration}/_utilities/plume_extent.py +0 -0
  102. {tests/unit_tests → webviz_subsurface/plugins/_co2_migration/views}/__init__.py +0 -0
  103. {tests/unit_tests/abbreviations_tests → webviz_subsurface/plugins/_co2_migration/views/mainview}/__init__.py +0 -0
  104. {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info/licenses}/LICENSE +0 -0
  105. {webviz_subsurface-0.2.39.dist-info → webviz_subsurface-0.2.41.dist-info/licenses}/LICENSE.chromedriver +0 -0
@@ -1,171 +0,0 @@
1
- import datetime
2
-
3
- import pandas as pd
4
- import pytest
5
- from pandas._testing import assert_frame_equal
6
-
7
- from webviz_subsurface._utils.dataframe_utils import make_date_column_datetime_object
8
- from webviz_subsurface.plugins._simulation_time_series._views._subplot_view._types import (
9
- StatisticsOptions,
10
- )
11
-
12
- # pylint: disable=line-too-long
13
- from webviz_subsurface.plugins._simulation_time_series._views._subplot_view._utils.vector_statistics import (
14
- create_vectors_statistics_df,
15
- )
16
-
17
- # *******************************************************************
18
- #####################################################################
19
- #
20
- # CONFIGURE TESTDATA
21
- #
22
- #####################################################################
23
- # *******************************************************************
24
-
25
- # fmt: off
26
- INPUT_YEAR_2020_DF = pd.DataFrame(
27
- columns = ["DATE", "REAL", "A", "B"],
28
- data = [
29
- [datetime.datetime(2020,1,1), 1, 10.0, 50.0 ],
30
- [datetime.datetime(2020,2,1), 1, 100.0, 500.0 ],
31
- [datetime.datetime(2020,3,1), 1, 1000.0, 5000.0 ],
32
- [datetime.datetime(2020,4,1), 1, 10000.0, 50000.0 ],
33
- [datetime.datetime(2020,5,1), 1, 100000.0, 500000.0],
34
- [datetime.datetime(2020,1,1), 2, 20.0, 60.0 ],
35
- [datetime.datetime(2020,2,1), 2, 200.0, 600.0 ],
36
- [datetime.datetime(2020,3,1), 2, 2000.0, 6000.0 ],
37
- [datetime.datetime(2020,4,1), 2, 20000.0, 60000.0 ],
38
- [datetime.datetime(2020,5,1), 2, 200000.0, 600000.0],
39
- [datetime.datetime(2020,1,1), 4, 30.0, 70.0 ],
40
- [datetime.datetime(2020,2,1), 4, 300.0, 700.0 ],
41
- [datetime.datetime(2020,3,1), 4, 3000.0, 7000.0 ],
42
- [datetime.datetime(2020,4,1), 4, 30000.0, 70000.0 ],
43
- [datetime.datetime(2020,5,1), 4, 300000.0, 700000.0],
44
- [datetime.datetime(2020,1,1), 5, 40.0, 80.0 ],
45
- [datetime.datetime(2020,2,1), 5, 400.0, 800.0 ],
46
- [datetime.datetime(2020,3,1), 5, 4000.0, 8000.0 ],
47
- [datetime.datetime(2020,4,1), 5, 40000.0, 80000.0 ],
48
- [datetime.datetime(2020,5,1), 5, 400000.0, 800000.0]
49
- ]
50
- )
51
- make_date_column_datetime_object(INPUT_YEAR_2020_DF)
52
-
53
- # pylint: disable=line-too-long
54
- # Columns are:
55
- # ["DATE", "A" "B" ]
56
- # [ MEAN, MIN, MAX, P10, P90, P50, MEAN, MIN, MAX, P10, P90, P50]
57
- # NOTE: P10 is 90 percentil and P90 is 10 percentile for oil standard
58
- EXPECTED_STATISTICS_YEAR_2020_DF = pd.DataFrame(
59
- columns = pd.MultiIndex.from_tuples([
60
- ("DATE", ""),
61
- ("A", StatisticsOptions.MEAN),
62
- ("A", StatisticsOptions.MIN),
63
- ("A", StatisticsOptions.MAX),
64
- ("A", StatisticsOptions.P10),
65
- ("A", StatisticsOptions.P90),
66
- ("A", StatisticsOptions.P50),
67
- ("B", StatisticsOptions.MEAN),
68
- ("B", StatisticsOptions.MIN),
69
- ("B", StatisticsOptions.MAX),
70
- ("B", StatisticsOptions.P10),
71
- ("B", StatisticsOptions.P90),
72
- ("B", StatisticsOptions.P50),
73
- ]),
74
- data = [
75
- [datetime.datetime(2020,1,1), 25.0, 10.0, 40.0, 37.0, 13.0, 25.0, 65.0, 50.0, 80.0, 77.0, 53.0, 65.0 ],
76
- [datetime.datetime(2020,2,1), 250.0, 100.0, 400.0, 370.0, 130.0, 250.0, 650.0, 500.0, 800.0, 770.0, 530.0, 650.0 ],
77
- [datetime.datetime(2020,3,1), 2500.0, 1000.0, 4000.0, 3700.0, 1300.0, 2500.0, 6500.0, 5000.0, 8000.0, 7700.0, 5300.0, 6500.0 ],
78
- [datetime.datetime(2020,4,1), 25000.0, 10000.0, 40000.0, 37000.0, 13000.0, 25000.0, 65000.0, 50000.0, 80000.0, 77000.0, 53000.0, 65000.0 ],
79
- [datetime.datetime(2020,5,1), 250000.0, 100000.0, 400000.0, 370000.0, 130000.0, 250000.0, 650000.0, 500000.0, 800000.0, 770000.0, 530000.0, 650000.0],
80
- ]
81
- )
82
- make_date_column_datetime_object(EXPECTED_STATISTICS_YEAR_2020_DF)
83
- # fmt: on
84
-
85
- # Dates AFTER year 2262!
86
- INPUT_YEAR_2263_DATES = pd.Series(
87
- [
88
- datetime.datetime(2263, 1, 1),
89
- datetime.datetime(2263, 2, 1),
90
- datetime.datetime(2263, 3, 1),
91
- datetime.datetime(2263, 4, 1),
92
- datetime.datetime(2263, 5, 1),
93
- datetime.datetime(2263, 1, 1),
94
- datetime.datetime(2263, 2, 1),
95
- datetime.datetime(2263, 3, 1),
96
- datetime.datetime(2263, 4, 1),
97
- datetime.datetime(2263, 5, 1),
98
- datetime.datetime(2263, 1, 1),
99
- datetime.datetime(2263, 2, 1),
100
- datetime.datetime(2263, 3, 1),
101
- datetime.datetime(2263, 4, 1),
102
- datetime.datetime(2263, 5, 1),
103
- datetime.datetime(2263, 1, 1),
104
- datetime.datetime(2263, 2, 1),
105
- datetime.datetime(2263, 3, 1),
106
- datetime.datetime(2263, 4, 1),
107
- datetime.datetime(2263, 5, 1),
108
- ]
109
- )
110
- EXPECTED_YEAR_2263_DATES = pd.Series(
111
- [
112
- datetime.datetime(2263, 1, 1),
113
- datetime.datetime(2263, 2, 1),
114
- datetime.datetime(2263, 3, 1),
115
- datetime.datetime(2263, 4, 1),
116
- datetime.datetime(2263, 5, 1),
117
- ]
118
- )
119
- # NOTE: datetime.datetime after year 2262 is not converted to pd.Timestamp, thus
120
- # no need to make date column datetime object
121
- INPUT_YEAR_2263_DF = INPUT_YEAR_2020_DF.copy()
122
- INPUT_YEAR_2263_DF["DATE"] = INPUT_YEAR_2263_DATES
123
- EXPECTED_STATISTICS_YEAR_2263_DF = EXPECTED_STATISTICS_YEAR_2020_DF.copy()
124
- EXPECTED_STATISTICS_YEAR_2263_DF["DATE"] = EXPECTED_YEAR_2263_DATES
125
-
126
- # *******************************************************************
127
- #####################################################################
128
- #
129
- # UNIT TESTS
130
- #
131
- #####################################################################
132
- # *******************************************************************
133
-
134
- TEST_VALID_CASES = [
135
- pytest.param(INPUT_YEAR_2020_DF, EXPECTED_STATISTICS_YEAR_2020_DF),
136
- pytest.param(INPUT_YEAR_2263_DF, EXPECTED_STATISTICS_YEAR_2263_DF),
137
- ]
138
-
139
-
140
- @pytest.mark.parametrize("input_df, expected_statistics_df", TEST_VALID_CASES)
141
- def test_create_vectors_statistics_df(
142
- input_df: pd.DataFrame, expected_statistics_df: pd.DataFrame
143
- ) -> None:
144
- statistics_df = create_vectors_statistics_df(input_df)
145
-
146
- assert_frame_equal(statistics_df, expected_statistics_df)
147
-
148
-
149
- def test_create_vectors_statstics_df_invalid_input() -> None:
150
- """Test assert check assert_date_column_is_datetime_object() in
151
- webviz_subsurface._utils.dataframe_utils.py
152
- """
153
- # fmt: off
154
- input_df = pd.DataFrame(
155
- columns=["DATE", "REAL", "A", "B"],
156
- data=[
157
- [pd.Timestamp(2020, 1, 1), 1, 10.0, 50.0 ],
158
- [pd.Timestamp(2020, 2, 1), 1, 100.0, 500.0 ],
159
- [pd.Timestamp(2020, 3, 1), 1, 1000.0, 5000.0 ],
160
- [pd.Timestamp(2020, 4, 1), 1, 10000.0, 50000.0 ],
161
- [pd.Timestamp(2020, 5, 1), 1, 100000.0, 500000.0],
162
- ],
163
- )
164
- # fmt: on
165
-
166
- with pytest.raises(ValueError) as err:
167
- create_vectors_statistics_df(input_df)
168
- assert (
169
- str(err.value)
170
- == '"DATE"-column in dataframe is not on datetime.datetime format!'
171
- )
@@ -1,130 +0,0 @@
1
- # pylint: disable=protected-access
2
- import pandas as pd
3
- import pytest
4
-
5
- from webviz_subsurface._components.tornado._tornado_data import (
6
- SensitivityType,
7
- TornadoData,
8
- )
9
-
10
-
11
- def test_tornado_data_init():
12
- # fmt: off
13
- input_data = [
14
- ["REAL", "SENSNAME", "SENSCASE", "SENSTYPE", "VALUE" ],
15
- [ 0, "A", "p10_p90", "mc" , 10.0],
16
- [ 1, "A", "p10_p90", "mc" , 20.0],
17
- [ 2, "B", "deep", "scalar" , 5.0],
18
- [ 3, "B", "deep", "scalar" , 6.0],
19
- [ 4, "C", "shallow", "scalar" , 25.0],
20
- [ 5, "C", "shallow", "scalar" , 26.0],
21
- [ 6, "D", "simulation", "mc" , 9.0],
22
- [ 7, "D", "simulation", "mc" , 11.0],
23
- ]
24
- # fmt: on
25
-
26
- input_df = pd.DataFrame(input_data[1:], columns=input_data[0])
27
-
28
- with pytest.raises(ValueError) as exc:
29
- TornadoData(dframe=input_df)
30
- assert exc.value.args[0] == "Reference SENSNAME rms_seed not in input data"
31
-
32
- tornado_data = TornadoData(dframe=input_df, reference="A")
33
-
34
- assert tornado_data._calculate_ref_average(input_df) == 15.0
35
- avg_list = tornado_data._calculate_sensitivity_averages(input_df)
36
- assert avg_list[0] == {
37
- "sensname": "A",
38
- "senscase": "P90",
39
- "values": 11.0,
40
- "values_ref": -26.666666666666668,
41
- "reals": [0],
42
- "senstype": "mc",
43
- }
44
- low_high_list = tornado_data._calculate_tornado_low_high_list(avg_list)
45
- assert low_high_list[0] == {
46
- "low": -26.666666666666668,
47
- "low_base": 0,
48
- "low_label": "P90",
49
- "low_tooltip": -26.666666666666668,
50
- "true_low": 11.0,
51
- "low_reals": [0],
52
- "sensname": "A",
53
- "high": 26.666666666666668,
54
- "high_base": 0,
55
- "high_label": "P10",
56
- "high_tooltip": 26.666666666666668,
57
- "true_high": 19.0,
58
- "high_reals": [1],
59
- "senstype": "mc",
60
- }
61
-
62
- tornado_data = TornadoData(
63
- dframe=input_df, reference="B", scale="Absolute", cutbyref=True
64
- )
65
- assert tornado_data._calculate_tornado_table(input_df).to_dict("records") == [
66
- {
67
- "low": 0.0,
68
- "low_base": 5.5,
69
- "low_label": "P90",
70
- "low_tooltip": 5.5,
71
- "true_low": 11.0,
72
- "low_reals": [],
73
- "sensname": "A",
74
- "high": 8.0,
75
- "high_base": 5.5,
76
- "high_label": "P10",
77
- "high_tooltip": 13.5,
78
- "true_high": 19.0,
79
- "high_reals": [0, 1],
80
- "senstype": SensitivityType.MONTE_CARLO,
81
- },
82
- {
83
- "low": 0.0,
84
- "low_base": 0.0,
85
- "low_label": None,
86
- "low_tooltip": 0.0,
87
- "true_low": 5.5,
88
- "low_reals": [],
89
- "sensname": "B",
90
- "high": 0.0,
91
- "high_base": 0.0,
92
- "high_label": "deep",
93
- "high_tooltip": 0.0,
94
- "true_high": 5.5,
95
- "high_reals": [2, 3],
96
- "senstype": SensitivityType.SCALAR,
97
- },
98
- {
99
- "low": 0.0,
100
- "low_base": 0.0,
101
- "low_label": None,
102
- "low_tooltip": 0.0,
103
- "true_low": 5.5,
104
- "low_reals": [],
105
- "sensname": "C",
106
- "high": 20.0,
107
- "high_base": 0.0,
108
- "high_label": "shallow",
109
- "high_tooltip": 20.0,
110
- "true_high": 25.5,
111
- "high_reals": [4, 5],
112
- "senstype": SensitivityType.SCALAR,
113
- },
114
- {
115
- "low": 0.0,
116
- "low_base": 3.6999999999999993,
117
- "low_label": "P90",
118
- "low_tooltip": 3.6999999999999993,
119
- "true_low": 9.2,
120
- "low_reals": [],
121
- "sensname": "D",
122
- "high": 1.6000000000000014,
123
- "high_base": 3.6999999999999993,
124
- "high_label": "P10",
125
- "high_tooltip": 5.300000000000001,
126
- "true_high": 10.8,
127
- "high_reals": [6, 7],
128
- "senstype": SensitivityType.MONTE_CARLO,
129
- },
130
- ]
@@ -1,158 +0,0 @@
1
- import numpy as np
2
- import pandas as pd
3
- import pytest
4
- from pandas._testing import assert_frame_equal
5
-
6
- from webviz_subsurface._datainput.well_completions import remove_invalid_colors
7
- from webviz_subsurface.plugins._well_completions._business_logic import (
8
- extract_stratigraphy,
9
- merge_compdat_and_connstatus,
10
- )
11
-
12
-
13
- def test_remove_invalid_colors():
14
- """Tests that colors that are not 6 digit hexadecimal are removed from the lyr
15
- parse zone list
16
- """
17
- zonelist = [
18
- {"name": "ZoneA", "color": "#FFFFFF"},
19
- {"name": "ZoneB", "color": "#FFF"},
20
- ]
21
- assert remove_invalid_colors(zonelist) == [
22
- {"name": "ZoneA", "color": "#FFFFFF"},
23
- {
24
- "name": "ZoneB",
25
- },
26
- ]
27
-
28
-
29
- def test_extract_stratigraphy():
30
- """Checks that the merging of the layer_zone_mapping and the stratigraphy is
31
- correct and that the colors are added following the correct prioritization
32
- rules
33
- """
34
- zone_names = ["ZoneA.1", "ZoneA.2", "ZoneB.1"]
35
- stratigraphy = [
36
- {
37
- "name": "ZoneA",
38
- "color": "#000000",
39
- "subzones": [{"name": "ZoneA.1"}, {"name": "ZoneA.2"}, {"name": "ZoneA.3"}],
40
- },
41
- {
42
- "name": "ZoneB",
43
- "subzones": [{"name": "ZoneB.1", "subzones": [{"name": "ZoneB.1.1"}]}],
44
- },
45
- {
46
- "name": "ZoneC",
47
- },
48
- ]
49
- zone_color_mapping = {"ZoneA": "#111111", "ZoneA.1": "#222222"}
50
- theme_colors = ["#FFFFFF"]
51
-
52
- result = extract_stratigraphy(
53
- zone_names, stratigraphy, zone_color_mapping, theme_colors
54
- )
55
- assert result == [
56
- {
57
- "name": "ZoneA",
58
- "color": "#000000", # colors given in the stratigraphy has priority
59
- "subzones": [
60
- {
61
- "name": "ZoneA.1",
62
- "color": "#222222", # color from zone_color_mapping
63
- },
64
- {"name": "ZoneA.2", "color": "#FFFFFF"} # color from theme_colors
65
- # ZoneA.3 is not here because it is not in the layer_zone_mapping
66
- ],
67
- },
68
- {
69
- "name": "ZoneB",
70
- "color": "#808080", # Since it's not a leaf, color is set to grey
71
- "subzones": [
72
- {
73
- "name": "ZoneB.1",
74
- "color": "#FFFFFF" # color from theme_colors
75
- # No subzones here because ZoneB.1.1 is not in the layer_zone_mapping
76
- }
77
- ],
78
- },
79
- # ZoneC is removed since it's not in the layer_zone_mapping
80
- ]
81
-
82
-
83
- def test_extract_stratigraphy_errors():
84
- """Checks that a ValueError is raised when a Zone is in the layer_zone_mapping, but
85
- not in the stratigraphy.
86
- """
87
- layer_zone_mapping = {1: "ZoneA", 2: "ZoneB", 3: "ZoneD"}
88
- stratigraphy = [
89
- {
90
- "name": "ZoneA",
91
- },
92
- {
93
- "name": "ZoneB",
94
- },
95
- ]
96
- with pytest.raises(ValueError):
97
- extract_stratigraphy(layer_zone_mapping, stratigraphy, {}, [])
98
-
99
-
100
- def test_merge_compdat_and_connstatus():
101
- """Tests the functionality of the merge_compdat_and_connstatus function.
102
-
103
- The following functionality is covered:
104
- * The two first rows of df_compdat is replaced with the two first from
105
- df_connstatus, except for the KH (which is only available in df_compdat).
106
- KH is taken from the first of the two compdat rows
107
- * The A2 well is not available in df_connstatus and will be taken as is
108
- from df_compdat
109
- * the fourth row in df_compdat (WELL: A1, REAL:1) is ignored because A1 is
110
- in df_connstatus, but not REAL 1. We don't mix compdat and connstatus data
111
- for the same well
112
- * The fourth row in df_compdat has KH=Nan. This will be 0 in the output
113
- """
114
- df_compdat = pd.DataFrame(
115
- data={
116
- "DATE": [
117
- "2021-01-01",
118
- "2021-05-01",
119
- "2021-01-01",
120
- "2021-01-01",
121
- "2022-01-01",
122
- ],
123
- "REAL": [0, 0, 0, 1, 0],
124
- "WELL": ["A1", "A1", "A2", "A1", "A3"],
125
- "I": [1, 1, 1, 1, 1],
126
- "J": [1, 1, 1, 1, 1],
127
- "K1": [1, 1, 1, 1, 1],
128
- "OP/SH": ["SHUT", "OPEN", "OPEN", "OPEN", "OPEN"],
129
- "KH": [100, 1000, 10, 100, np.nan],
130
- }
131
- )
132
- df_connstatus = pd.DataFrame(
133
- data={
134
- "DATE": ["2021-03-01", "2021-08-01", "2021-01-01"],
135
- "REAL": [0, 0, 0],
136
- "WELL": ["A1", "A1", "A3"],
137
- "I": [1, 1, 1],
138
- "J": [1, 1, 1],
139
- "K1": [1, 1, 1],
140
- "OP/SH": ["OPEN", "SHUT", "OPEN"],
141
- }
142
- )
143
- df_output = pd.DataFrame(
144
- data={
145
- "DATE": ["2021-03-01", "2021-08-01", "2021-01-01", "2021-01-01"],
146
- "REAL": [0, 0, 0, 0],
147
- "WELL": ["A1", "A1", "A3", "A2"],
148
- "I": [1, 1, 1, 1],
149
- "J": [1, 1, 1, 1],
150
- "K1": [1, 1, 1, 1],
151
- "OP/SH": ["OPEN", "SHUT", "OPEN", "OPEN"],
152
- "KH": [100.0, 100.0, 0.0, 10.0],
153
- }
154
- )
155
- df_result = merge_compdat_and_connstatus(df_compdat, df_connstatus)
156
- assert_frame_equal(
157
- df_result, df_output, check_like=True
158
- ) # Ignore order of rows and columns
File without changes