Skip to content

Commit e10a795

Browse files
committed
Implementing Juan's comments
1 parent 47db2bf commit e10a795

File tree

4 files changed

+37
-48
lines changed

4 files changed

+37
-48
lines changed

n3fit/runcards/examples/Basic_runcard_pc_covmat.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ datacuts:
3333
################################################################################
3434
# NNLO QCD TRN evolution
3535
theory:
36-
theoryid: 708
36+
theoryid: 40_000_000
3737

3838
theorycovmatconfig:
39-
point_prescriptions: ["9 point", "power corrections"]
39+
point_prescriptions: ["power corrections"]
4040
pc_parameters:
4141
H2p: {yshift: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0], nodes: [0.0, 0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 1]}
4242
H2d: {yshift: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0], nodes: [0.0, 0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 1]}

n3fit/src/n3fit/performfit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def performfit(
4141
debug=False,
4242
maxcores=None,
4343
double_precision=False,
44-
parallel_models=False,
44+
parallel_models=True,
4545
):
4646
"""
4747
This action will (upon having read a validcard) process a full PDF fit

validphys2/src/validphys/config.py

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,17 +1323,21 @@ def produce_nnfit_theory_covmat(
13231323
f = user_covmat_fitting
13241324

13251325
return f
1326-
1327-
def produce_mult_factor_user_covmat(self, mult_factor: float = None, user_covmat_path: str = None):
1326+
1327+
def produce_mult_factor_user_covmat(
1328+
self, mult_factor: float = 1.0, user_covmat_path: str = None
1329+
):
13281330
"""
13291331
Multiplicative factors for the user covmat provided by mult_factors_user_covmat in the runcard.
13301332
If no factors are provided, returns None.
13311333
For use in theorycovariance.construction.user_covmat.
13321334
"""
13331335
# Check that if mult_factors is provided, user_covmat_paths is also provided
13341336
if mult_factor is not None and user_covmat_path is None:
1335-
raise ConfigError("If mult_factors is provided, user_covmat_paths must also be provided.")
1336-
1337+
raise ConfigError(
1338+
"If mult_factors is provided, user_covmat_paths must also be provided."
1339+
)
1340+
13371341
if mult_factor is None:
13381342
return 1.0 if user_covmat_path is not None else None
13391343
else:
@@ -1945,18 +1949,7 @@ def produce_filter_data(
19451949
if not fakedata:
19461950
return validphys.filters.filter_real_data
19471951
else:
1948-
# TODO we don't want to sample from the theory covmat for L1 data,
1949-
# but we do want to use the theory covmat for L2 data
1950-
if theorycovmatconfig is not None and theorycovmatconfig.get(
1951-
"use_thcovmat_in_fakedata_sampling"
1952-
):
1953-
# NOTE: By the time we run theory covmat closure tests,
1954-
# hopefully the generation of pseudodata will be done in python.
1955-
raise ConfigError(
1956-
"Generating L1 closure test data which samples from the theory "
1957-
"covariance matrix has not been implemented yet."
1958-
)
1959-
elif inconsistent_fakedata:
1952+
if inconsistent_fakedata:
19601953
log.info("Using filter for inconsistent closure data")
19611954
return validphys.filters.filter_inconsistent_closure_data_by_experiment
19621955

@@ -1986,14 +1979,14 @@ def produce_total_phi_data(self, fitthcovmat):
19861979

19871980
@configparser.explicit_node
19881981
def produce_covs_pt_prescrip(self, point_prescription):
1989-
if point_prescription != 'power corrections':
1990-
from validphys.theorycovariance.construction import covs_pt_prescrip_mhou
1991-
1992-
f = covs_pt_prescrip_mhou
1993-
else:
1982+
if point_prescription == 'power corrections':
19941983
from validphys.theorycovariance.construction import covs_pt_prescrip_pc
19951984

19961985
f = covs_pt_prescrip_pc
1986+
else:
1987+
from validphys.theorycovariance.construction import covs_pt_prescrip_mhou
1988+
1989+
f = covs_pt_prescrip_mhou
19971990

19981991
return f
19991992

validphys2/src/validphys/theorycovariance/construction.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
pass
1717
from validphys.checks import check_pc_parameters
18-
from validphys.core import PDF
1918
from validphys.results import results, results_central
2019
from validphys.theorycovariance.higher_twist_functions import compute_deltas_pc
2120
from validphys.theorycovariance.theorycovarianceutils import (
@@ -227,34 +226,31 @@ def covmat_n3lo_ad(name1, name2, deltas1, deltas2):
227226
def covmat_power_corrections(deltas1, deltas2):
228227
"""Returns the the theory covariance sub-matrix for power
229228
corrections. The two arguments `deltas1` and `deltas2` contain
230-
the shifts for the firs and second experiment, respectively.
229+
the shifts for the first and second experiment, respectively.
231230
232231
The shifts are given in this form:
233232
```
234-
deltas1 = {shift1_label: array1_of_shifts1,
235-
shift2_label: array1_of_shifts2,
236-
shift3_label: array1_of_shifts3,
237-
...}
238-
deltas2 = {shift1_label: array2_of_shifts1,
239-
shift2_label: array2_of_shifts2,
240-
shift3_label: array2_of_shifts3,
241-
...}
233+
deltas1 = [array1_of_shifts1,
234+
array1_of_shifts2,
235+
array1_of_shifts3,
236+
...]
237+
deltas2 = [array2_of_shifts1,
238+
array2_of_shifts2,
239+
array2_of_shifts3,
240+
...]
242241
```
243242
The sub-matrix is computed using the 5-point prescription, thus
244243
245244
s = array1_of_shifts1 X array2_of_shifts1 + array1_of_shifts2 X array2_of_shifts2 + ...
246245
247-
where `X` is the outer product.
246+
where ``X`` is the outer product.
248247
"""
249-
# Check that `deltas1` and `deltas2` have the same shifts
250-
if deltas1.keys() != deltas2.keys():
251-
raise RuntimeError('The two dictionaries do not contain the same shifts.')
252248

253-
size1 = next(iter(deltas1.values())).size
254-
size2 = next(iter(deltas2.values())).size
249+
size1 = deltas1[0].size
250+
size2 = deltas2[0].size
255251
s = np.zeros(shape=(size1, size2))
256-
for shift in deltas1.keys():
257-
s += np.outer(deltas1[shift], deltas2[shift])
252+
for shift1, shift2 in zip(deltas1, deltas2):
253+
s += np.outer(shift1, shift2)
258254
return s
259255

260256

@@ -367,12 +363,7 @@ def covs_pt_prescrip_mhou(combine_by_type, point_prescription):
367363

368364
@check_pc_parameters
369365
def covs_pt_prescrip_pc(
370-
combine_by_type,
371-
point_prescription,
372-
pdf: PDF,
373-
pc_parameters,
374-
pc_included_procs,
375-
pc_excluded_exps,
366+
combine_by_type, point_prescription, pdf, pc_parameters, pc_included_procs, pc_excluded_exps
376367
):
377368
"""Produces the sub-matrices of the theory covariance matrix for power
378369
corrections. Sub-matrices correspond to applying power corrected shifts
@@ -399,6 +390,11 @@ def covs_pt_prescrip_pc(
399390
if not (is_excluded_exp or is_included_proc):
400391
deltas1 = compute_deltas_pc(data_spec1, pdf, pc_parameters)
401392
deltas2 = compute_deltas_pc(data_spec2, pdf, pc_parameters)
393+
394+
# Convert deltas1 and deltas2 to the format expected by compute_covs_pt_prescrip
395+
deltas1 = [np.array(deltas1[shift]) for shift in sorted(deltas1.keys())]
396+
deltas2 = [np.array(deltas2[shift]) for shift in sorted(deltas2.keys())]
397+
402398
s = compute_covs_pt_prescrip(
403399
point_prescription, exp_name1, deltas1, exp_name2, deltas2
404400
)

0 commit comments

Comments
 (0)