diff --git a/src/ert/_c_wrappers/analysis/analysis_module.py b/src/ert/_c_wrappers/analysis/analysis_module.py index f31e672392d..06ec2ec6629 100644 --- a/src/ert/_c_wrappers/analysis/analysis_module.py +++ b/src/ert/_c_wrappers/analysis/analysis_module.py @@ -210,7 +210,8 @@ def set_var(self, var_name: str, value: Union[float, int, bool, str]): except ValueError: raise ConfigValidationError( - f"Variable {var_name!r} with value {value!r} has incorrect type." + f"Variable {var_name!r} with value {value!r} has " + f"incorrect type." f" Expected type {var['type'].__name__!r} but received" f" value {value!r} of type {type(value).__name__!r}" ) diff --git a/src/ert/analysis/_es_update.py b/src/ert/analysis/_es_update.py index aab1cf62fda..eb37395cdd4 100644 --- a/src/ert/analysis/_es_update.py +++ b/src/ert/analysis/_es_update.py @@ -5,7 +5,7 @@ from dataclasses import dataclass, field from math import sqrt from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Callable import iterative_ensemble_smoother as ies import numpy as np @@ -369,9 +369,13 @@ def analysis_ES( iens_active_index = [i for i in range(len(ens_mask)) if ens_mask[i]] progress_callback(Progress(Task("Loading data", 1, 3), None)) + start = time.time() temp_storage = _create_temporary_parameter_storage( source_fs, ensemble_config, iens_active_index ) + end = time.time() + elapsed = end - start + print(f"Time to run _create_temporary_parameter_storage: {elapsed}") ensemble_size = sum(ens_mask) param_ensemble = _param_ensemble_for_projection( @@ -383,8 +387,9 @@ def analysis_ES( truncation = module.get_truncation() # Looping over local analysis update_step for update_step in updatestep: + print("Loading responses and observations...") + start = time.time() try: - print("Loading responses and observations...") Y, ( observation_values, observation_errors, @@ -400,6 +405,9 @@ def analysis_ES( ) except IndexError as e: raise ErtAnalysisError(e) from e + end = time.time() + elapsed = end - start + print(f"Time to run _load_observations_and_responses: {elapsed}") # pylint: disable=unsupported-assignment-operation smoother_snapshot.update_step_snapshots[update_step.name] = update_snapshot @@ -446,14 +454,17 @@ def analysis_ES( np.linalg.inv(Sigma_A) @ C_AY @ np.linalg.inv(Sigma_Y) ) c_bool = c_AY > correlation_threshold - # Some parameters might be significantly correlated to the exact same - # responses, making up what we call a `parameter group``. + # Some parameters might be significantly correlated + # to the exact same responses, + # making up what we call a `parameter group``. # We want to call the update only once per such parameter group # to speed up computation. param_groups = np.unique(c_bool, axis=0) # Drop the parameter group that does not correlate to any responses. - row_with_all_false = np.all(param_groups == False, axis=1) + row_with_all_false = np.all( + param_groups == False, axis=1 + ) # noqa: E712, E501 param_groups = param_groups[~row_with_all_false] for grp in param_groups: @@ -519,9 +530,13 @@ def analysis_ES( _save_to_temporary_storage(temp_storage, [parameter], A) progress_callback(Progress(Task("Storing data", 3, 3), None)) + start = time.time() _save_temporary_storage_to_disk( target_fs, ensemble_config, temp_storage, iens_active_index ) + end = time.time() + elapsed = end - start + print(f"Time to run _save_temporary_storage_to_disk: {elapsed}") def analysis_IES( @@ -581,7 +596,7 @@ def analysis_IES( f"No active observations for update step: {update_step.name}." ) - noise = rng.standard_normal(size=(len(observation_values), S.shape[1])) + noise = rng.standard_normal(size=(len(observation_values), Y.shape[1])) for parameter in update_step.parameters: iterative_ensemble_smoother.fit( Y,