ert 19.0.1__py3-none-any.whl → 20.0.0b0__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 (86) hide show
  1. ert/__main__.py +94 -63
  2. ert/analysis/_es_update.py +11 -14
  3. ert/cli/main.py +1 -0
  4. ert/config/__init__.py +3 -2
  5. ert/config/_create_observation_dataframes.py +51 -375
  6. ert/config/_observations.py +483 -200
  7. ert/config/_read_summary.py +4 -5
  8. ert/config/ert_config.py +59 -67
  9. ert/config/everest_control.py +40 -39
  10. ert/config/everest_response.py +1 -13
  11. ert/config/field.py +0 -72
  12. ert/config/forward_model_step.py +17 -1
  13. ert/config/gen_data_config.py +14 -17
  14. ert/config/observation_config_migrations.py +821 -0
  15. ert/config/parameter_config.py +18 -28
  16. ert/config/parsing/__init__.py +0 -1
  17. ert/config/parsing/_parse_zonemap.py +45 -0
  18. ert/config/parsing/config_keywords.py +1 -0
  19. ert/config/parsing/config_schema.py +2 -0
  20. ert/config/parsing/observations_parser.py +2 -0
  21. ert/config/response_config.py +5 -23
  22. ert/config/rft_config.py +44 -19
  23. ert/config/summary_config.py +1 -13
  24. ert/config/surface_config.py +0 -57
  25. ert/dark_storage/compute/misfits.py +0 -42
  26. ert/dark_storage/endpoints/__init__.py +0 -2
  27. ert/dark_storage/endpoints/experiment_server.py +5 -3
  28. ert/dark_storage/endpoints/experiments.py +2 -5
  29. ert/dark_storage/json_schema/experiment.py +1 -2
  30. ert/ensemble_evaluator/config.py +2 -1
  31. ert/field_utils/__init__.py +0 -2
  32. ert/field_utils/field_utils.py +1 -117
  33. ert/gui/ertwidgets/listeditbox.py +9 -1
  34. ert/gui/ertwidgets/models/ertsummary.py +20 -6
  35. ert/gui/ertwidgets/pathchooser.py +9 -1
  36. ert/gui/ertwidgets/stringbox.py +11 -3
  37. ert/gui/ertwidgets/textbox.py +10 -3
  38. ert/gui/ertwidgets/validationsupport.py +19 -1
  39. ert/gui/main_window.py +11 -6
  40. ert/gui/simulation/experiment_panel.py +10 -3
  41. ert/gui/simulation/run_dialog.py +11 -1
  42. ert/gui/tools/manage_experiments/export_dialog.py +4 -0
  43. ert/gui/tools/manage_experiments/manage_experiments_panel.py +1 -0
  44. ert/gui/tools/manage_experiments/storage_info_widget.py +1 -1
  45. ert/gui/tools/manage_experiments/storage_widget.py +18 -3
  46. ert/gui/tools/plot/data_type_proxy_model.py +1 -1
  47. ert/gui/tools/plot/plot_api.py +35 -27
  48. ert/gui/tools/plot/plot_widget.py +5 -0
  49. ert/gui/tools/plot/plot_window.py +4 -7
  50. ert/plugins/plugin_manager.py +4 -0
  51. ert/run_models/ensemble_experiment.py +1 -3
  52. ert/run_models/ensemble_smoother.py +1 -3
  53. ert/run_models/everest_run_model.py +12 -13
  54. ert/run_models/initial_ensemble_run_model.py +19 -22
  55. ert/run_models/model_factory.py +7 -7
  56. ert/run_models/multiple_data_assimilation.py +1 -3
  57. ert/sample_prior.py +12 -14
  58. ert/services/__init__.py +7 -3
  59. ert/services/_storage_main.py +59 -22
  60. ert/services/ert_server.py +186 -24
  61. ert/shared/net_utils.py +43 -18
  62. ert/shared/version.py +3 -3
  63. ert/storage/local_ensemble.py +46 -115
  64. ert/storage/local_experiment.py +0 -16
  65. ert/utils/__init__.py +20 -0
  66. {ert-19.0.1.dist-info → ert-20.0.0b0.dist-info}/METADATA +4 -51
  67. {ert-19.0.1.dist-info → ert-20.0.0b0.dist-info}/RECORD +79 -84
  68. everest/bin/everest_script.py +5 -5
  69. everest/bin/kill_script.py +2 -2
  70. everest/bin/monitor_script.py +2 -2
  71. everest/bin/utils.py +4 -4
  72. everest/detached/everserver.py +6 -6
  73. everest/gui/everest_client.py +0 -6
  74. everest/gui/main_window.py +2 -2
  75. everest/util/__init__.py +1 -19
  76. ert/dark_storage/compute/__init__.py +0 -0
  77. ert/dark_storage/endpoints/compute/__init__.py +0 -0
  78. ert/dark_storage/endpoints/compute/misfits.py +0 -95
  79. ert/services/_base_service.py +0 -387
  80. ert/services/webviz_ert_service.py +0 -20
  81. ert/shared/storage/command.py +0 -38
  82. ert/shared/storage/extraction.py +0 -42
  83. {ert-19.0.1.dist-info → ert-20.0.0b0.dist-info}/WHEEL +0 -0
  84. {ert-19.0.1.dist-info → ert-20.0.0b0.dist-info}/entry_points.txt +0 -0
  85. {ert-19.0.1.dist-info → ert-20.0.0b0.dist-info}/licenses/COPYING +0 -0
  86. {ert-19.0.1.dist-info → ert-20.0.0b0.dist-info}/top_level.txt +0 -0
