From 1960c7ca15e5a76fac65a77d45575fd6d4fef59f Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Mon, 18 Sep 2023 11:46:54 +0200 Subject: [PATCH 1/6] Rotate the eko back to save disk space --- src/pineko/evolve.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pineko/evolve.py b/src/pineko/evolve.py index 86adac06..5b1790d6 100644 --- a/src/pineko/evolve.py +++ b/src/pineko/evolve.py @@ -246,6 +246,10 @@ def evolve_grid( order_mask=order_mask, xi=(xir, xif), ) + # Rotate again the eko to save disk space + eko.io.manipulate.xgrid_reshape( + operators, targetgrid=opcard.xgrid + ) rich.print(f"Optimizing for {assumptions}") fktable.optimize(assumptions) fktable.set_key_value("eko_version", operators.metadata.version) From 5016b86b5c552cde1d1790cc6b75f8a5cd283ff4 Mon Sep 17 00:00:00 2001 From: Giacomo Magni Date: Tue, 19 Sep 2023 09:36:04 +0200 Subject: [PATCH 2/6] copy original operator instead of reinterpolate --- src/pineko/evolve.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pineko/evolve.py b/src/pineko/evolve.py index 5b1790d6..2658d838 100644 --- a/src/pineko/evolve.py +++ b/src/pineko/evolve.py @@ -202,6 +202,7 @@ def evolve_grid( # rotate the targetgrid if "integrability_version" in grid.key_values(): x_grid = np.append(x_grid, 1.0) + orignal_operators = copy.deepcopy(operators) eko.io.manipulate.xgrid_reshape( operators, targetgrid=eko.interpolation.XGrid(x_grid) ) @@ -246,10 +247,8 @@ def evolve_grid( order_mask=order_mask, xi=(xir, xif), ) - # Rotate again the eko to save disk space - eko.io.manipulate.xgrid_reshape( - operators, targetgrid=opcard.xgrid - ) + # Save only the original operator to save disk space + operators = orignal_operators rich.print(f"Optimizing for {assumptions}") fktable.optimize(assumptions) fktable.set_key_value("eko_version", operators.metadata.version) From d5719420efb97d7d6ec324d567fb6a367f207a3c Mon Sep 17 00:00:00 2001 From: Giacomo Magni Date: Tue, 19 Sep 2023 12:13:21 +0200 Subject: [PATCH 3/6] another try --- src/pineko/evolve.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pineko/evolve.py b/src/pineko/evolve.py index 2658d838..ccd85778 100644 --- a/src/pineko/evolve.py +++ b/src/pineko/evolve.py @@ -202,16 +202,16 @@ def evolve_grid( # rotate the targetgrid if "integrability_version" in grid.key_values(): x_grid = np.append(x_grid, 1.0) - orignal_operators = copy.deepcopy(operators) + new_operators = copy.deepcopy(operators) eko.io.manipulate.xgrid_reshape( - operators, targetgrid=eko.interpolation.XGrid(x_grid) + new_operators, targetgrid=eko.interpolation.XGrid(x_grid) ) - check.check_grid_and_eko_compatible(grid, operators, xif, max_as, max_al) + check.check_grid_and_eko_compatible(grid, new_operators, xif, max_as, max_al) # rotate to evolution (if doable and necessary) - if np.allclose(operators.bases.inputpids, br.flavor_basis_pids): - eko.io.manipulate.to_evol(operators) + if np.allclose(new_operators.bases.inputpids, br.flavor_basis_pids): + eko.io.manipulate.to_evol(new_operators) # Here we are checking if the EKO contains the rotation matrix (flavor to evol) - elif not np.allclose(operators.bases.inputpids, br.rotate_flavor_to_evolution): + elif not np.allclose(new_operators.bases.inputpids, br.rotate_flavor_to_evolution): raise ValueError("The EKO is neither in flavor nor in evolution basis.") # PineAPPL wants alpha_s = 4*pi*a_s # remember that we already accounted for xif in the opcard generation @@ -240,7 +240,7 @@ def evolve_grid( ] # We need to use ekompatibility in order to pass a dictionary to pineappl fktable = grid.evolve( - ekompatibility.pineappl_layout(operators), + ekompatibility.pineappl_layout(new_operators), xir * xir * mur2_grid, alphas_values, "evol", @@ -248,7 +248,7 @@ def evolve_grid( xi=(xir, xif), ) # Save only the original operator to save disk space - operators = orignal_operators + del new_operators rich.print(f"Optimizing for {assumptions}") fktable.optimize(assumptions) fktable.set_key_value("eko_version", operators.metadata.version) From 9f67dc97ef4c5c86ec78afaf624ccf9248c935d2 Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Tue, 19 Sep 2023 16:17:57 +0200 Subject: [PATCH 4/6] Deepcopy the operators --- src/pineko/evolve.py | 15 ++++++--------- src/pineko/theory.py | 8 +++++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/pineko/evolve.py b/src/pineko/evolve.py index ccd85778..86adac06 100644 --- a/src/pineko/evolve.py +++ b/src/pineko/evolve.py @@ -202,16 +202,15 @@ def evolve_grid( # rotate the targetgrid if "integrability_version" in grid.key_values(): x_grid = np.append(x_grid, 1.0) - new_operators = copy.deepcopy(operators) eko.io.manipulate.xgrid_reshape( - new_operators, targetgrid=eko.interpolation.XGrid(x_grid) + operators, targetgrid=eko.interpolation.XGrid(x_grid) ) - check.check_grid_and_eko_compatible(grid, new_operators, xif, max_as, max_al) + check.check_grid_and_eko_compatible(grid, operators, xif, max_as, max_al) # rotate to evolution (if doable and necessary) - if np.allclose(new_operators.bases.inputpids, br.flavor_basis_pids): - eko.io.manipulate.to_evol(new_operators) + if np.allclose(operators.bases.inputpids, br.flavor_basis_pids): + eko.io.manipulate.to_evol(operators) # Here we are checking if the EKO contains the rotation matrix (flavor to evol) - elif not np.allclose(new_operators.bases.inputpids, br.rotate_flavor_to_evolution): + elif not np.allclose(operators.bases.inputpids, br.rotate_flavor_to_evolution): raise ValueError("The EKO is neither in flavor nor in evolution basis.") # PineAPPL wants alpha_s = 4*pi*a_s # remember that we already accounted for xif in the opcard generation @@ -240,15 +239,13 @@ def evolve_grid( ] # We need to use ekompatibility in order to pass a dictionary to pineappl fktable = grid.evolve( - ekompatibility.pineappl_layout(new_operators), + ekompatibility.pineappl_layout(operators), xir * xir * mur2_grid, alphas_values, "evol", order_mask=order_mask, xi=(xir, xif), ) - # Save only the original operator to save disk space - del new_operators rich.print(f"Optimizing for {assumptions}") fktable.optimize(assumptions) fktable.set_key_value("eko_version", operators.metadata.version) diff --git a/src/pineko/theory.py b/src/pineko/theory.py index acfb9f5b..a9ffdc5c 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -395,8 +395,11 @@ def fk(self, name, grid_path, tcard, pdf): if sv_method is None: if not np.isclose(xif, 1.0): check_scvar_evolve(grid, max_as, max_al, check.Scale.FACT) - # loading ekos + # loading ekos to produce a tmp copy with eko.EKO.edit(eko_filename) as operators: + eko_tmp_path = operators.paths.root.parent / "eko-tmp" + operators.deepcopy(eko_tmp_path) + with eko.EKO.edit(eko_tmp_path) as operators: # Obtain the assumptions hash assumptions = theory_card.construct_assumptions(tcard) # do it! @@ -430,6 +433,9 @@ def fk(self, name, grid_path, tcard, pdf): assumptions=assumptions, comparison_pdf=pdf, ) + # Remove tmp ekos + eko_tmp_path.unlink() + logger.info( "Finished computation of %s - took %f s", name, From d7ef1b8187b0031193c272f664b693bd59d6bf9f Mon Sep 17 00:00:00 2001 From: Andrea Barontini Date: Wed, 20 Sep 2023 12:05:56 +0200 Subject: [PATCH 5/6] Update src/pineko/theory.py Co-authored-by: Felix Hekhorn --- src/pineko/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pineko/theory.py b/src/pineko/theory.py index a9ffdc5c..c274ce5e 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -397,7 +397,7 @@ def fk(self, name, grid_path, tcard, pdf): check_scvar_evolve(grid, max_as, max_al, check.Scale.FACT) # loading ekos to produce a tmp copy with eko.EKO.edit(eko_filename) as operators: - eko_tmp_path = operators.paths.root.parent / "eko-tmp" + eko_tmp_path = operators.paths.root.parent / "eko-tmp.tar" operators.deepcopy(eko_tmp_path) with eko.EKO.edit(eko_tmp_path) as operators: # Obtain the assumptions hash From 8b2a63455585c8873980b958da7c1f3853d46cf2 Mon Sep 17 00:00:00 2001 From: andreab1997 Date: Wed, 20 Sep 2023 12:08:29 +0200 Subject: [PATCH 6/6] Use EKO.read instead of EKO.edit --- src/pineko/theory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pineko/theory.py b/src/pineko/theory.py index c274ce5e..899d8f66 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -396,7 +396,7 @@ def fk(self, name, grid_path, tcard, pdf): if not np.isclose(xif, 1.0): check_scvar_evolve(grid, max_as, max_al, check.Scale.FACT) # loading ekos to produce a tmp copy - with eko.EKO.edit(eko_filename) as operators: + with eko.EKO.read(eko_filename) as operators: eko_tmp_path = operators.paths.root.parent / "eko-tmp.tar" operators.deepcopy(eko_tmp_path) with eko.EKO.edit(eko_tmp_path) as operators: