Skip to content

Commit 80b71b1

Browse files
author
Yngve S. Kristiansen
committed
Rename obs group variable
1 parent 430bad9 commit 80b71b1

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

src/semeio/workflows/ahm_analysis/ahmanalysis.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@ def _replace(s: str) -> str:
198198
ahmanalysis_reports_dir = Path(reports_dir) / "AhmAnalysisJob"
199199
os.makedirs(ahmanalysis_reports_dir, exist_ok=True)
200200

201-
# create dataframe with observations vectors (1 by 1 obs and also all_obs)
202-
combinations = make_obs_groups(key_map)
203-
204201
field_parameters = [
205202
p.name
206203
for p in prior_experiment.parameter_configuration.values()
@@ -233,11 +230,12 @@ def _replace(s: str) -> str:
233230
pd.DataFrame(),
234231
pd.DataFrame(index=["misfit"]),
235232
)
233+
236234
# loop over keys and calculate the KS matrix,
237235
# conditioning one parameter at the time.
238-
updated_combinations = deepcopy(combinations)
239-
for group_name, obs_group in combinations.items():
240-
print("Processing:", group_name)
236+
obs_group_to_obs_keys = deepcopy(make_obs_groups(key_map))
237+
for obs_group, observations in obs_group_to_obs_keys.items():
238+
print("Processing:", obs_group)
241239

242240
# Use localization to evaluate change of parameters for each observation
243241
# The order of the context managers is important, as we want to create a new
@@ -261,7 +259,7 @@ def _replace(s: str) -> str:
261259
update_log = smoother_update(
262260
prior_storage=prior_ensemble,
263261
posterior_storage=target_ensemble,
264-
observations=obs_group,
262+
observations=observations,
265263
parameters=field_parameters + gen_kw_names,
266264
update_settings=copy.deepcopy(observation_settings),
267265
es_settings=es_settings,
@@ -270,29 +268,29 @@ def _replace(s: str) -> str:
270268
# Get the active vs total observation info
271269
df_update_log = make_update_log_df(update_log)
272270
except ErtAnalysisError:
273-
logger.error(f"Analysis failed for: {obs_group}")
274-
del updated_combinations[group_name]
271+
logger.error(f"Analysis failed for: {observations}")
272+
del obs_group_to_obs_keys[obs_group]
275273
continue
276274
# Get the updated scalar parameter distributions
277275
target_ensemble.load_all_gen_kw_data().to_csv(
278-
ahmanalysis_reports_dir / f"{group_name}.csv"
276+
ahmanalysis_reports_dir / f"{obs_group}.csv"
279277
)
280278

281-
active_obs.at["ratio", group_name] = (
279+
active_obs.at["ratio", obs_group] = (
282280
str(count_active_observations(df_update_log))
283281
+ " active/"
284282
+ str(len(df_update_log.index))
285283
)
286284
# Get misfit values
287-
misfitval[group_name] = [
285+
misfitval[obs_group] = [
288286
calc_observationsgroup_misfit(
289-
group_name,
287+
obs_group,
290288
df_update_log,
291289
LibresFacade.load_all_misfit_data(prior_ensemble),
292290
)
293291
]
294292
# Calculate Ks matrix for scalar parameters
295-
kolmogorov_smirnov_data[group_name] = kolmogorov_smirnov_data[
293+
kolmogorov_smirnov_data[obs_group] = kolmogorov_smirnov_data[
296294
"Parameters"
297295
].map(
298296
calc_kolmogorov_smirnov(

0 commit comments

Comments
 (0)