Skip to content

Commit

Permalink
fix inherit ekos
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomomagni committed Jul 8, 2024
1 parent c503f6f commit 453bc45
Showing 1 changed file with 38 additions and 21 deletions.
59 changes: 38 additions & 21 deletions src/pineko/theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@
logger = logging.getLogger(__name__)


def get_eko_names(grid, name):
"""Find eko names.
Parameters
----------
name : str
grid name, i.e. it's true stem
grid : pathlib.Path
path to grid
"""
grid_kv = pineappl.grid.Grid.read(grid).key_values()
conv_type_a, conv_type_b = evolve.get_ekos_convolution_type(grid_kv)
names = []
if conv_type_b is None or conv_type_a == conv_type_b:
names = [name]
else:
names = [
f"{name}_{conv_type_a}",
f"{name}_{conv_type_b}",
]
return names


def check_scvar_evolve(grid, max_as, max_al, kind: check.Scale):
"""Check scale variations and central orders consistency."""
available, max_as_effective = check.contains_sv(grid, max_as, max_al, kind)
Expand Down Expand Up @@ -169,7 +192,7 @@ def inherit_grids(self, target_theory_id):
other.mkdir(exist_ok=True)
self.iterate(self.inherit_grid, other=other)

def inherit_eko(self, name, _grid, other):
def inherit_eko(self, name, grid, other):
"""Inherit a EKO to a new theory.
Parameters
Expand All @@ -181,17 +204,19 @@ def inherit_eko(self, name, _grid, other):
other : pathlib.Path
new folder
"""
eko_path = self.ekos_path() / f"{name}.tar"
new = other / f"{name}.tar"
if new.exists():
if not self.overwrite:
rich.print(f"Skipping existing eko {new}")
return
new.unlink()
# link
new.symlink_to(eko_path)
if new.exists():
rich.print(f"[green]Success:[/] Created link at {new}")
names = get_eko_names(grid, name)
for name in names:
eko_path = self.ekos_path() / f"{name}.tar"
new = other / f"{name}.tar"
if new.exists():
if not self.overwrite:
rich.print(f"Skipping existing eko {new}")
return
new.unlink()
# link
new.symlink_to(eko_path)
if new.exists():
rich.print(f"[green]Success:[/] Created link at {new}")

def inherit_ekos(self, target_theory_id):
"""Inherit ekos to a new theory.
Expand Down Expand Up @@ -320,15 +345,7 @@ def eko(self, name, grid, tcard):
paths["logs"]["eko"], f"{self.theory_id}-{name}.log", ("eko",)
)
# setup data
grid_kv = pineappl.grid.Grid.read(grid).key_values()
conv_type_a, conv_type_b = evolve.get_ekos_convolution_type(grid_kv)
if conv_type_b is None or conv_type_a == conv_type_b:
names = [name]
else:
names = [
f"{name}_{conv_type_a}",
f"{name}_{conv_type_b}",
]
names = get_eko_names(grid, name)

for name in names:
ocard = self.load_operator_card(name)
Expand Down

0 comments on commit 453bc45

Please sign in to comment.