diff --git a/src/pineko/check.py b/src/pineko/check.py index 47c85771..a6f6b96a 100644 --- a/src/pineko/check.py +++ b/src/pineko/check.py @@ -76,15 +76,19 @@ def in1d(a, b, rtol=1e-05, atol=1e-08): ) -def check_grid_and_eko_compatible(pineappl_grid, operators, xif, max_as, max_al): - """Check whether the EKO operators and the PineAPPL grid are compatible. +def check_grid_and_eko_compatible( + pineappl_grid, eko_xgrid, eko_mu2, xif, max_as, max_al +): + """Check whether the EKO operator and the PineAPPL grid are compatible. Parameters ---------- pineappl_grid : pineappl.grid.Grid grid - operators : eko.EKO - operators + eko_xgrid : list + eko interpolation xgrid + eko_mu2: float + eko mu2 scale xif : float factorization scale variation max_as: int @@ -95,7 +99,7 @@ def check_grid_and_eko_compatible(pineappl_grid, operators, xif, max_as, max_al) Raises ------ ValueError - If the operators and the grid are not compatible. + If the operator and the grid are not compatible. """ order_mask = pineappl.grid.Order.create_mask( pineappl_grid.orders(), max_as, max_al, True @@ -104,14 +108,12 @@ def check_grid_and_eko_compatible(pineappl_grid, operators, xif, max_as, max_al) x_grid = evol_info.x1 muf2_grid = evol_info.fac1 # Q2 grid - if not np.all( - in1d(np.unique(list(operators.mu2grid)), xif * xif * np.array(muf2_grid)) - ): + if not np.all(in1d(np.array([eko_mu2]), xif * xif * np.array(muf2_grid))): raise ValueError( "Q2 grid in pineappl grid and eko operator are NOT compatible!" ) # x-grid - if not np.all(in1d(np.unique(operators.xgrid.tolist()), np.array(x_grid))): + if not np.all(in1d(np.unique(eko_xgrid), np.array(x_grid))): raise ValueError("x grid in pineappl grid and eko operator are NOT compatible!") diff --git a/src/pineko/cli/check.py b/src/pineko/cli/check.py index a515c017..19794744 100644 --- a/src/pineko/cli/check.py +++ b/src/pineko/cli/check.py @@ -38,13 +38,14 @@ def sub_compatibility(grid_path, operator_path, xif, max_as, max_al): """ pineappl_grid = pineappl.grid.Grid.read(grid_path) with eko.EKO.read(operator_path) as operators: - try: - check.check_grid_and_eko_compatible( - pineappl_grid, operators, xif, max_as, max_al - ) - rich.print("[green]Success:[/] grids are compatible") - except ValueError as e: - rich.print("[red]Error:[/]", e) + for (q2, _), _ in operators.items(): + try: + check.check_grid_and_eko_compatible( + pineappl_grid, operators.xgrid.tolist(), q2, xif, max_as, max_al + ) + except ValueError as e: + rich.print("[red]Error:[/]", e) + rich.print("[green]Success:[/] grids and eko are compatible.") @dataclass diff --git a/src/pineko/evolve.py b/src/pineko/evolve.py index 1842af6a..cf327ce7 100644 --- a/src/pineko/evolve.py +++ b/src/pineko/evolve.py @@ -365,11 +365,6 @@ def evolve_grid( tcard = operators1.theory_card opcard = operators1.operator_card - # TODO: do we still want to check here or only later ? - check.check_grid_and_eko_compatible(grid, operators1, xif, max_as, max_al) - if operators2 is not None: - check.check_grid_and_eko_compatible(grid, operators2, xif, max_as, max_al) - # PineAPPL wants alpha_s = 4*pi*a_s # remember that we already accounted for xif in the opcard generation evmod = eko.couplings.couplings_mod_ev(opcard.configs.evolution_method) @@ -404,6 +399,8 @@ def prepare(operator): """Match the raw operator with its relevant metadata.""" for (q2, _), op in operator.items(): op = xgrid_reshape(op, operator.xgrid) + # TODO: this check here could be dropped ? + check.check_grid_and_eko_compatible(grid, x_grid, q2, xif, max_as, max_al) info = PyOperatorSliceInfo( fac0=operator.mu20, x0=operator.xgrid.tolist(),