Skip to content

Commit f68bafd

Browse files
committed
Align nnfit_theory_covat to data_input
1 parent e7071f0 commit f68bafd

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

validphys2/src/validphys/theorycovariance/construction.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -471,22 +471,33 @@ def theory_covmat_custom(theory_covmats_fitting):
471471
return sum(theory_covmats_fitting)
472472

473473

474-
def theory_covmat_custom_fitting(theory_covmat_custom, procs_index_matched):
475-
"""theory_covmat_custom (summed over all point prescriptions) reindexed so the
476-
dataset ordering matches the experiment covmat for alignment when fitting."""
477-
return _reindex_covmat_to_fitting_order(theory_covmat_custom, procs_index_matched)
474+
def data_input_matched_procs_index(data_input, procs_index):
475+
"""procs_index ordered according to data_input (runcard order), so that
476+
nnfit_theory_covmat is stored in the same order as loaded_theory_covmat."""
477+
tups = []
478+
for ds in data_input:
479+
for orig in procs_index:
480+
if orig[1] == str(ds):
481+
tups.append(orig)
482+
return pd.MultiIndex.from_tuples(tups, names=("process", "dataset", "id"))
483+
484+
485+
def theory_covmat_custom_fitting(theory_covmat_custom, data_input_matched_procs_index):
486+
"""theory_covmat_custom (summed over all point prescriptions) reindexed to
487+
data_input (runcard) order so it aligns with loaded_theory_covmat in n3fit."""
488+
return _reindex_covmat_to_fitting_order(theory_covmat_custom, data_input_matched_procs_index)
478489

479490

480-
def total_theory_covmat_fitting(total_theory_covmat, procs_index_matched):
481-
"""total_theory_covmat but reindexed so the order of the datasets matches
482-
those in the experiment covmat so they are aligned when fitting."""
483-
return _reindex_covmat_to_fitting_order(total_theory_covmat, procs_index_matched)
491+
def total_theory_covmat_fitting(total_theory_covmat, data_input_matched_procs_index):
492+
"""total_theory_covmat reindexed to data_input (runcard) order so it aligns
493+
with loaded_theory_covmat in n3fit."""
494+
return _reindex_covmat_to_fitting_order(total_theory_covmat, data_input_matched_procs_index)
484495

485496

486-
def user_covmat_fitting(user_covmat, procs_index_matched):
487-
"""user_covmat but reindexed so the order of the datasets matches
488-
those in the experiment covmat so they are aligned when fitting."""
489-
return _reindex_covmat_to_fitting_order(user_covmat, procs_index_matched)
497+
def user_covmat_fitting(user_covmat, data_input_matched_procs_index):
498+
"""user_covmat reindexed to data_input (runcard) order so it aligns with
499+
loaded_theory_covmat in n3fit."""
500+
return _reindex_covmat_to_fitting_order(user_covmat, data_input_matched_procs_index)
490501

491502

492503
def procs_index_matched(groups_index, procs_index):

0 commit comments

Comments
 (0)