Skip to content

Commit

Permalink
first round of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomomagni committed Jul 24, 2024
1 parent bbfc210 commit 2553fe1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions benchmarks/bench_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def benchmark_compare_cli(lhapdf_path, test_files, test_pdf):
with lhapdf_path(test_pdf):
result = runner.invoke(
command,
["compare", str(grid_path), str(fk_path), "2", "0", "NNPDF40_nlo_as_01180"],
["compare", str(fk_path), str(grid_path), "2", "0", "NNPDF40_nlo_as_01180"],
)
assert "yll left" in result.output

Expand All @@ -95,7 +95,7 @@ def benchmark_convolve_cli(test_files, tmp_path):
runner = CliRunner()
result = runner.invoke(
command,
["convolve", str(grid_path), str(fk_path), "2", "0", str(eko_path)],
["convolve", str(fk_path), str(grid_path), "2", "0", str(eko_path)],
)
assert "Optimizing for Nf6Ind" in result.output

Expand Down
4 changes: 2 additions & 2 deletions docs/source/overview/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Then you can convolve the |EKO| with the grids by running::

Note that you can also convolve a single grid with a single eko (obtaining a single FK table) by running::

pineko convolve GRID FKTABLE MAX_AS MAX_AL OP_PATH_1 OP_PATH_2
pineko convolve FKTABLE GRID MAX_AS MAX_AL OP_PATH_1 OP_PATH_2

If necessary it is possible to specify the values of the *renormalization* and *factorization* scale variations with
the options ``--xir`` and ``--xif``.
Expand Down Expand Up @@ -91,7 +91,7 @@ Comparing grids and FK tables
With the command ``pineko compare`` it is possible to compare the predictions as provided by the grid
(convolved with a |PDF|) with the predictions as provided by the |FK| table. This is done like

pineko compare GRID FKTABLE MAX_AS MAX_AL PDF_1 PDF_2
pineko compare FKTABLE GRID MAX_AS MAX_AL PDF_1 PDF_2

again eventually specifying the values of *renormalization* and *factorization* scales with the
appropriate options.
Expand Down
6 changes: 3 additions & 3 deletions src/pineko/cli/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@


@command.command("compare")
@click.argument("pineappl_path", type=click.Path(exists=True))
@click.argument("fktable_path", type=click.Path())
@click.argument("grid_path", type=click.Path(exists=True))
@click.argument("max_as", type=int)
@click.argument("max_al", type=int)
@click.argument("pdfs", type=click.STRING, nargs=-1)
@click.option("--xir", default=1.0, help="renormalization scale variation")
@click.option("--xif", default=1.0, help="factorization scale variation")
def subcommand(pineappl_path, fktable_path, max_as, max_al, pdfs, xir, xif):
def subcommand(fktable_path, grid_path, max_as, max_al, pdfs, xir, xif):
"""Compare process level PineAPPL grid and derived FK Table.
The comparison between the grid stored at PINEAPPL_PATH, and the FK table
Expand All @@ -29,7 +29,7 @@ def subcommand(pineappl_path, fktable_path, max_as, max_al, pdfs, xir, xif):
XIR and XIF represent the renormalization and factorization scale in the grid respectively.
"""
pine = pineappl.grid.Grid.read(pineappl_path)
pine = pineappl.grid.Grid.read(grid_path)
fk = pineappl.fk_table.FkTable.read(fktable_path)
pdf1 = pdfs[0]
pdf2 = pdfs[1] if len(pdfs) == 2 else None
Expand Down
7 changes: 4 additions & 3 deletions src/pineko/cli/convolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


