Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an unique truth for all theory cards #2028

Merged
merged 65 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
7f6f54e
First minimal example
andreab1997 Mar 28, 2024
6e08087
Update nnpdf_data/theory.py
andreab1997 Mar 28, 2024
0f71abe
Remove unused parameters
andreab1997 Mar 28, 2024
9a40b96
Add use_fhmruvv and remove IB
andreab1997 Mar 28, 2024
1065a93
Remove Qedref
andreab1997 Apr 4, 2024
3a22aa6
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 8, 2024
90cb80f
Address review comment
andreab1997 Apr 8, 2024
0655ba5
Modify DAMPPOWERs
andreab1997 Apr 8, 2024
6fb5b6d
Add comments to parameters
andreab1997 Apr 8, 2024
9ccd33a
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
0808e9a
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
cb1c0cb
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
503b5c0
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
44f39cb
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
8c42f4d
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
ccda8f9
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
cacfb06
Address review comments
andreab1997 Apr 10, 2024
a5ea090
Remove Fact and Ren Scalevar'
andreab1997 Apr 10, 2024
c0d0ea7
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 11, 2024
7caa2c8
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 11, 2024
8e0652f
Put all the optional parameters at the end
andreab1997 Apr 11, 2024
fa1920b
First minimal example
andreab1997 Mar 28, 2024
8341ca2
Update nnpdf_data/theory.py
andreab1997 Mar 28, 2024
2307065
Remove unused parameters
andreab1997 Mar 28, 2024
74b91ca
Add use_fhmruvv and remove IB
andreab1997 Mar 28, 2024
72d7a5c
Remove Qedref
andreab1997 Apr 4, 2024
eadaae0
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 8, 2024
4a522a1
Address review comment
andreab1997 Apr 8, 2024
514c9a3
Modify DAMPPOWERs
andreab1997 Apr 8, 2024
9904beb
Add comments to parameters
andreab1997 Apr 8, 2024
31b39a4
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
da7ba20
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
6de4627
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
bbfa5ff
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
9a900da
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
f303c4a
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
42ac7d1
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 10, 2024
5f76e79
Address review comments
andreab1997 Apr 10, 2024
8529b53
Remove Fact and Ren Scalevar'
andreab1997 Apr 10, 2024
8a9a437
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 11, 2024
20d3f74
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 11, 2024
58faa65
Put all the optional parameters at the end
andreab1997 Apr 11, 2024
b689f26
update runcard and rebase with master
scarlehoff Apr 12, 2024
60c95fc
add parameters still requested by eko to evolven3fit ; photon module …
scarlehoff Apr 12, 2024
749ea42
remove theory 522
scarlehoff Apr 12, 2024
2526a63
raise exception only for new theories
scarlehoff Apr 13, 2024
b8e80d5
flip qed running, pre-commit touched files
scarlehoff Apr 13, 2024
e0d8e76
fix n3lo parameters
giacomomagni Apr 15, 2024
1aaf91a
add theorycard 41_000_000
RoyStegeman Apr 15, 2024
dbabec8
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 18, 2024
9cb8a06
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 18, 2024
6480755
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 18, 2024
c9acc6c
Merge branch 'single_truth' of github.com:NNPDF/nnpdf into single_truth
andreab1997 Apr 18, 2024
f4f14e5
Correct QED description
andreab1997 Apr 18, 2024
a40b954
Move HQ with default at the bottom
andreab1997 Apr 18, 2024
73a7db6
Add comment on CKM matrix
andreab1997 Apr 18, 2024
fb83970
Update nnpdf_data/nnpdf_data/theory.py
andreab1997 Apr 22, 2024
2a77e7c
Merge pull request #2048 from NNPDF/41_baseline_theory
andreab1997 Apr 22, 2024
be36283
add annotations and hints and a default for IterEv
scarlehoff Apr 24, 2024
490ee74
utilize the theory iterations by default ; fail inmediately with inco…
scarlehoff Apr 24, 2024
1d894af
add a default-depending-on-Q0 for nf0
scarlehoff Apr 25, 2024
8e4eb08
Merge pull request #2062 from NNPDF/add_default_for_itev
scarlehoff Apr 30, 2024
8f1be78
add alphas/alphaqed/qref to mandatory fields
scarlehoff Apr 30, 2024
cdb247c
Merge branch 'master' into single_truth
scarlehoff Apr 30, 2024
0e19aa1
Merge branch 'master' into single_truth
scarlehoff May 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions nnpdf_data/nnpdf_data/theory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"""
This module provides an unique source and definition for all the possible parameters
scarlehoff marked this conversation as resolved.
Show resolved Hide resolved
that a theory card can contain.
"""

import dataclasses

DEPRECATED_KEYS = ["MaxNfAs", "SxRes", "SxOrd" "EScaleVar", "Qedref", "global_nx"]