@@ -8,7 +8,6 @@ from __future__ import annotations
8
8
 
9
9
  import fnmatch
10
10
  import re
11
- import warnings
12
11
  from collections.abc import Callable, Sequence
13
12
  from datetime import datetime, timedelta
14
13
  from enum import Enum, auto
@@ -158,10 +157,10 @@ def _read_spec(
158
157
  if kw.summary_variable == "TIME":
159
158
  date_index = i
160
159
  date_unit_str = kw.unit
161
- except InvalidSummaryKeyError as err:
162
- warnings.warn(
163
- f"Found {err} in summary specification, key not loaded", stacklevel=2
164
- )
160
+ except InvalidSummaryKeyError:
161
+ # InvalidSummaryKeyError will happen under normal conditions when
162
+ # the the number of wells set for WELLDIMS in the .DATA file is
163
+ # larger than the number of declared wells/groups/etc. These are skipped.
165
164
  continue
166
165
 
167
166
  if should_load_key(key):
ert/config/ert_config.py CHANGED
@@ -7,7 +7,6 @@ import pprint
7
7
  import re
8
8
  from collections import Counter, defaultdict
9
9
  from collections.abc import Mapping
10
- from datetime import datetime
11
10
  from functools import cached_property
12
11
  from os import path
13
12
  from pathlib import Path
@@ -23,7 +22,7 @@ from ert.substitutions import Substitutions
23
22
  from ._create_observation_dataframes import create_observation_dataframes
24
23
  from ._design_matrix_validator import DesignMatrixValidator
25
24
  from ._observations import (
26
- HistoryObservation,
25
+ GeneralObservation,
27
26
  Observation,
28
27
  RFTObservation,
29
28
  SummaryObservation,
@@ -52,7 +51,6 @@ from .parsing import (
52
51
  ConfigWarning,
53
52
  ErrorInfo,
54
53
  ForwardModelStepKeys,
55
- HistorySource,
56
54
  HookRuntime,
57
55
  ObservationConfigError,
58
56
  init_forward_model_schema,
@@ -62,7 +60,6 @@ from .parsing import (
62
60
  )
63
61
  from .parsing.observations_parser import ObservationDict
64
62
  from .queue_config import KnownQueueOptions, QueueConfig
65
- from .refcase import Refcase
66
63
  from .rft_config import RFTConfig
67
64
  from .workflow import Workflow
68
65
  from .workflow_fixtures import fixtures_per_hook
@@ -104,23 +101,6 @@ def _seed_sequence(seed: int | None) -> int:
104
101
  return int_seed
105
102
 
106
103
 
107
- def _read_time_map(file_contents: str) -> list[datetime]:
108
- def str_to_datetime(date_str: str) -> datetime:
109
- try:
110
- return datetime.fromisoformat(date_str)
111
- except ValueError:
112
- logger.warning(
113
- "DD/MM/YYYY date format is deprecated"
114
- ", please use ISO date format YYYY-MM-DD."
115
- )
116
- return datetime.strptime(date_str, "%d/%m/%Y")
117
-
118
- dates = []
119
- for line in file_contents.splitlines():
120
- dates.append(str_to_datetime(line.strip()))
121
- return dates
122
-
123
-
124
104
  def create_forward_model_json(
125
105
  context: dict[str, str],
126
106
  forward_model_steps: list[ForwardModelStep],
@@ -688,14 +668,6 @@ def log_observation_keys(
688
668
  if key not in {"name", "type"}
689
669
  )
690
670
 
691
- if "HISTORY_OBSERVATION" in observation_type_counts:
692
- msg = (
693
- "HISTORY_OBSERVATION is deprecated and will be removed. "
694
- "Please use SUMMARY_OBSERVATION instead."
695
- )
696
- ConfigWarning.warn(msg)
697
- logger.warning(msg)
698
-
699
671
  logger.info(
700
672
  f"Count of observation types:\n\t{dict(observation_type_counts)}\n"
701
673
  f"Count of observation keywords:\n\t{dict(observation_keyword_counts)}"
@@ -717,6 +689,7 @@ class ErtConfig(BaseModel):
717
689
  QUEUE_OPTIONS: ClassVar[KnownQueueOptions | None] = None
718
690
  RESERVED_KEYWORDS: ClassVar[list[str]] = RESERVED_KEYWORDS
719
691
  ENV_VARS: ClassVar[dict[str, str]] = {}
692
+ PRIORITIZE_PRIVATE_IP_ADDRESS: ClassVar[bool] = False
720
693
 
721
694
  substitutions: dict[str, str] = Field(default_factory=dict)
722
695
  ensemble_config: EnsembleConfig = Field(default_factory=EnsembleConfig)
@@ -731,6 +704,7 @@ class ErtConfig(BaseModel):
731
704
  default_factory=lambda: defaultdict(lambda: cast(list[Workflow], []))
732
705
  )
733
706
  runpath_file: Path = Path(DEFAULT_RUNPATH_FILE)
707
+ prioritize_private_ip_address: bool = False
734
708
 
735
709
  ert_templates: list[tuple[str, str]] = Field(default_factory=list)
736
710
 
@@ -739,9 +713,7 @@ class ErtConfig(BaseModel):
739
713
  user_config_file: str = "no_config"
740
714
  config_path: str = Field(init=False, default="")
741
715
  observation_declarations: list[Observation] = Field(default_factory=list)
742
- time_map: list[datetime] | None = None
743
- history_source: HistorySource = HistorySource.REFCASE_HISTORY
744
- refcase: Refcase | None = None
716
+ zonemap: dict[int, list[str]] = Field(default_factory=dict)
745
717
  _observations: dict[str, pl.DataFrame] | None = PrivateAttr(None)
746
718
 
747
719
  @property
@@ -758,23 +730,15 @@ class ErtConfig(BaseModel):
758
730
  input_files=[self.runpath_config.eclbase_format_string],
759
731
  data_to_read={},
760
732
  locations=[],
733
+ zonemap=self.zonemap,
761
734
  )
762
- computed = create_observation_dataframes(
735
+ self._observations = create_observation_dataframes(
763
736
  self.observation_declarations,
764
- self.refcase,
765
- cast(
766
- GenDataConfig | None,
767
- self.ensemble_config.response_configs.get("gen_data", None),
768
- ),
769
737
  cast(
770
738
  RFTConfig | None,
771
739
  self.ensemble_config.response_configs.get("rft", None),
772
740
  ),
773
- self.time_map,
774
- self.history_source,
775
741
  )
776
- self._observations = computed
777
- return computed
778
742
  return self._observations
779
743
 
780
744
  @model_validator(mode="after")
@@ -830,6 +794,46 @@ class ErtConfig(BaseModel):
830
794
  )
831
795
  return self
832
796
 
797
+ @model_validator(mode="after")
798
+ def validate_observations_against_responses(self) -> Self:
799
+ gen_data_config = cast(
800
+ GenDataConfig | None,
801
+ self.ensemble_config.response_configs.get("gen_data", None),
802
+ )
803
+
804
+ errors: list[ErrorInfo] = []
805
+ for obs in self.observation_declarations:
806
+ if isinstance(obs, GeneralObservation):
807
+ response_key = obs.data
808
+ if gen_data_config is None or response_key not in gen_data_config.keys:
809
+ errors.append(
810
+ ErrorInfo(
811
+ message=(
812
+ f"Problem with GENERAL_OBSERVATION {obs.name}:"
813
+ f" No GEN_DATA with name {response_key!r} found"
814
+ )
815
+ ).set_context(response_key)
816
+ )
817
+ continue
818
+ assert isinstance(gen_data_config, GenDataConfig)
819
+ _, report_steps = gen_data_config.get_args_for_key(response_key)
820
+ response_report_steps = [] if report_steps is None else report_steps
821
+ if response_report_steps and obs.restart not in response_report_steps:
822
+ errors.append(
823
+ ErrorInfo(
824
+ message=(
825
+ f"The GEN_DATA node:{response_key} is not configured "
826
+ f"to load from report step:{obs.restart} for the "
827
+ f"observation:{obs.name}"
828
+ )
829
+ ).set_context(response_key)
830
+ )
831
+
832
+ if errors:
833
+ raise ConfigValidationError.from_collected(errors)
834
+
835
+ return self
836
+
833
837
  def __eq__(self, other: object) -> bool:
834
838
  if not isinstance(other, ErtConfig):
835
839
  return False
@@ -866,6 +870,9 @@ class ErtConfig(BaseModel):
866
870
  )
867
871
  ENV_VARS = dict(runtime_plugins.environment_variables)
868
872
  QUEUE_OPTIONS = runtime_plugins.queue_options
873
+ PRIORITIZE_PRIVATE_IP_ADDRESS = (
874
+ runtime_plugins.prioritize_private_ip_address
875
+ )
869
876
 
870
877
  ErtConfigWithPlugins.model_rebuild()
871
878
  assert issubclass(ErtConfigWithPlugins, ErtConfig)
@@ -1024,7 +1031,7 @@ class ErtConfig(BaseModel):
1024
1031
  summary_obs = {
1025
1032
  obs.key
1026
1033
  for obs in obs_configs
1027
- if isinstance(obs, HistoryObservation | SummaryObservation)
1034
+ if isinstance(obs, SummaryObservation)
1028
1035
  }
1029
1036
  if summary_obs:
1030
1037
  summary_keys = ErtConfig._read_summary_keys(config_dict)
@@ -1032,16 +1039,6 @@ class ErtConfig(BaseModel):
1032
1039
  [key] for key in summary_obs if key not in summary_keys
1033
1040
  ]
1034
1041
  ensemble_config = EnsembleConfig.from_dict(config_dict=config_dict)
1035
- time_map = None
1036
- if time_map_args := config_dict.get(ConfigKeys.TIME_MAP):
1037
- time_map_file, time_map_contents = time_map_args
1038
- try:
1039
- time_map = _read_time_map(time_map_contents)
1040
- except ValueError as err:
1041
- raise ConfigValidationError.with_context(
1042
- f"Could not read timemap file {time_map_file}: {err}",
1043
- time_map_file,
1044
- ) from err
1045
1042
  except ConfigValidationError as err:
1046
1043
  errors.append(err)
1047
1044
  except PydanticValidationError as err:
@@ -1094,9 +1091,6 @@ class ErtConfig(BaseModel):
1094
1091
 
1095
1092
  env_vars = {}
1096
1093
  substituter = Substitutions(substitutions)
1097
- history_source = config_dict.get(
1098
- ConfigKeys.HISTORY_SOURCE, HistorySource.REFCASE_HISTORY
1099
- )
1100
1094
 
1101
1095
  # Insert env vars from plugins/site config
1102
1096
  for key, val in cls.ENV_VARS.items():
@@ -1118,8 +1112,10 @@ class ErtConfig(BaseModel):
1118
1112
  user_configured_.add(key)
1119
1113
  env_vars[key] = substituter.substitute(val)
1120
1114
 
1115
+ if errors:
1116
+ raise ObservationConfigError.from_collected(errors)
1117
+
1121
1118
  try:
1122
- refcase = Refcase.from_config_dict(config_dict)
1123
1119
  cls_config = cls(
1124
1120
  substitutions=substitutions,
1125
1121
  ensemble_config=ensemble_config,
@@ -1141,9 +1137,8 @@ class ErtConfig(BaseModel):
1141
1137
  runpath_config=model_config,
1142
1138
  user_config_file=config_file_path,
1143
1139
  observation_declarations=list(obs_configs),
1144
- time_map=time_map,
1145
- history_source=history_source,
1146
- refcase=refcase,
1140
+ prioritize_private_ip_address=cls.PRIORITIZE_PRIVATE_IP_ADDRESS,
1141
+ zonemap=config_dict.get(ConfigKeys.ZONEMAP, ("", {}))[1],
1147
1142
  )
1148
1143
 
1149
1144
  # The observations are created here because create_observation_dataframes
@@ -1157,20 +1152,17 @@ class ErtConfig(BaseModel):
1157
1152
  input_files=[eclbase],
1158
1153
  data_to_read={},
1159
1154
  locations=[],
1155
+ zonemap=cls_config.zonemap,
1160
1156
  )
