Skip to content

Commit

Permalink
add a scale_variation extension to plot_datasets_pdfs_chi2
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Nov 13, 2023
1 parent 59b0edc commit 3fea7dc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
18 changes: 18 additions & 0 deletions validphys2/examples/data_theory_comparison_w_sv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ theoryids:
from_: scale_variation_theories
use_theorycovmat: true

use_pdferr: true

dataset_inputs:
- { dataset: ATLASWZRAP36PB }
- { dataset: BCDMSP }
Expand All @@ -22,6 +24,11 @@ dataspecs:
- pdf: Basic_runcard_3replicas_lowprec_221130
speclabel: "pdf2"

# for the chi2 comparison
pdfs:
- Basic_runcard_3replicas_lowprec_221130
- NNPDF40_nnlo_lowprecision

datanorm:
normalize_to: data

Expand Down Expand Up @@ -60,6 +67,17 @@ template_text: |
{@ endwith @}
Chi2 Report per dataset
=======================
Without scale variations
------------------------
{@plot_datasets_pdfs_chi2@}
With scale variations
---------------------
{@plot_datasets_pdfs_chi2_sv@}
actions_:
- report(main=true)
14 changes: 11 additions & 3 deletions validphys2/src/validphys/dataplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ def plot_chi2dist(dataset, abs_chi2_data, chi2_stats, pdf):


@figure
def plot_chi2dist_sv(dataset, results_with_theory_covmat, pdf):
# TODO: maybe unnecessary if the covmat can be passed automagically
abs_chi2_data_thcovmat = abs_chi2_data(results_with_theory_covmat)
def plot_chi2dist_sv(dataset, abs_chi2_data_thcovmat, pdf):
chi2_stats_thcovmat = chi2_stats(abs_chi2_data_thcovmat)
return plot_chi2dist(dataset, abs_chi2_data_thcovmat, chi2_stats_thcovmat, pdf)

Expand Down Expand Up @@ -682,6 +680,16 @@ def plot_datasets_pdfs_chi2(data, each_dataset_chi2_pdfs, pdfs):
return fig


# TODO These three might not be necessary, see the comment in ``abs_chi2_data_thcovmat``
each_dataset_chi2_sv = collect("abs_chi2_data_thcovmat", ("data",))
each_dataset_chi2_pdfs_sv = collect("each_dataset_chi2_sv", ("pdfs",))


@figure
def plot_datasets_pdfs_chi2_sv(data, each_dataset_chi2_pdfs_sv, pdfs):
return plot_datasets_pdfs_chi2(data, each_dataset_chi2_pdfs_sv, pdfs)


@figure
def plot_datasets_chi2_spider(groups_data, groups_chi2):
"""Plot the chi² of all datasets with bars."""
Expand Down
5 changes: 5 additions & 0 deletions validphys2/src/validphys/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,11 @@ def abs_chi2_data(results):
return Chi2Data(th_result.stats_class(chi2s[:, np.newaxis]), central_result, len(data_result))


def abs_chi2_data_thcovmat(results_with_theory_covmat):
# TODO: maybe unnecessary if the covmat can be passed automagically and thus abs_chi2_data can be used directly
return abs_chi2_data(results_with_theory_covmat)


def dataset_inputs_abs_chi2_data(dataset_inputs_results):
"""Like `abs_chi2_data` but for a group of inputs"""
return abs_chi2_data(dataset_inputs_results)
Expand Down

0 comments on commit 3fea7dc

Please sign in to comment.