Skip to content

Commit

Permalink
Merge pull request #181 from NNPDF/allow_different_ekos
Browse files Browse the repository at this point in the history
Allow evolution and convolution with different ekos for a single grid
  • Loading branch information
scarlehoff authored Aug 21, 2024
2 parents 938d334 + 8642572 commit c04f55f
Show file tree
Hide file tree
Showing 22 changed files with 1,058 additions and 809 deletions.
4 changes: 2 additions & 2 deletions benchmarks/bench_autosv.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def benchmark_compute_ren_sv_grid(test_files, tmp_path, test_pdf, lhapdf_path):
plusrensv_grid = pineappl.grid.Grid.read(plusrensv_grid_path)
sv_list = [(0.5, 1.0), (2.0, 1.0)] # Only ren sv have to be tested
bin_number = to_test_grid.bins()
to_test_res = to_test_grid.convolute_with_one(
to_test_res = to_test_grid.convolve_with_one(
2212,
pdf.xfxQ2,
pdf.alphasQ2,
Expand All @@ -49,7 +49,7 @@ def benchmark_compute_ren_sv_grid(test_files, tmp_path, test_pdf, lhapdf_path):
np.array([], dtype=bool),
sv_list,
).reshape(bin_number, len(sv_list))
plusrensv_res = plusrensv_grid.convolute_with_one(
plusrensv_res = plusrensv_grid.convolve_with_one(
2212,
pdf.xfxQ2,
pdf.alphasQ2,
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/bench_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ 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


def benchmark_convolute_cli(test_files, tmp_path):
def benchmark_convolve_cli(test_files, tmp_path):
grid_path = pathlib.Path(
test_files / "data/grids/400/HERA_NC_225GEV_EP_SIGMARED.pineappl.lz4"
)
Expand All @@ -95,7 +95,7 @@ def benchmark_convolute_cli(test_files, tmp_path):
runner = CliRunner()
result = runner.invoke(
command,
["convolute", str(grid_path), str(eko_path), str(fk_path), "2", "0"],
["convolve", str(fk_path), str(grid_path), "2", "0", str(eko_path)],
)
assert "Optimizing for Nf6Ind" in result.output

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bench_evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def benchmark_evolve_grid(tmp_path, lhapdf_path, test_files, test_pdf):
1.0,
1.0,
assumptions=assumptions,
comparison_pdf="NNPDF40_nnlo_as_01180",
comparison_pdf1="NNPDF40_nnlo_as_01180",
)
# check metadata is there - fixes https://github.com/NNPDF/pineko/issues/70
fk = pineappl.fk_table.FkTable.read(target_path)
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/bench_kfactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def benchmark_kfactor_inclusion(test_files, tmp_path, test_pdf, lhapdf_path):
order_mask_nnloQCD = pineappl.grid.Order.create_mask(
pluskfactor_grid.orders(), 3, 0, True
)
to_test_res_nlo = pluskfactor_grid.convolute_with_one(
to_test_res_nlo = pluskfactor_grid.convolve_with_one(
2212,
pdf.xfxQ2,
pdf.alphasQ2,
Expand All @@ -37,7 +37,7 @@ def benchmark_kfactor_inclusion(test_files, tmp_path, test_pdf, lhapdf_path):
np.array([], dtype=bool),
sv_list,
).reshape(bin_number, len(sv_list))
to_test_res_nnlo = pluskfactor_grid.convolute_with_one(
to_test_res_nnlo = pluskfactor_grid.convolve_with_one(
2212,
pdf.xfxQ2,
pdf.alphasQ2,
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/bench_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ def benchmark_regression(tmp_path, dataset):
fkt = FkTable.read(
tmp_path / "data" / "fktables" / str(THEORYID) / f"{grid_name}.pineappl.lz4"
)
result.append(fkt.convolute_with_one(2212, pdf.xfxQ2))
result.append(fkt.convolve_with_one(2212, pdf.xfxQ2))
result = np.concatenate(result)

if not regression_path.exists():
np.save(regression_path, result)
raise FileNotFoundError("Regression did not exist and has been regenerated")

regression_data = np.load(regression_path)
np.testing.assert_allclose(regression_data, result)
np.testing.assert_allclose(regression_data, result, rtol=4e-6)
13 changes: 9 additions & 4 deletions benchmarks/bench_theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ def benchmark_inherit_grids(test_files):


def benchmark_inherit_eko(tmp_path):
from_eko = theory_obj.ekos_path()
theory_obj.inherit_eko("TestEko", from_eko, tmp_path)
for grid in theory_obj.grids_path().iterdir():
name = grid.stem.split(".")[0]
# here NUTEV eko is not present
if (theory_obj.ekos_path() / f"{name}.tar").exists():
theory_obj.inherit_eko(name, grid, tmp_path)
assert tmp_path.is_dir()
assert (tmp_path / f"{name}.tar").exists()


def benchmark_inherit_ekos(test_files):
Expand Down Expand Up @@ -166,9 +171,9 @@ def benchmark_fk(test_files, test_configs):
)
theory_obj_hera.opcard(grid_name, pathlib.Path(test_files / grid_path), tcard)

theory_obj_hera.fk(grid_name, grid_path, tcard, pdf=None)
theory_obj_hera.fk(grid_name, grid_path, tcard, pdf1=None, pdf2=None)
# test overwrite function
theory_obj_hera.fk(grid_name, grid_path, tcard, pdf=None)
theory_obj_hera.fk(grid_name, grid_path, tcard, pdf1=None, pdf2=None)
log_path = pathlib.Path(test_files / "logs/fk/400-HERA_NC_225GEV_EP_SIGMARED.log")
if os.path.exists(log_path):
os.remove(log_path)
Expand Down
10 changes: 5 additions & 5 deletions docs/source/overview/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ Generating the FK Table
-----------------------

You need to have the |EKO| computed in the previous step.
Then you can convolute the |EKO| with the grids by running::
Then you can convolve the |EKO| with the grids by running::

pineko theory fks THEORY_ID DATASET1 DATASET2 ...

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

pineko convolute GRID OPCARD FKTABLE MAX_AS MAX_AL
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 @@ -89,9 +89,9 @@ Comparing grids and FK tables
"""""""""""""""""""""""""""""

With the command ``pineko compare`` it is possible to compare the predictions as provided by the grid
(convoluted with a |PDF|) with the predictions as provided by the |FK| table. This is done like
(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
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
Loading

0 comments on commit c04f55f

Please sign in to comment.