1157
+
1158
+ # PS:
1159
+ # This mutates the rft config and is necessary for the moment
1161
1160
  cls_config._observations = create_observation_dataframes(
1162
1161
  obs_configs,
1163
- refcase,
1164
- cast(
1165
- GenDataConfig | None,
1166
- ensemble_config.response_configs.get("gen_data", None),
1167
- ),
1168
1162
  cast(
1169
1163
  RFTConfig | None,
1170
1164
  ensemble_config.response_configs.get("rft", None),
1171
1165
  ),
1172
- time_map,
1173
- history_source,
1174
1166
  )
1175
1167
  except PydanticValidationError as err:
1176
1168
  raise ConfigValidationError.from_pydantic(err) from err
@@ -11,13 +11,14 @@ from typing import TYPE_CHECKING, Any, Literal, Self
11
11
 
12
12
  import networkx as nx
13
13
  import numpy as np
14
+ import polars as pl
14
15
  import xarray as xr
15
16
  from pydantic import BaseModel, ConfigDict, Field, model_validator
16
17
  from ropt.workflow import find_sampler_plugin
17
18
 
18
19
  from ert.substitutions import substitute_runpath_name
19
20
 
20
- from .parameter_config import ParameterConfig
21
+ from .parameter_config import ParameterCardinality, ParameterConfig
21
22
 
