@@ -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,13 @@ 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 = make_obs_groups (key_map )
237+ # iterate over a copy to workaround mutations done to obs_group_to_obs_keys
238+ for obs_group , observations in deepcopy (obs_group_to_obs_keys ).items ():
239+ print ("Processing:" , obs_group )
241240
242241 # Use localization to evaluate change of parameters for each observation
243242 # The order of the context managers is important, as we want to create a new
@@ -261,7 +260,7 @@ def _replace(s: str) -> str:
261260 update_log = smoother_update (
262261 prior_storage = prior_ensemble ,
263262 posterior_storage = target_ensemble ,
264- observations = obs_group ,
263+ observations = observations ,
265264 parameters = field_parameters + gen_kw_names ,
266265 update_settings = copy .deepcopy (observation_settings ),
267266 es_settings = es_settings ,
@@ -270,29 +269,29 @@ def _replace(s: str) -> str:
270269 # Get the active vs total observation info
271270 df_update_log = make_update_log_df (update_log )
272271 except ErtAnalysisError :
273- logger .error (f"Analysis failed for: { obs_group } " )
274- del updated_combinations [ group_name ]
272+ logger .error (f"Analysis failed for: { observations } " )
273+ del obs_group_to_obs_keys [ obs_group ]
275274 continue
276275 # Get the updated scalar parameter distributions
277276 target_ensemble .load_all_gen_kw_data ().to_csv (
278- ahmanalysis_reports_dir / f"{ group_name } .csv"
277+ ahmanalysis_reports_dir / f"{ obs_group } .csv"
279278 )
280279
281- active_obs .at ["ratio" , group_name ] = (
280+ active_obs .at ["ratio" , obs_group ] = (
282281 str (count_active_observations (df_update_log ))
283282 + " active/"
284283 + str (len (df_update_log .index ))
285284 )
286285 # Get misfit values
287- misfitval [group_name ] = [
286+ misfitval [obs_group ] = [
288287 calc_observationsgroup_misfit (
289- group_name ,
288+ obs_group ,
290289 df_update_log ,
291290 LibresFacade .load_all_misfit_data (prior_ensemble ),
292291 )
293292 ]
294293 # Calculate Ks matrix for scalar parameters
295- kolmogorov_smirnov_data [group_name ] = kolmogorov_smirnov_data [
294+ kolmogorov_smirnov_data [obs_group ] = kolmogorov_smirnov_data [
296295 "Parameters"
297296 ].map (
298297 calc_kolmogorov_smirnov (
0 commit comments