Skip to content

Commit ef59af1

Browse files
committed
Produce covs_pt_prescrip
1 parent e7b3a0d commit ef59af1

File tree

2 files changed

+54
-32
lines changed

2 files changed

+54
-32
lines changed

validphys2/src/validphys/config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,19 @@ def produce_power_corr_dict(self, pc_parameters=None):
17931793

17941794
return pc_parameters_by_type
17951795

1796+
@configparser.explicit_node
1797+
def produce_covs_pt_prescrip(self, point_prescription):
1798+
if point_prescription != 'power corrections':
1799+
from validphys.theorycovariance.construction import covs_pt_prescrip_mhou
1800+
1801+
f = covs_pt_prescrip_mhou
1802+
else:
1803+
from validphys.theorycovariance.construction import covs_pt_prescrip_pc
1804+
1805+
f = covs_pt_prescrip_pc
1806+
1807+
return f
1808+
17961809

17971810
class Config(report.Config, CoreConfig):
17981811
"""The effective configuration parser class."""

validphys2/src/validphys/theorycovariance/construction.py

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -330,22 +330,14 @@ def compute_covs_pt_prescrip(point_prescription, name1, deltas1, name2=None, del
330330

331331

332332
@check_correct_theory_combination
333-
def covs_pt_prescrip(
334-
combine_by_type,
335-
point_prescription,
336-
pdf: PDF,
337-
power_corr_dict,
338-
pc_included_procs,
339-
pc_excluded_exps,
340-
):
333+
def covs_pt_prescrip_mhou(combine_by_type, point_prescription):
341334
"""Produces the sub-matrices of the theory covariance matrix according
342335
to a point prescription which matches the number of input theories.
343336
chosen in the runcard in order to specify the prescription. Sub-matrices
344337
correspond to applying the scale variation prescription to each pair of
345338
processes in turn, using a different procedure for the case where the
346339
processes are the same relative to when they are different."""
347340
process_info = combine_by_type
348-
datagroup_spec = process_info.data_spec
349341
running_index = 0
350342

351343
covmats = defaultdict(list)
@@ -366,30 +358,47 @@ def covs_pt_prescrip(
366358
start_locs = (start_proc[name1], start_proc[name2])
367359
covmats[start_locs] = s
368360

369-
# For power corrections, the loops run over experimentes
370-
else:
371-
start_proc_by_exp = defaultdict(list)
372-
for exp_name, data_spec in datagroup_spec.items():
373-
start_proc_by_exp[exp_name] = running_index
374-
running_index += data_spec.load_commondata().ndata
375-
376-
for exp_name1, data_spec1 in datagroup_spec.items():
377-
for exp_name2, data_spec2 in datagroup_spec.items():
378-
process_type1 = process_lookup(exp_name1)
379-
process_type2 = process_lookup(exp_name2)
380-
381-
is_excluded_exp = any(name in pc_excluded_exps for name in [exp_name1, exp_name2])
382-
is_included_proc = any(
383-
proc not in pc_included_procs for proc in [process_type1, process_type2]
361+
return covmats
362+
363+
364+
def covs_pt_prescrip_pc(
365+
combine_by_type,
366+
point_prescription,
367+
pdf: PDF,
368+
power_corr_dict,
369+
pc_included_procs,
370+
pc_excluded_exps,
371+
):
372+
"""Produces the sub-matrices of the theory covariance matrix for power
373+
corrections. Sub-matrices correspond to applying power corrected shifts
374+
to each pair of `datasets`."""
375+
process_info = combine_by_type
376+
datagroup_spec = process_info.data_spec
377+
running_index = 0
378+
379+
covmats = defaultdict(list)
380+
start_proc_by_exp = defaultdict(list)
381+
for exp_name, data_spec in datagroup_spec.items():
382+
start_proc_by_exp[exp_name] = running_index
383+
running_index += data_spec.load_commondata().ndata
384+
385+
for exp_name1, data_spec1 in datagroup_spec.items():
386+
for exp_name2, data_spec2 in datagroup_spec.items():
387+
process_type1 = process_lookup(exp_name1)
388+
process_type2 = process_lookup(exp_name2)
389+
390+
is_excluded_exp = any(name in pc_excluded_exps for name in [exp_name1, exp_name2])
391+
is_included_proc = any(
392+
proc not in pc_included_procs for proc in [process_type1, process_type2]
393+
)
394+
if not (is_excluded_exp or is_included_proc):
395+
deltas1 = compute_deltas_pc(data_spec1, pdf, power_corr_dict)
396+
deltas2 = compute_deltas_pc(data_spec2, pdf, power_corr_dict)
397+
s = compute_covs_pt_prescrip(
398+
point_prescription, exp_name1, deltas1, exp_name2, deltas2
384399
)
385-
if not (is_excluded_exp or is_included_proc):
386-
deltas1 = compute_deltas_pc(data_spec1, pdf, power_corr_dict)
387-
deltas2 = compute_deltas_pc(data_spec2, pdf, power_corr_dict)
388-
s = compute_covs_pt_prescrip(
389-
point_prescription, exp_name1, deltas1, exp_name2, deltas2
390-
)
391-
start_locs = (start_proc_by_exp[exp_name1], start_proc_by_exp[exp_name2])
392-
covmats[start_locs] = s
400+
start_locs = (start_proc_by_exp[exp_name1], start_proc_by_exp[exp_name2])
401+
covmats[start_locs] = s
393402
return covmats
394403

395404

0 commit comments

Comments
 (0)