22
23
  if TYPE_CHECKING:
23
24
  import numpy.typing as npt
@@ -175,31 +176,47 @@ class EverestControl(ParameterConfig):
175
176
  def parameter_keys(self) -> list[str]:
176
177
  return self.input_keys
177
178
 
179
+ @property
180
+ def cardinality(self) -> ParameterCardinality:
181
+ return ParameterCardinality.multiple_configs_per_ensemble_dataset
182
+
178
183
  def read_from_runpath(
179
184
  self, run_path: Path, real_nr: int, iteration: int
180
185
  ) -> xr.Dataset:
181
186
  raise NotImplementedError
182
187
 
188
+ def load_parameters(
189
+ self, ensemble: Ensemble, realizations: npt.NDArray[np.int_]
190
+ ) -> npt.NDArray[np.float64]:
191
+ raise NotImplementedError
192
+
193
+ def load_parameter_graph(self) -> nx.Graph[int]:
194
+ raise NotImplementedError
195
+
196
+ def __len__(self) -> int:
197
+ return len(self.input_keys)
198
+
183
199
  def write_to_runpath(
184
200
  self, run_path: Path, real_nr: int, ensemble: Ensemble
185
201
  ) -> None:
186
- file_path = run_path / substitute_runpath_name(
202
+ file_path: Path = run_path / substitute_runpath_name(
187
203
  self.output_file, real_nr, ensemble.iteration
188
204
  )
189
205
  Path.mkdir(file_path.parent, exist_ok=True, parents=True)
190
206
 
191
- data: MutableDataType = {}
192
- for da in ensemble.load_parameters(self.name, real_nr)["values"]:
193
- assert isinstance(da, xr.DataArray)
194
- name = str(da.names.values)
195
- try:
196
- outer, inner = name.split("\0")
197
-
198
- if outer not in data:
199
- data[outer] = {}
200
- data[outer][inner] = float(da) # type: ignore
201
- except ValueError:
202
- data[name] = float(da)
207
+ data: dict[str, Any] = {}
208
+ df = ensemble.load_parameters(self.name, real_nr)
209
+ assert isinstance(df, pl.DataFrame)
210
+ df = df.drop("realization")
211
+ df = df.rename({col: col.replace(f"{self.name}.", "", 1) for col in df.columns})
212
+ for c in df.columns:
213
+ if "." in c:
214
+ top_key, sub_key = c.split(".", 1)
215
+ if top_key not in data:
216
+ data[top_key] = {}
217
+ data[top_key][sub_key] = df[c].item()
218
+ else:
219
+ data[c] = df[c].item()
203
220
 
204
221
  file_path.write_text(json.dumps(data), encoding="utf-8")
205
222
 
@@ -207,28 +224,12 @@ class EverestControl(ParameterConfig):
207
224
  self,
208
225
  from_data: npt.NDArray[np.float64],
209
226
  iens_active_index: npt.NDArray[np.int_],
210
- ) -> Iterator[tuple[int, xr.Dataset]]:
211
- for i, realization in enumerate(iens_active_index):
212
- yield (
213
- int(realization),
214
- xr.Dataset(
215
- {
216
- "values": ("names", from_data[:, i]),
217
- "names": [
218
- x.split(f"{self.name}.")[1].replace(".", "\0")
219
- for x in self.parameter_keys
220
- ],
221
- }
222
- ),
223
- )
224
-
225
- def load_parameters(
226
- self, ensemble: Ensemble, realizations: npt.NDArray[np.int_]
227
- ) -> npt.NDArray[np.float64]:
228
- raise NotImplementedError
229
-
230
- def load_parameter_graph(self) -> nx.Graph[int]:
231
- raise NotImplementedError
232
-
233
- def __len__(self) -> int:
234
- return len(self.input_keys)
227
+ ) -> Iterator[tuple[None, pl.DataFrame]]:
228
+ df = pl.DataFrame(
229
+ {
230
+ "realization": iens_active_index,
231
+ **{k: from_data[:, i] for i, k in enumerate(self.parameter_keys)},
232
+ },
233
+ strict=False,
234
+ )
235
+ yield None, df
@@ -7,7 +7,7 @@ import polars as pl
7
7
  from ert.substitutions import substitute_runpath_name
