Skip to content

Commit 6b1dd38

Browse files
committed
Allow multiplicative factor for user covmat
1 parent 25adee3 commit 6b1dd38

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

validphys2/src/validphys/config.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ def produce_loaded_theory_covmat(
878878
# change ordering according to exp_covmat (so according to runcard order)
879879
tmp = theory_covmat.droplevel(0, axis=0).droplevel(0, axis=1)
880880
bb = [str(i) for i in data_input]
881+
import ipdb; ipdb.set_trace()
881882
return tmp.reindex(index=bb, columns=bb, level=0).values
882883

883884
@configparser.explicit_node
@@ -1323,6 +1324,21 @@ def produce_nnfit_theory_covmat(
13231324
f = user_covmat_fitting
13241325

13251326
return f
1327+
1328+
def produce_mult_factor_user_covmat(self, mult_factor: float = None, user_covmat_path: str = None):
1329+
"""
1330+
Multiplicative factors for the user covmat provided by mult_factors_user_covmat in the runcard.
1331+
If no factors are provided, returns None.
1332+
For use in theorycovariance.construction.user_covmat.
1333+
"""
1334+
# Check that if mult_factors is provided, user_covmat_paths is also provided
1335+
if mult_factor is not None and user_covmat_path is None:
1336+
raise ConfigError("If mult_factors is provided, user_covmat_paths must also be provided.")
1337+
1338+
if mult_factor is None:
1339+
return 1.0 if user_covmat_path is not None else None
1340+
else:
1341+
return mult_factor
13261342

13271343
def produce_fitthcovmat(
13281344
self, use_thcovmat_if_present: bool = False, fit: (str, type(None)) = None

validphys2/src/validphys/theorycovariance/construction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ def fromfile_covmat(covmatpath, groups_data_by_process, procs_index):
531531

532532

533533
@table
534-
def user_covmat(groups_data_by_process, procs_index, loaded_user_covmat_path):
534+
def user_covmat(groups_data_by_process, procs_index, loaded_user_covmat_path, mult_factor_user_covmat):
535535
"""
536536
General theory covariance matrix provided by the user.
537537
Useful for testing the impact of externally produced
@@ -541,7 +541,7 @@ def user_covmat(groups_data_by_process, procs_index, loaded_user_covmat_path):
541541
``user_covmat_path`` in ``theorycovmatconfig`` in the
542542
runcard. For more information see documentation.
543543
"""
544-
return fromfile_covmat(loaded_user_covmat_path, groups_data_by_process, procs_index)
544+
return mult_factor_user_covmat * fromfile_covmat(loaded_user_covmat_path, groups_data_by_process, procs_index)
545545

546546

547547
@table

0 commit comments

Comments
 (0)