ekobox.genpdf package
Create fake PDF sets for debugging.
- ekobox.genpdf.take_data(parent_pdf_set: str | dict | None = None, members: bool = False, xgrid: List[float] | None = None, evolgrid: List[Tuple[float, int]] | None = None)[source]
Auxiliary function for generate_pdf.
It provides the info, the heads of the member files and the blocks to be generated to generate_pdf.
- Returns:
info (dict) – info dictionary
heads (list(str)) – heads of member files if necessary
blocks (list(dict)) – data blocks
- ekobox.genpdf.generate_pdf(name: str, labels: List[int], parent_pdf_set=None, members=False, info_update=None, install: bool = False, xgrid: List[float] | None = None, evolgrid: List[Tuple[float, int]] | None = None)[source]
Generate a new PDF from a parent PDF with a set of flavors.
If parent_pdf_set is the name of an available PDF set, it will be used as parent. In order to use the toy PDF as parent, it is enough to set parent_pdf_set to “toy”. In order to use the toy Polarized PDF as parent, it is enough to set parent_pdf_set to “toy_pol”. If parent_pdf_set is not specified, a debug PDF constructed as x * (1-x) for every flavor will be used as parent. It is also possible to provide custom functions for each flavor in the form of a dictionary: {pid: f(x,Q2)}.
With labels it is possible to pass a list of PIDs or evolution basis combinations to keep in the generated PDF. In order to project on custom combinations of PIDs, it is also possible to pass a list containing the desired factors for each flavor.
The default behavior is to generate only one member for a PDF set (the zero member) but it can be changed setting to True the members flag.
The info_update argument is a dictionary and provide to the user as a way to change the info file of the generated PDF set. If a key of info_update matches with one key of the standard info file, the information are updated, otherwise they are simply added.
Turning True the value of the install flag, it is possible to automatically install the generated PDF to the lhapdf directory. By default install is False.
Examples
To generate a PDF with a fixed function f(x,Q2) for some flavors you can use the following snippet:
>>> # f = lambda x,Q2 ... put the desired function here >>> # mask = [list of active PIDs] >>> generate_pdf(name, labels, parent_pdf_set={pid: f for pid in mask})
The API also provides the possibility to extract arbitrary flavor combinations: using the debug PDF settings we can construct a “anti-QED-singlet” combination that is usefull in debugging DIS codes since it does not couple in LO, but only through the pure-singlet contributions (starting at NNLO)
>>> from eko import basis_rotation as br >>> from ekobox import genpdf >>> import numpy as np >>> anti_qed_singlet = np.zeros_like(br.flavor_basis_pids, dtype=np.float_) >>> anti_qed_singlet[br.flavor_basis_pids.index(1)] = -4 >>> anti_qed_singlet[br.flavor_basis_pids.index(-1)] = -4 >>> anti_qed_singlet[br.flavor_basis_pids.index(2)] = 1 >>> anti_qed_singlet[br.flavor_basis_pids.index(-2)] = 1 >>> genpdf.generate_pdf("anti_qed_singlet", [anti_qed_singlet])
- ekobox.genpdf.install_pdf(name)[source]
Install set into LHAPDF.
The set to be installed has to be in the current directory.
- Parameters:
name (str) – source pdf name
- ekobox.genpdf.generate_block(xfxQ2: Callable, xgrid: List[float], sorted_q2grid: List[float], pids: List[int]) dict [source]
Generate an LHAPDF data block from a callable.
Submodules
ekobox.genpdf.cli module
ekobox.genpdf.export module
PDF set writer.
- ekobox.genpdf.export.dump_blocks(name, member, blocks, pdf_type=None)[source]
Write LHAPDF data file.
- ekobox.genpdf.export.dump_info(name, info)[source]
Write LHAPDF info file.
NOTE: Since LHAPDF info files are not truely yaml files, we have to use a slightly more complicated function to dump the info file.
ekobox.genpdf.flavors module
Collection of flavor tools.
- ekobox.genpdf.flavors.pid_to_flavor(pids)[source]
Create flavor representations from PIDs.
- Parameters:
- Returns:
list of reprentations for each PID
- Return type:
- ekobox.genpdf.flavors.evol_to_flavor(labels)[source]
Create flavor representations from evolution members.
- Parameters:
- Returns:
list of reprentations for each distribution
- Return type:
- ekobox.genpdf.flavors.project(blocks, reprs)[source]
Project some combination of flavors defined by reprs from the blocks.
ekobox.genpdf.load module
PDF set elements loaders.