8
8
 
9
9
  from .parsing import ConfigDict
10
- from .response_config import InvalidResponseFile, ResponseConfig, ResponseMetadata
10
+ from .response_config import InvalidResponseFile, ResponseConfig
11
11
  from .responses_index import responses_index
12
12
 
13
13
 
@@ -21,18 +21,6 @@ class EverestResponse(ResponseConfig):
21
21
  def primary_key(self) -> list[str]:
22
22
  return []
23
23
 
24
- @property
25
- def metadata(self) -> list[ResponseMetadata]:
26
- return [
27
- ResponseMetadata(
28
- response_type=self.type,
29
- response_key=response_key,
30
- finalized=self.has_finalized_keys,
31
- filter_on=None,
32
- )
33
- for response_key in self.keys
34
- ]
35
-
36
24
  @property
37
25
  def expected_input_files(self) -> list[str]:
38
26
  return self.input_files
ert/config/field.py CHANGED
@@ -17,13 +17,10 @@ from ert.field_utils import (
17
17
  ErtboxParameters,
18
18
  FieldFileFormat,
19
19
  Shape,
20
- calc_rho_for_2d_grid_layer,
21
20
  calculate_ertbox_parameters,
22
21
  get_shape,
23
22
  read_field,
24
23
  save_field,
25
- transform_local_ellipse_angle_to_local_coords,
26
- transform_positions_to_local_field_coordinates,
27
24
  )