@command.command("convolve")
@click.argument("grid_path", type=click.Path(exists=True))
@click.argument("fktable", type=click.Path())
@click.argument("grid_path", type=click.Path(exists=True))
@click.argument("max_as", type=int)
@click.argument("max_al", type=int)
@click.argument("op_paths", type=click.Path(exists=True), nargs=-1)
Expand All @@ -34,8 +34,8 @@
show_default=True,
)
def subcommand(
grid_path,
fktable,
grid_path,
max_as,
max_al,
op_paths,
Expand Down Expand Up @@ -72,7 +72,8 @@ def subcommand(
rich.print(
rich.panel.Panel.fit("Computing ...", style="magenta", box=rich.box.SQUARE),
f" {grid_path}\n",
f"+ {op_paths}\n",
f"+ {op_paths[0]}\n",
f"+ {op_paths[1]}\n" if n_ekos > 1 else "",
f"= {fktable}\n",
f"with max_as={max_as}, max_al={max_al}, xir={xir}, xif={xif}",
f"min_as: {min_as}" if min_as is not None else "",
Expand Down
15 changes: 6 additions & 9 deletions src/pineko/comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ def compare(pine, fktable, max_as, max_al, pdf1, xir, xif, pdf2=None):
import lhapdf # pylint: disable=import-error,import-outside-toplevel

pdfset1 = lhapdf.mkPDF(pdf1, 0)
pdgid1 = int(pdfset1.set().get_entry("Particle"))

if pdf2 is not None:
pdfset2 = lhapdf.mkPDF(pdf1, 0)
pdgid2 = int(pdfset2.set().get_entry("Particle"))
else:
pdfset2 = pdfset1
pdgid2 = pdgid1

# TODO: This should probably changed in the future to use the Grid::convolutions
try:
parton1 = pine.key_values()["convolution_particle_1"]
parton2 = pine.key_values()["convolution_particle_2"]
Expand All @@ -56,29 +53,29 @@ def compare(pine, fktable, max_as, max_al, pdf1, xir, xif, pdf2=None):
if hadronic:
before = np.array(
pine.convolve_with_two(
pdg_id1=pdgid1,
pdg_id1=parton1,
xfx1=pdfset1.xfxQ2,
pdg_id2=pdgid2,
pdg_id2=parton2,
xfx2=pdfset2.xfxQ2,
alphas=pdfset1.alphasQ2,
order_mask=order_mask,
xi=((xir, xif),),
)
)
after = np.array(
fktable.convolve_with_two(pdgid1, pdfset1.xfxQ2, pdgid2, pdfset2.xfxQ2)
fktable.convolve_with_two(parton1, pdfset1.xfxQ2, parton2, pdfset2.xfxQ2)
)
else:
before = np.array(
pine.convolve_with_one(
pdgid1,
parton1,
pdfset1.xfxQ2,
pdfset1.alphasQ2,
order_mask=order_mask,
xi=((xir, xif),),
)
)
after = np.array(fktable.convolve_with_one(pdgid1, pdfset1.xfxQ2))
after = np.array(fktable.convolve_with_one(parton1, pdfset1.xfxQ2))

df = pd.DataFrame()
# add bin info
Expand Down
7 changes: 4 additions & 3 deletions src/pineko/evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,16 @@ def get_ekos_convolution_type(kv):
kv: dict
pineappl grid metadata
"""
# TODO: This should probably changed in the future to use the Grid::convolutions
if "convolution_type_1" in kv:
conv_type_1 = kv["convolution_type_1"]
# TODO: this case is now deprecated and should be remved from yadism and pinefarm
# TODO: polarized is now deprecated, needed for compatibility
elif "polarized" in kv and kv["polarized"]:
conv_type_1 = "PolPDF"
else:
conv_type_1 = "UnpolPDF"

# TODO: initial_state_2 is now deprecated, needed for comatibility
# TODO: initial_state_2 is now deprecated, needed for compatibility
if "convolution_particle_2" in kv:
part_2 = kv["convolution_particle_2"]
else:
Expand Down Expand Up @@ -413,7 +414,7 @@ def prepare(operator, items):
fktable.set_key_value("eko_operator_card", json.dumps(operators1.operator_card.raw))
if operators2 is not None:
fktable.set_key_value(
"eko_operator_card_b", json.dumps(operators2.operator_card.raw)
"eko_operator_card_2", json.dumps(operators2.operator_card.raw)
)

fktable.set_key_value("pineko_version", version.__version__)
Expand Down

0 comments on commit 2553fe1

Please sign in to comment.