Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/ert/config/rft_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,16 @@ def approximate_missing_rft_responses(
how="anti",
)

# Only attempt to approximate missing values for observations that have a
# well connection cell since currently observations and responses are matched
# based on well connection cell.
# Responses could be approximated for observations without a
# well connection cell based on its utm coordinates, however this will require
# a fallback mechanism to match responses to observations when
# the well_connection_cell is None.
observations_with_missing_response = observations_with_missing_response.filter(
pl.col("well_connection_cell").is_not_null()
)
if observations_with_missing_response.is_empty():
return responses

Expand Down
26 changes: 21 additions & 5 deletions tests/ert/unit_tests/config/test_rft_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,8 @@ def _rft_observation_for_approximation(
east: float = 5.0,
north: float = 5.0,
tvd: float = 15.0,
well_connection_cell: tuple[int, int, int] = (1, 1, 3),
well_connection_cell_center: tuple[float, float, float] = (5.0, 5.0, 25.0),
well_connection_cell: tuple[int, int, int] | None = (1, 1, 3),
well_connection_cell_center: tuple[float, float, float] | None = (5.0, 5.0, 25.0),
zone: str | None = "zone1",
) -> pl.DataFrame:
def _make_dataframe(prop: str) -> pl.DataFrame:
Expand Down Expand Up @@ -1324,6 +1324,16 @@ def _expected_approximated_values(
"available. I.e. no zonemap file."
),
),
pytest.param(
_rft_responses_for_approximation(),
_rft_observation_for_approximation(
tvd=25.0,
well_connection_cell=None, # <= observation is outside the grid
well_connection_cell_center=None, # <= observation is outside the grid
),
None,
id=("Test that approximation is not done when observation is outside grid"),
),
],
)
def test_rft_value_approximation(
Expand All @@ -1335,9 +1345,15 @@ def test_rft_value_approximation(
responses=rft_responses, observations=rft_observations
)

approximated_values = responses_with_approximations.filter(
pl.col("well_connection_cell") == [1, 1, 3] # The cell of the observation
).collect()
# rechunk before the anti-join: polars raises a PanicException on multi-chunk
# frames when a join on Array columns yields an empty result.
# See: https://github.com/pola-rs/polars/issues/29093
rft_responses = rft_responses.collect()
approximated_values = (
responses_with_approximations.collect()
.rechunk()
.join(rft_responses, on=rft_responses.columns, how="anti")
)

assert dict(
zip(
Expand Down
Loading