28
25
  from ert.substitutions import substitute_runpath_name
29
26
  from ert.utils import log_duration
@@ -318,75 +315,6 @@ class Field(ParameterConfig):
318
315
  def nz(self) -> int:
319
316
  return self.ertbox_params.nz
320
317
 
321
- def calc_rho_for_2d_grid_layer(
322
- self,
323
- obs_xpos: npt.NDArray[np.float64],
324
- obs_ypos: npt.NDArray[np.float64],
325
- obs_main_range: npt.NDArray[np.float64],
326
- obs_perp_range: npt.NDArray[np.float64],
327
- obs_anisotropy_angle: npt.NDArray[np.float64],
328
- right_handed_grid_indexing: bool = True,
329
- ) -> npt.NDArray[np.float64]:
330
- """Function to calculate scaling values to be used in the RHO matrix
331
- for distance-based localization.
332
-
333
- Args:
334
- obs_xpos: x-coordinates in global coordinates of observations
335
- obs_ypos: y-coordinates in global coordinates of observations
336
- obs_main_range: Size of influence ellipse main principal direction.
337
- obs_perp_range: Size of influence ellipse second principal direction.
338
- obs_anisotropy_angle: Rotation angle anticlock wise of main principal
339
- direction of influence ellipse relative to global coordinate
340
- system's x-axis.
341
- right_handed_grid_indexing: When this is True the field parameters
342
- grid index order counts J-index down from ny-1 to 0.
343
- If the value is False, the grid index order is to count J index
344
- from 0 to ny-1. As standard for 3D field parameters,
345
- the grid index order follows the right_handed grid indexing.
346
-
347
- Returns:
348
- Scaling values (elements of the RHO matrix) as a numpy array
349
- of shape=(nx,ny,nobservations)
350
-
351
- """
352
- # Can only be used if ertbox coordinate system is defined
353
- assert self.ertbox_params.xinc is not None, (
354
- "Parameter for grid resolution must be defined"
355
- )
356
- assert self.ertbox_params.yinc is not None, (
357
- "Parameter for grid resolution must be defined"
358
- )
359
- assert self.ertbox_params.origin is not None, (
360
- "Parameter for grid origin must be defined"
361
- )
362
- assert self.ertbox_params.rotation_angle is not None, (
363
- "Parameter for grid rotation must be defined"
364
- )
365
- # Transform positions of observations into local coordinates
366
- xpos, ypos = transform_positions_to_local_field_coordinates(
367
- self.ertbox_params.origin,
368
- self.ertbox_params.rotation_angle,
369
- obs_xpos,
370
- obs_ypos,
371
- )
372
- # Transform localization ellipse orientation to local coordinates
373
- ellipse_rotation = transform_local_ellipse_angle_to_local_coords(
374
- self.ertbox_params.rotation_angle, obs_anisotropy_angle
375
- )
376
-
377
- return calc_rho_for_2d_grid_layer(
378
- self.ertbox_params.nx,
379
- self.ertbox_params.ny,
380
- self.ertbox_params.xinc,
381
- self.ertbox_params.yinc,
382
- xpos,
383
- ypos,
384
- obs_main_range,
385
- obs_perp_range,
386
- ellipse_rotation,
387
- right_handed_grid_indexing=right_handed_grid_indexing,
388
- )
389
-
390
318
 
