Add logging of RFT observations outside grid - #14322
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more.
|
achaikou
left a comment
There was a problem hiding this comment.
Mainly wonder if the core of the update code is the right place to put these logs to 🤔
| ) | ||
|
|
||
| smoother_update( | ||
| smoother_snapshot = smoother_update( |
There was a problem hiding this comment.
If we are doing it during update, for ES-MDA it would be logged 3 times (though most likely error will be just in the first iteration?). It won't be logged for the final ensemble though, if it suddenly pops up.
This made me wonder what other options we have.
I think RFTConfig's obtain_location_metadata (or _map_locations_to_cells) is a more natural place for this log, even if there potentially would be more logged lines due to each realization being logged separately.
After all, this is where problem first shows itself. So it should be simple to detect and log and it is guaranteed not to be overshadowed by some later code.
What are your thoughts on it?
There was a problem hiding this comment.
My reasoning was that we are mainly interested to know to what extent the issue of observations not in the grid affects the update step. Since we in general need to keep the total amount of logs down, to not overflow the logging system, I decided to log once per update step. I also considered logging only once per experiment run, but that would spread the logging code across multiple modules, so once per update seemed like the best trade-of to keep the log count down, while keeping the logging code well contained.
Since the grid can differ between every realization the same observation can be part of the grid in some realizations and not part of the grid in other realizations. Within an iteration if an observations is not part of the grid for any of the realizations that observation will be removed from the update calculation entirely. So it does not really matter if this happens for one, some or many realizations. That's why I only log how many rft observations where deactivated out of the total amount of rft observations per iteration/update-step.
I agree that it would be natural to add the logging somewhere within RFTConfig, but that would make it log per realization which I would like to avoid.
There was a problem hiding this comment.
I think observation will be deactivated regardless of us approximating response or not approximating it. It gets deactivated just by mertis of being outside of the grid.
So if I think about it, I am not even sure now if approximating responses for observations / logging how many observations there are outside of the grid is of any use 😅
Alright, I buy the "keeping logs down" reasoning 👍
I guess my main dislike is that this file is still kind of pure, with no pollution from update not-related stuff.
So maybe it makes sense to move the code somewhere closer to what it uses? Like here we rely on having result from get_observations_and_responses, missing_realizations and status columns.
Then better place seems to be here or somewhere nearby
https://github.com/equinor/ert/blob/main/src/ert/analysis/_update_commons.py#L272
But if you prefer update_run_model (or it is easier to mock, for example), then I am fine with it too 🙂
There was a problem hiding this comment.
I'll have a look, to see if I can move it. You're correct that observations are deactivated when they are outside the grid currently. As it is now, the approximation option only helps to keep observations active when the response is missing for other reasons (e.g. inactive grid cell). So the aim of logging this particular case is to see if we should change the current behavior, so that responses are approximated for observations outside the grid, and thus allowing the observation to stay active. This would also require us to allow RFT responses and observations to be matched on utm coordinates when the "well_connection_cell" is None.
There was a problem hiding this comment.
Do you know why we decided to deactivate observations that are outside of the grid in the first place?
If it was only because there was no matching response, then great. 👍
But if it was to assure that observation actually falls into the field/grid, then I have questions 😄
There was a problem hiding this comment.
To my understanding it is just because there will be no matching response. Since grid gaps are just a mathematical artifact due to the way cornerpoint grids define cell surfaces, I see no reason to deactivate such observations for any other reason. Note, if we go down the path of attempting to approximate responses and match against observations outside the grid we would probably want to have some kind of mecanism to disgard observations that are completely outside the grid (.i.e not just located in a gap).
There was a problem hiding this comment.
Got you, makes sense!
Thanks for explanations! 🌷
| ) | ||
| self._log_rft_observations_outside_grid(prior, smoother_snapshot) | ||
|
|
||
| def _log_rft_observations_outside_grid( |
There was a problem hiding this comment.
Might be useful to add some information to the docs about why the function is here and when it can be removed 🪹
There was a problem hiding this comment.
Agree, I'll add that
| { | ||
| "status": ObservationStatus.MISSING_RESPONSE, | ||
| "missing_realizations": ( | ||
| f"0: {RFT_LOCATION_NOT_IN_GRID_ERROR} 10.0, 11.0, 12.0" |
There was a problem hiding this comment.
Might make sense to add this message not to 1, but to 2 realizations to test that we do not count the same observation twice.
There was a problem hiding this comment.
Agree, I'll improve the test
Issue
Resolves #14290
Approach
Add logging for observations deactivated due to beeing outside the grid.
Performed test run on tgx to verify logs arrive as expected
git rebase -i main --exec 'just rapid-tests')When applicable
merge screenshot-PR in ert-testdata before merging this PR.