Skip to content

Commit 348be41

Browse files
committed
Update for new thcovmat construction + refactor + docstrings
1 parent 3725aa4 commit 348be41

File tree

3 files changed

+892
-394
lines changed

3 files changed

+892
-394
lines changed

validphys2/src/validphys/config.py

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,28 +1157,6 @@ def produce_loaded_user_covmat_path(self, user_covmat_path: str = ""):
11571157
fileloc = l.check_vp_output_file(user_covmat_path)
11581158
return fileloc
11591159

1160-
@configparser.explicit_node
1161-
def produce_covmat_custom(self, use_ht_uncertainties: bool = False):
1162-
if use_ht_uncertainties:
1163-
from validphys.theorycovariance.construction import thcov_ht
1164-
1165-
return thcov_ht
1166-
else:
1167-
from validphys.theorycovariance.construction import covs_pt_prescrip
1168-
1169-
return covs_pt_prescrip
1170-
1171-
@configparser.explicit_node
1172-
def produce_combine_custom(self, use_ht_uncertainties: bool = False):
1173-
if use_ht_uncertainties:
1174-
from validphys.theorycovariance.construction import combine_by_type_ht
1175-
1176-
return combine_by_type_ht
1177-
else:
1178-
from validphys.theorycovariance.construction import combine_by_type
1179-
1180-
return combine_by_type
1181-
11821160
@configparser.explicit_node
11831161
def produce_nnfit_theory_covmat(
11841162
self, point_prescriptions: list = None, user_covmat_path: str = None
@@ -1205,31 +1183,8 @@ def produce_nnfit_theory_covmat(
12051183
from validphys.theorycovariance.construction import user_covmat_fitting
12061184

12071185
f = user_covmat_fitting
1208-
elif use_ht_uncertainties:
1209-
# NOTE: this covmat is the same as for scale variations, which will result in a clash of
1210-
# table names if we wish to use them simultaneously
1211-
if use_user_uncertainties:
1212-
from validphys.theorycovariance.construction import total_theory_covmat_fitting
1213-
1214-
f = total_theory_covmat_fitting
1215-
else:
1216-
from validphys.theorycovariance.construction import theory_covmat_custom_fitting
1217-
1218-
f = theory_covmat_custom_fitting
12191186

1220-
@functools.wraps(f)
1221-
def res(*args, **kwargs):
1222-
return f(*args, **kwargs)
1223-
1224-
# Set this to get the same filename regardless of the action.
1225-
res.__name__ = "theory_covmat"
1226-
return res
1227-
1228-
@configparser.explicit_node
1229-
def produce_combine_by_type_custom(self, use_ht_uncertainties: bool = False):
1230-
if use_ht_uncertainties:
1231-
return validphys.theorycovariance.construction.combine_by_type_ht
1232-
return validphys.theorycovariance.construction.combine_by_type
1187+
return f
12331188

12341189
def produce_fitthcovmat(
12351190
self, use_thcovmat_if_present: bool = False, fit: (str, type(None)) = None
@@ -1707,6 +1662,8 @@ def produce_theoryids(self, t0id, point_prescription):
17071662
prescription. The options for the latter are defined in pointprescriptions.yaml.
17081663
This hard codes the theories needed for each prescription to avoid user error."""
17091664
th = t0id.id
1665+
if point_prescription == 'power corrections':
1666+
return NSList([t0id], nskey="theoryid")
17101667

17111668
lsv = yaml_safe.load(read_text(validphys.scalevariations, "scalevariationtheoryids.yaml"))
17121669

@@ -1809,6 +1766,30 @@ def produce_total_phi_data(self, fitthcovmat):
18091766
return validphys.results.total_phi_data_from_experiments
18101767
return validphys.results.dataset_inputs_phi_data
18111768

1769+
# @configparser.explicit_node
1770+
def produce_power_corr_dict(self, pc_parameters=None):
1771+
"""The parameters for the power corrections are given as a list.
1772+
This function converts this list into a dictionary with the keys
1773+
being the names of the types of power corrections (e.g. `H2p`, `H2d`,...).
1774+
"""
1775+
if pc_parameters is None:
1776+
return None
1777+
1778+
pc_parameters_by_type = {}
1779+
# Loop over the parameterization for the power corrections in the runcard
1780+
for par in pc_parameters:
1781+
# Check that the length of shifts matches the length of nodes.
1782+
if len(par['yshift']) != len(par['nodes']):
1783+
raise ValueError(
1784+
f"The length of nodes does not match that of the list in {par['ht']}."
1785+
f"Check the runcard. Got {len(par['yshift'])} != {len(par['nodes'])}"
1786+
)
1787+
1788+
# Store parameters for each power correction
1789+
pc_parameters_by_type[par['ht']] = {'yshift': par['yshift'], 'nodes': par['nodes']}
1790+
1791+
return pc_parameters_by_type
1792+
18121793

18131794
class Config(report.Config, CoreConfig):
18141795
"""The effective configuration parser class."""

0 commit comments

Comments
 (0)