Skip to content

Commit

Permalink
Show inversion errors in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Jan 8, 2025
1 parent 383d645 commit 8499185
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
34 changes: 33 additions & 1 deletion src/ert/analysis/_es_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import functools
import logging
import time
import warnings
from collections.abc import Callable, Iterable, Sequence
from fnmatch import fnmatch
from typing import (
Expand All @@ -16,6 +17,7 @@
import numpy as np
import polars
import psutil
import scipy
from iterative_ensemble_smoother.experimental import AdaptiveESMDA

from ert.config import GenKwConfig
Expand Down Expand Up @@ -515,7 +517,37 @@ def adaptive_localization_progress_callback(
else:
# Compute transition matrix so that
# X_posterior = X_prior @ T
T = smoother_es.compute_transition_matrix(Y=S, alpha=1.0, truncation=truncation)
try:
with warnings.catch_warnings(
record=True, category=scipy.linalg.LinAlgWarning
) as all_warnings:
T = smoother_es.compute_transition_matrix(
Y=S, alpha=1.0, truncation=truncation
)
if all_warnings:
progress_callback(
AnalysisStatusEvent(
msg="Warning encountered while computing transition matrix in update"
f"Results may be unreliable: {all_warnings}",
)
)

except scipy.linalg.LinAlgError as err:
msg = (
"Failed while computing transition matrix, "
f"this might be due to outlier values in one or more realizations: {err}"
)
progress_callback(
AnalysisErrorEvent(
error_msg=msg,
data=DataSection(
header=smoother_snapshot.header,
data=smoother_snapshot.csv,
extra=smoother_snapshot.extra,
),
)
)
raise ErtAnalysisError(msg) from err
# Add identity in place for fast computation
np.fill_diagonal(T, T.diagonal() + 1)

Expand Down
2 changes: 1 addition & 1 deletion src/ert/run_models/base_run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ def update(
except ErtAnalysisError as e:
raise ErtRunError(
"Update algorithm failed for iteration:"
f"{posterior.iteration}. The following error occurred {e}"
f"{posterior.iteration}. The following error occurred: {e}"
) from e
self.run_workflows(HookRuntime.POST_UPDATE, self._storage, prior)
return posterior

0 comments on commit 8499185

Please sign in to comment.