Skip to content

Commit

Permalink
Sort observations and responses in _es_update
Browse files Browse the repository at this point in the history
  • Loading branch information
yngve-sk committed Oct 10, 2024
1 parent 603d12d commit a06c971
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 33 deletions.
4 changes: 4 additions & 0 deletions src/ert/analysis/_es_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ def _load_observations_and_responses(
iens_active_index,
)

observations_and_responses = observations_and_responses.sort(
by=["observation_key", "index"]
)

S = observations_and_responses.select(
observations_and_responses.columns[5:]
).to_numpy()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---------- --------- ----- ----- ----- ----- ------ ----- ------
WPR_DIFF_1 199, 400 0.000 0.100 1.000 0.100 -0.011 0.060 Active
WPR_DIFF_1 199, 800 0.100 0.200 1.000 0.200 0.081 0.126 Active
WPR_DIFF_1 199, 1200 0.200 0.150 1.000 0.150 0.073 0.130 Active
WPR_DIFF_1 199, 1800 0.000 0.050 1.000 0.050 0.127 0.125 Active
WPR_DIFF_1 199, 400 0.000 0.100 1.000 0.100 -0.011 0.060 Active
WPR_DIFF_1 199, 800 0.100 0.200 1.000 0.200 0.081 0.126 Active
---------- --------- ----- ----- ----- ----- ------ ----- ------
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ WOPR_OP1_190 2015-03-15 00:00:00.000 0.015 0.010 1.732 0.017 0.042 0.041
WOPR_OP1_36 2010-12-26 00:00:00.000 0.700 0.070 1.732 0.121 0.650 0.084 Active
WOPR_OP1_72 2011-12-21 00:00:00.000 0.500 0.050 1.000 0.050 0.405 0.170 Active
WOPR_OP1_9 2010-03-31 00:00:00.000 0.100 0.050 1.732 0.087 0.096 0.060 Active
WPR_DIFF_1 199, 400 0.000 0.100 1.000 0.100 -0.011 0.060 Active
WPR_DIFF_1 199, 800 0.100 0.200 1.000 0.200 0.081 0.126 Active
WPR_DIFF_1 199, 1200 0.200 0.150 1.000 0.150 0.073 0.130 Active
WPR_DIFF_1 199, 1800 0.000 0.050 1.000 0.050 0.127 0.125 Active
WPR_DIFF_1 199, 400 0.000 0.100 1.000 0.100 -0.011 0.060 Active
WPR_DIFF_1 199, 800 0.100 0.200 1.000 0.200 0.081 0.126 Active
------------ ----------------------- ----- ----- ----- ----- ------ ----- ------
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ WOPR_OP1_190 2015-03-15 00:00:00.000 0.015 0.010 1.000 0.010 0.042 0.041
WOPR_OP1_36 2010-12-26 00:00:00.000 0.700 0.070 1.000 0.070 0.650 0.084 Active
WOPR_OP1_72 2011-12-21 00:00:00.000 0.500 0.050 1.000 0.050 0.405 0.170 Active
WOPR_OP1_9 2010-03-31 00:00:00.000 0.100 0.050 1.000 0.050 0.096 0.060 Active
WPR_DIFF_1 199, 400 0.000 0.100 1.000 0.100 -0.011 0.060 Active
WPR_DIFF_1 199, 800 0.100 0.200 1.000 0.200 0.081 0.126 Active
WPR_DIFF_1 199, 1200 0.200 0.150 1.000 0.150 0.073 0.130 Active
WPR_DIFF_1 199, 1800 0.000 0.050 1.000 0.050 0.127 0.125 Active
WPR_DIFF_1 199, 400 0.000 0.100 1.000 0.100 -0.011 0.060 Active
WPR_DIFF_1 199, 800 0.100 0.200 1.000 0.200 0.081 0.126 Active
------------ ----------------------- ----- ----- ----- ----- ------ ----- ------
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ WOPR_OP1_190 2015-03-15 00:00:00.000 0.015 0.010 1.000 0.010 0.042 0.041
WOPR_OP1_36 2010-12-26 00:00:00.000 0.700 0.070 1.000 0.070 0.650 0.084 Active
WOPR_OP1_72 2011-12-21 00:00:00.000 0.500 0.050 1.000 0.050 0.405 0.170 Active
WOPR_OP1_9 2010-03-31 00:00:00.000 0.100 0.050 1.000 0.050 0.096 0.060 Active
WPR_DIFF_1 199, 400 0.000 0.100 1.000 0.100 -0.011 0.060 Active
WPR_DIFF_1 199, 800 0.100 0.200 1.000 0.200 0.081 0.126 Active
WPR_DIFF_1 199, 1200 0.200 0.150 1.000 0.150 0.073 0.130 Active
WPR_DIFF_1 199, 1800 0.000 0.050 1.000 0.050 0.127 0.125 Active
WPR_DIFF_1 199, 400 0.000 0.100 1.000 0.100 -0.011 0.060 Active
WPR_DIFF_1 199, 800 0.100 0.200 1.000 0.200 0.081 0.126 Active
------------ ----------------------- ----- ----- ----- ----- ------ ----- ------
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ WOPR_OP1_190 2015-03-15 00:00:00.000 0.015 0.010 1.414 0.014 0.042 0.041
WOPR_OP1_36 2010-12-26 00:00:00.000 0.700 0.070 1.000 0.070 0.650 0.084 Active
WOPR_OP1_72 2011-12-21 00:00:00.000 0.500 0.050 1.000 0.050 0.405 0.170 Active
WOPR_OP1_9 2010-03-31 00:00:00.000 0.100 0.050 1.000 0.050 0.096 0.060 Active
WPR_DIFF_1 199, 400 0.000 0.100 1.000 0.100 -0.011 0.060 Active
WPR_DIFF_1 199, 800 0.100 0.200 1.000 0.200 0.081 0.126 Active
WPR_DIFF_1 199, 1200 0.200 0.150 1.000 0.150 0.073 0.130 Active
WPR_DIFF_1 199, 1800 0.000 0.050 1.000 0.050 0.127 0.125 Active
WPR_DIFF_1 199, 400 0.000 0.100 1.000 0.100 -0.011 0.060 Active
WPR_DIFF_1 199, 800 0.100 0.200 1.000 0.200 0.081 0.126 Active
------------ ----------------------- ----- ----- ----- ----- ------ ----- ------
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ WOPR_OP1_190 2015-03-15 00:00:00.000 0.015 0.010 1.000 0.010 0.042 0.041
WOPR_OP1_36 2010-12-26 00:00:00.000 0.700 0.070 1.000 0.070 0.650 0.084 Deactivated, outlier
WOPR_OP1_72 2011-12-21 00:00:00.000 0.500 0.050 1.000 0.050 0.405 0.170 Deactivated, outlier
WOPR_OP1_9 2010-03-31 00:00:00.000 0.100 0.050 1.000 0.050 0.096 0.060 Deactivated, outlier
WPR_DIFF_1 199, 400 0.000 0.100 1.000 0.100 -0.011 0.060 Deactivated, outlier
WPR_DIFF_1 199, 800 0.100 0.200 1.000 0.200 0.081 0.126 Deactivated, outlier
WPR_DIFF_1 199, 1200 0.200 0.150 1.000 0.150 0.073 0.130 Deactivated, outlier
WPR_DIFF_1 199, 1800 0.000 0.050 1.000 0.050 0.127 0.125 Deactivated, outlier
WPR_DIFF_1 199, 400 0.000 0.100 1.000 0.100 -0.011 0.060 Deactivated, outlier
WPR_DIFF_1 199, 800 0.100 0.200 1.000 0.200 0.081 0.126 Deactivated, outlier
------------ ----------------------- ----- ----- ----- ----- ------ ----- --------------------
42 changes: 21 additions & 21 deletions tests/ert/unit_tests/analysis/test_es_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,31 +222,31 @@ def test_update_report_with_different_observation_status_from_smoother_update(
(
"IES_ENKF",
[
0.5167529669896218,
-0.9178847938402281,
-0.6299046429604261,
-0.1632005925319205,
0.0216488942750398,
0.07464619425897459,
-1.5587692532545538,
0.22910522740018124,
-0.7171489000139469,
0.7287252249699406,
0.6038000995616932,
-0.8995579663087738,
-0.650440718033405,
-0.11664520562571357,
0.14637004546145008,
0.06369104020984925,
-1.5673340724477953,
0.2045320804879709,
-0.8182935847537811,
0.7551499933992224,
],
),
(
"STD_ENKF",
[
1.3040645145742686,
-0.8162878122658299,
-1.5484856041224397,
-1.379896334985399,
-0.510970027650022,
0.5638868158813687,
-2.7669280724377487,
1.7160680670028017,
-1.2603717378211836,
1.2014197463741136,
1.7365584618531105,
-0.819068074727709,
-1.6628460358849138,
-1.269803440396085,
-0.06688718485326725,
0.5544021609832737,
-2.904293766981197,
1.6866443742416257,
-1.6783511959093573,
1.3081213916230614,
],
),
],
Expand Down Expand Up @@ -325,7 +325,7 @@ def test_update_snapshot(
assert sim_gen_kw != target_gen_kw

# Check that posterior is as expected
assert target_gen_kw == pytest.approx(expected_gen_kw, rel=1e-5)
assert target_gen_kw == pytest.approx(expected_gen_kw, abs=1e-5)


@pytest.mark.usefixtures("use_tmpdir")
Expand Down

0 comments on commit a06c971

Please sign in to comment.