@dataclasses.dataclass(frozen=True)
class TheoryCard:
ID: int # ID number of the theory
PTO: int # Perturbative order (0 = LO, 1 = NLO, 2 = NNLO ...)
FNS: str # Flavor number scheme (i.e. FONLL-C)
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
DAMP: int # Whether a damping function is applied or not for FONLL
IC: int # 0 = perturbative charm only , 1 = intrinsic charm allowed
ModEv: str # DGLAP evolution solution method (EXA or TRN)
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
XIR: float # Renormalization scale over the hard scattering scale ratio
XIF: float # Factorization scale over the hard scattering scale ratio
NfFF: int # Number of active flavors, only for FFNS or FFN0 schemes
QED: int # QED correction to strong coupling: 0 = disabled , 1 = allowed
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
HQ: str # Heavy quark mass scheme, POLE for pole masses (default), MSBAR for running masses (used only in Eko).
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
mc: float # [GeV] charm mass
Qmc: float # [GeV] MSbar mass reference scale of the charm
kcThr: float # Threshold ratio of the charm
mb: float # # [GeV] bottom mass
Qmb: float # [GeV] MSbar mass reference scale of the bottom
kbThr: float # Threshold ratio of the bottom
mt: float # # [GeV] top mass
Qmt: float # [GeV] MSbar mass reference scale of the top
ktThr: float # Threshold ratio of the top
CKM: list[float] # CKM matrix elements
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
MZ: float # [GeV] Mass of Z
MW: float # [GeV] Mass of W
GF: float # Fermi constant
SIN2TW: float
TMC: int # Include target mass corrections: 0 = disabled, 1 = leading twist, 2 = higher twist approximated, 3 = higher twist exact
MP: float # [GeV] Mass of the proton
Comments: str # Comments on the theory
MaxNfPdf: int = 5 # Used by pineko to define the thresholds
# Fit theory parameters default
nf0: int = 4 # Number of active flavors at the parametrization scale Q0
Q0: float = 1.65 # [GeV] Parametrization scale
nfref: int = 5 # Number of active flavors at Qref
Qref: float = 91.2 # [GeV] Reference scale for alphas and alphaqed
alphas: float = 0.118 # Value of alpha_s at the scale Qref
alphaqed: float = 0.007496252 # Values of alpha QED at the scale Qref
# Evolution parameters
IterEv: int = None # iterations for the evolution of the PDF. Defaults to 40 when ModEv = EXA
scarlehoff marked this conversation as resolved.
Show resolved Hide resolved
ModSV: str = None # Scale variations method in EKO (expanded or exponentiated)
DAMPPOWERc: int = None # Power of the damping factor in FONLL for the c
DAMPPOWERb: int = None # Power of the damping factor in FONLL for the b
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these can be moved below damp?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is it here because it has a default?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default. damp can be given an IC-dependent default as well.

(the conference finished before I could merge this :'( )

# N3LO parameters
n3lo_cf_variation: list = dataclasses.field(
default_factory=lambda: 7 * [0]
) # N3LO coefficient functions variation: -1 = lower bound, 0 = central, 1 = upper bound
use_fhmruvv: bool = (
False # N3LO splitting functions approximation: if True use the FHMRUVV parametrization, otherwise use EKO parametrization.
)
###### Keys for compatibility with old NNPDF theories, their values will be dropped inmediately after reading to avoid problems
###### they will be set to ``None`` inmediately after loading the theory
MaxNfAs: int = None
SxRes: int = None
SxOrd: str = None
EScaleVar: int = None
Qedref: float = None
global_nx: int = None

def __post_init__(self):
"""Drop deprecated keys"""
for key in DEPRECATED_KEYS:
object.__setattr__(self, key, None)

def asdict(self):
return dataclasses.asdict(self)
48 changes: 3 additions & 45 deletions nnpdf_data/nnpdf_data/theorydbutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,15 @@
low level utilities for querying the theory database file and representing the
data as a python object.
"""
from dataclasses import asdict, dataclass
from functools import lru_cache
from pathlib import Path

import pandas as pd

from .theory import TheoryCard
from .utils import parse_yaml_inp


@dataclass(frozen=True)
class _TheoryCard:
ID: int
PTO: int
FNS: str
DAMP: int
IC: int
ModEv: str
XIR: float
XIF: float
NfFF: int
MaxNfAs: int
MaxNfPdf: int
Q0: float
alphas: float
Qref: float
QED: int
alphaqed: float
Qedref: float
SxRes: int
SxOrd: str
HQ: str
mc: float
Qmc: float
kcThr: float
mb: float
Qmb: float
kbThr: float
mt: float
Qmt: float
ktThr: float
CKM: list[float]
MZ: float
MW: float
GF: float
SIN2TW: float
TMC: int
MP: float
Comments: str
global_nx: int
EScaleVar: int


class TheoryNotFoundInDatabase(Exception):
pass

Expand All @@ -67,7 +24,8 @@ def parse_theory_card(theory_card):
Returns the theory as a dictionary
"""
if theory_card.exists():
return asdict(parse_yaml_inp(theory_card, _TheoryCard))
tcard = parse_yaml_inp(theory_card, TheoryCard)
return tcard.asdict()
raise TheoryNotFoundInDatabase(f"Theory card {theory_card} not found")


Expand Down
7 changes: 6 additions & 1 deletion nnpdf_data/nnpdf_data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import ruamel.yaml as yaml
from validobj import ValidationError, parse_input

try:
Loader = yaml.CLoader
except AttributeError:
Loader = yaml.Loader


def parse_yaml_inp(input_yaml, spec):
"""
Expand All @@ -12,7 +17,7 @@ def parse_yaml_inp(input_yaml, spec):
https://validobj.readthedocs.io/en/latest/examples.html#yaml-line-numbers
"""
input_yaml = pathlib.Path(input_yaml)
inp = yaml.round_trip_load(input_yaml.open("r", encoding="utf-8"))
inp = yaml.load(input_yaml.read_text(encoding="utf-8"), Loader=Loader)
try:
return parse_input(inp, spec)
except ValidationError as e:
Expand Down
Loading