diff --git a/validphys2/src/validphys/results.py b/validphys2/src/validphys/results.py index d989da6caa..cab3c6966a 100644 --- a/validphys2/src/validphys/results.py +++ b/validphys2/src/validphys/results.py @@ -661,16 +661,15 @@ def predictions_by_kinematics_table(results, kinematics_table_notable): return tb groups_each_dataset_chi2 = collect("each_dataset_chi2", ("group_dataset_inputs_by_metadata",)) +groups_chi2_by_process = collect("dataset_inputs_abs_chi2_data", ("group_dataset_inputs_by_process",)) +groups_each_dataset_chi2_by_process = collect("each_dataset_chi2", ("group_dataset_inputs_by_process",)) @table def groups_chi2_table(groups_data, pdf, groups_chi2, groups_each_dataset_chi2): """Return a table with the chi² to the groups and each dataset in - the groups.""" + the groups, grouped by metadata.""" records = [] for group, groupres, dsresults in zip(groups_data, groups_chi2, groups_each_dataset_chi2): - stats = chi2_stats(groupres) - stats["group"] = group.name - records.append(stats) for dataset, dsres in zip(group, dsresults): stats = chi2_stats(dsres) stats["group"] = dataset.name @@ -678,14 +677,24 @@ def groups_chi2_table(groups_data, pdf, groups_chi2, groups_each_dataset_chi2): return pd.DataFrame(records) -@table -def procs_chi2_table(procs_data, pdf, procs_chi2, each_dataset_chi2): - return groups_chi2_table(procs_data, pdf, procs_chi2, each_dataset_chi2) - experiments_chi2_table = collect( "groups_chi2_table", ("group_dataset_inputs_by_experiment",) ) +@table +def procs_chi2_table( + procs_data, pdf, groups_chi2_by_process, groups_each_dataset_chi2_by_process +): + """Same as groups_chi2_table but by process""" + return groups_chi2_table( + procs_data, + pdf, + groups_chi2_by_process, + groups_each_dataset_chi2_by_process, + ) + +#procs_chi2_table = collect("groups_chi2_table", ("group_dataset_inputs_by_process",)) + @check_cuts_considered @table def closure_shifts(experiments_index, fit, use_cuts, experiments): diff --git a/validphys2/src/validphys/theorycovariance/output.py b/validphys2/src/validphys/theorycovariance/output.py index b2765febac..f631b215fa 100644 --- a/validphys2/src/validphys/theorycovariance/output.py +++ b/validphys2/src/validphys/theorycovariance/output.py @@ -16,27 +16,38 @@ from reportengine.figure import figure from reportengine.table import table +from reportengine import collect from validphys import plotutils from validphys.results import groups_chi2_table log = logging.getLogger(__name__) +abs_chi2_data_theory_dataset_by_process = collect( + "abs_chi2_data_theory_dataset", ("group_dataset_inputs_by_process",) +) + @table def procs_chi2_table_theory( - procs_data, pdf, abs_chi2_data_theory_proc, abs_chi2_data_theory_dataset + procs_data, pdf, abs_chi2_data_theory_proc, abs_chi2_data_theory_dataset_by_process ): """Same as groups_chi2_table but including theory covariance matrix. Note: we use groups_chi2_table here but provide data grouped by process.""" return groups_chi2_table( - procs_data, pdf, abs_chi2_data_theory_proc, abs_chi2_data_theory_dataset + procs_data, + pdf, + abs_chi2_data_theory_proc, + abs_chi2_data_theory_dataset_by_process, ) @table def procs_chi2_table_diagtheory( - procs_data, pdf, abs_chi2_data_diagtheory_proc, abs_chi2_data_diagtheory_dataset + procs_data, + pdf, + abs_chi2_data_diagtheory_proc, + abs_chi2_data_theory_dataset_by_process, ): """Same as groups_chi2_table but including diagonal theory covariance matrix. Note: we use groups_chi2_table here but provide data grouped by process.""" @@ -44,7 +55,7 @@ def procs_chi2_table_diagtheory( procs_data, pdf, abs_chi2_data_diagtheory_proc, - abs_chi2_data_diagtheory_dataset, + abs_chi2_data_theory_dataset_by_process, )