Skip to content

Commit

Permalink
sum covmats per prescription
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyStegeman committed Nov 3, 2024
1 parent 8e1005b commit c9b5e42
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 0 additions & 2 deletions n3fit/runcards/examples/Fit_with_theory_covmat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ theory:
theoryid: 708 # database id
theorycovmatconfig:
point_prescriptions: ["9 point", "3 point"]
# theoryids:
# from_: scale_variation_theories
pdf: NNPDF31_nlo_as_0118
use_thcovmat_in_fitting: true
use_thcovmat_in_sampling: true
Expand Down
4 changes: 2 additions & 2 deletions validphys2/src/validphys/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,9 +1193,9 @@ def produce_nnfit_theory_covmat(
f = total_theory_covmat_fitting
else:
# Only scalevar uncertainties
from validphys.theorycovariance.construction import theory_covmats_fitting
from validphys.theorycovariance.construction import theory_covmat_custom

f = theory_covmats_fitting
f = theory_covmat_custom
elif use_user_uncertainties:
# Only user uncertainties
from validphys.theorycovariance.construction import user_covmat_fitting
Expand Down
2 changes: 1 addition & 1 deletion validphys2/src/validphys/tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_thcovmat_chi2(thcovmat_config):

@make_table_comp(parse_exp_mat)
def test_thcovmat_matrix(thcovmat_config):
matrix = API.theory_covmat_custom(**thcovmat_config)
matrix = API.theory_covmat_custom_per_prescription(**thcovmat_config)
# Converting the dtype of the array to np.float64 to allow comparison to stored DataFrame
return pd.DataFrame(
np.array(matrix.values, dtype=np.float64), index=matrix.index, columns=matrix.index
Expand Down
15 changes: 11 additions & 4 deletions validphys2/src/validphys/theorycovariance/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def covs_pt_prescrip(combine_by_type, theoryids, point_prescription):


@table
def theory_covmat_custom(covs_pt_prescrip, procs_index, combine_by_type):
def theory_covmat_custom_per_prescription(covs_pt_prescrip, procs_index, combine_by_type):
"""Takes the individual sub-covmats between each two processes and assembles
them into a full covmat. Then reshuffles the order from ordering by process
to ordering by experiment as listed in the runcard"""
Expand Down Expand Up @@ -516,16 +516,23 @@ def total_theory_covmat(theory_covmat_custom, user_covmat):
return theory_covmat_custom + user_covmat


def theory_covmat_custom_fitting(theory_covmat_custom, procs_index_matched):
"""theory_covmat_custom but reindexed so the order of the datasets matches
def theory_covmat_custom_fitting(theory_covmat_custom_per_prescription, procs_index_matched):
"""theory_covmat_custom_per_prescription but reindexed so the order of the datasets matches
those in the experiment covmat so they are aligned when fitting."""
df = theory_covmat_custom.reindex(procs_index_matched).T.reindex(procs_index_matched)
df = theory_covmat_custom_per_prescription.reindex(procs_index_matched).T.reindex(
procs_index_matched
)
return df


theory_covmats_fitting = collect(theory_covmat_custom_fitting, ("point_prescriptions",))


@table
def theory_covmat_custom(theory_covmats_fitting):
return sum(theory_covmats_fitting)


def total_theory_covmat_fitting(total_theory_covmat, procs_index_matched):
"""total_theory_covmat but reindexed so the order of the datasets matches
those in the experiment covmat so they are aligned when fitting."""
Expand Down

0 comments on commit c9b5e42

Please sign in to comment.