391
319
  TRANSFORM_FUNCTIONS: Final[dict[str, Callable[[Any], Any]]] = {
392
320
  "LN": np.log,
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import inspect
3
4
  import logging
4
5
  from typing import (
5
6
  TYPE_CHECKING,
@@ -95,9 +96,24 @@ class ForwardModelStepOptions(TypedDict, total=False):
95
96
  required_keywords: NotRequired[list[str]]
96
97
 
97
98
 
99
+ def _get_source_package() -> str:
100
+ """Return the top-level package name of the calling forward model step.
101
+
102
+ Finds the documentation() call (stack[2]) under the forward model step class
103
+ and return its parent module
104
+ """
105
+ stack = inspect.stack()
106
+ if len(stack) > 2:
107
+ caller_frame = stack[2]
108
+ caller_module = inspect.getmodule(caller_frame.frame)
109
+ if caller_module:
110
+ return caller_module.__name__.split(".")[0]
111
+ return "not found"
112
+
113
+
98
114
  class ForwardModelStepDocumentation(BaseModel):
99
115
  config_file: str | None = Field(default=None)
100
- source_package: str = Field(default="ert")
116
+ source_package: str = Field(default_factory=_get_source_package)
101
117
  source_function_name: str = Field(default="ert")
102
118
  description: str = Field(default="No description")
103
119
  examples: str = Field(default="No examples")
@@ -14,7 +14,6 @@ from .parsing import ConfigDict, ConfigValidationError, ConfigWarning, ErrorInfo
14
14
  from .response_config import (
15
15
  InvalidResponseFile,
16
16
  ResponseConfig,
17
- ResponseMetadata,
18
17
  )
19
18
  from .responses_index import responses_index
20
19
 
@@ -24,22 +23,6 @@ class GenDataConfig(ResponseConfig):
24
23
  report_steps_list: list[list[int] | None] = Field(default_factory=list)
25
24
  has_finalized_keys: bool = True
26
25
 
27
- @property
28
- def metadata(self) -> list[ResponseMetadata]:
29
- return [
30
- ResponseMetadata(
31
- response_type=self.type,
32
- response_key=response_key,
33
- finalized=self.has_finalized_keys,
34
- filter_on={"report_step": report_steps}
35
- if report_steps is not None
36
- else {"report_step": [0]},
37
- )
38
- for response_key, report_steps in zip(
39
- self.keys, self.report_steps_list, strict=False
40
- )
41
- ]
42
-
43
26
  def model_post_init(self, ctx: Any) -> None:
44
27
  if len(self.report_steps_list) == 0:
45
28
  self.report_steps_list = [[0] for _ in self.keys]
@@ -48,6 +31,20 @@ class GenDataConfig(ResponseConfig):
48
31
  if report_steps is not None:
49
32
  report_steps.sort()
50
33
 
34
+ @property
35
+ def filter_on(self) -> dict[str, dict[str, list[int]]]:
36
+ """Filters for this response.
37
+
38
+ For ``GEN_DATA`` this is always supported: return
39
+ ``{response_key: {"report_step": [allowed_steps...]}}``.
40
+ """
41
+ return {
42
+ response_key: {"report_step": report_steps or [0]}
43
+ for response_key, report_steps in zip(
44
+ self.keys, self.report_steps_list, strict=False
45
+ )
46
+ }
47
+
51
48
  @property
52
49
  def expected_input_files(self) -> list[str]:
53
50
  expected_files = []