Skip to content

Commit

Permalink
Use index list instead of ActiveList to update std_scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Jul 7, 2023
1 parent 58527e8 commit 1ae2e7f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
32 changes: 1 addition & 31 deletions semeio/workflows/correlated_observations_scaling/obs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from collections import namedtuple
from copy import deepcopy

from ert._c_wrappers.enkf import ActiveList

from semeio.workflows.correlated_observations_scaling.exceptions import ValidationError


Expand Down Expand Up @@ -63,24 +61,11 @@ def create_active_lists(enkf_observations, events):
new_events = []
for event in events:
obs_index = _data_index_to_obs_index(enkf_observations, event.key, event.index)
new_active_list = _get_active_list(obs_index)

new_events.append(_make_tuple(event.key, event.index, new_active_list))
new_events.append(_make_tuple(event.key, event.index, obs_index))

return new_events


def _get_active_list(index_list):
"""
If the user doesn't supply an index list, we assume ALL-ACTIVE on the
observations, otherwise an active list is
created from the index list.
"""
if index_list is None:
index_list = []
return _active_list_from_index_list(index_list)


def _make_tuple(
key,
index,
Expand All @@ -90,21 +75,6 @@ def _make_tuple(
return new_event(key, index, active_list)


def _active_list_from_index_list(index_list):
"""
Creates an ActiveList from a list of indexes
:param index_list: list of index
:type index_list: list
:return: Active list, a c-object with mode (ALL-ACTIVE, PARTIALLY-ACTIVE)
and list of indices
:rtype: active_list
"""
active_list = ActiveList()
for index in index_list:
active_list.addActiveIndex(index)
return active_list


def _data_index_to_obs_index(obs, obs_key, data_index_list):
if obs[obs_key].observation_type.name != "GEN_OBS":
return data_index_list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _update_scaling(obs, scale_factor, obs_list):
if step - 1 in index_list:
obs_node.std_scaling = scale_factor
else:
obs_node.updateStdScaling(scale_factor, event.active_list)
obs_node.std_scaling[event.active_list] = scale_factor
logging.info( # pylint: disable=logging-fstring-interpolation
f"Keys: {[event.key for event in obs_list]} scaled "
f"with scaling factor: {scale_factor}"
Expand Down

0 comments on commit 1ae2e7f

Please sign in to comment.