From 56c7ba8ad52a8227b0a1974c1511f762c72a9bb7 Mon Sep 17 00:00:00 2001 From: giacomomagni Date: Tue, 14 Mar 2023 10:18:14 +0100 Subject: [PATCH 1/5] make toyLH polarized from genpdf --- src/ekobox/genpdf/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ekobox/genpdf/__init__.py b/src/ekobox/genpdf/__init__.py index ae82f106b..3a8d65be4 100644 --- a/src/ekobox/genpdf/__init__.py +++ b/src/ekobox/genpdf/__init__.py @@ -60,6 +60,13 @@ def take_data(parent_pdf_set=None, members=False, xgrid=None, Q2grid=None): all_blocks.append( [generate_block(toylh.xfxQ2, xgrid, Q2grid, br.flavor_basis_pids)] ) + elif parent_pdf_set in ["toylh_polarized", "toy_pol"]: + info = copy.deepcopy(load.Toy_info) + toylh = toy.mkPDF("ToyLH_polarized", 0) + all_blocks.append( + [generate_block(toylh.xfxQ2, xgrid, Q2grid, br.flavor_basis_pids)] + ) + else: info = load.load_info_from_file(parent_pdf_set) # iterate on members @@ -104,6 +111,8 @@ def generate_pdf( If `parent_pdf_set` is the name of an available PDF set, it will be used as parent. In order to use the toy PDF as parent, it is enough to set `parent_pdf_set` to "toy" or "toylh". + In order to use the toy Polarized PDF + as parent, it is enough to set `parent_pdf_set` to "toylh_polarized" or "toy_pol". If `parent_pdf_set` is not specified, a debug PDF constructed as x * (1-x) for every flavor will be used as parent. It is also possible to provide custom functions for each flavor @@ -114,7 +123,7 @@ def generate_pdf( on custom combinations of PIDs, it is also possible to pass a list containing the desired factors for each flavor. - The default behaviour is to generate only one member for a PDF set + The default behavior is to generate only one member for a PDF set (the zero member) but it can be changed setting to True the `members` flag. The `info_update` argument is a dictionary and provide to the user as a way From 55a678798ec55060d7cb2504512980e9cc3951eb Mon Sep 17 00:00:00 2001 From: giacomomagni Date: Tue, 14 Mar 2023 12:48:59 +0100 Subject: [PATCH 2/5] delay banana import stament in genpdf --- src/ekobox/genpdf/__init__.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ekobox/genpdf/__init__.py b/src/ekobox/genpdf/__init__.py index 3a8d65be4..c07784cad 100644 --- a/src/ekobox/genpdf/__init__.py +++ b/src/ekobox/genpdf/__init__.py @@ -5,7 +5,6 @@ import shutil import numpy as np -from banana import toy from eko import basis_rotation as br @@ -54,15 +53,16 @@ def take_data(parent_pdf_set=None, members=False, xgrid=None, Q2grid=None): pid: lambda x, _Q2: x * (1 - x) for pid in br.flavor_basis_pids } if isinstance(parent_pdf_set, str): - if parent_pdf_set in ["toylh", "toy"]: - info = copy.deepcopy(load.Toy_info) - toylh = toy.mkPDF("", 0) - all_blocks.append( - [generate_block(toylh.xfxQ2, xgrid, Q2grid, br.flavor_basis_pids)] - ) - elif parent_pdf_set in ["toylh_polarized", "toy_pol"]: + if parent_pdf_set in ["toy_pol", "toy"]: + # import banana only here to avoid + # explict dependecy + from banana import toy + info = copy.deepcopy(load.Toy_info) - toylh = toy.mkPDF("ToyLH_polarized", 0) + if "pol" in parent_pdf_set: + toylh = toy.mkPDF("ToyLH_polarized", 0) + else: + toylh = toy.mkPDF("", 0) all_blocks.append( [generate_block(toylh.xfxQ2, xgrid, Q2grid, br.flavor_basis_pids)] ) @@ -110,9 +110,9 @@ def generate_pdf( If `parent_pdf_set` is the name of an available PDF set, it will be used as parent. In order to use the toy PDF - as parent, it is enough to set `parent_pdf_set` to "toy" or "toylh". + as parent, it is enough to set `parent_pdf_set` to "toy". In order to use the toy Polarized PDF - as parent, it is enough to set `parent_pdf_set` to "toylh_polarized" or "toy_pol". + as parent, it is enough to set `parent_pdf_set` to "toy_pol". If `parent_pdf_set` is not specified, a debug PDF constructed as x * (1-x) for every flavor will be used as parent. It is also possible to provide custom functions for each flavor From 7a19e5695adbe594994e071d9b74d3b625d1d97b Mon Sep 17 00:00:00 2001 From: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:13:44 +0100 Subject: [PATCH 3/5] Update src/ekobox/genpdf/__init__.py --- src/ekobox/genpdf/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ekobox/genpdf/__init__.py b/src/ekobox/genpdf/__init__.py index c07784cad..d85c4ee28 100644 --- a/src/ekobox/genpdf/__init__.py +++ b/src/ekobox/genpdf/__init__.py @@ -55,7 +55,7 @@ def take_data(parent_pdf_set=None, members=False, xgrid=None, Q2grid=None): if isinstance(parent_pdf_set, str): if parent_pdf_set in ["toy_pol", "toy"]: # import banana only here to avoid - # explict dependecy + # explict dependency from banana import toy info = copy.deepcopy(load.Toy_info) From c8391c65223cb415b1847476843269386a9b308f Mon Sep 17 00:00:00 2001 From: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:14:44 +0100 Subject: [PATCH 4/5] Update src/ekobox/genpdf/__init__.py --- src/ekobox/genpdf/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ekobox/genpdf/__init__.py b/src/ekobox/genpdf/__init__.py index d85c4ee28..1835e620d 100644 --- a/src/ekobox/genpdf/__init__.py +++ b/src/ekobox/genpdf/__init__.py @@ -55,7 +55,7 @@ def take_data(parent_pdf_set=None, members=False, xgrid=None, Q2grid=None): if isinstance(parent_pdf_set, str): if parent_pdf_set in ["toy_pol", "toy"]: # import banana only here to avoid - # explict dependency + # explicit dependency from banana import toy info = copy.deepcopy(load.Toy_info) From 6fee873e91b933a9291727c6365f340e722344a0 Mon Sep 17 00:00:00 2001 From: giacomomagni Date: Tue, 14 Mar 2023 16:30:46 +0100 Subject: [PATCH 5/5] restore banana import at top level --- src/ekobox/genpdf/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ekobox/genpdf/__init__.py b/src/ekobox/genpdf/__init__.py index 1835e620d..30185d69b 100644 --- a/src/ekobox/genpdf/__init__.py +++ b/src/ekobox/genpdf/__init__.py @@ -5,6 +5,7 @@ import shutil import numpy as np +from banana import toy from eko import basis_rotation as br @@ -54,10 +55,6 @@ def take_data(parent_pdf_set=None, members=False, xgrid=None, Q2grid=None): } if isinstance(parent_pdf_set, str): if parent_pdf_set in ["toy_pol", "toy"]: - # import banana only here to avoid - # explicit dependency - from banana import toy - info = copy.deepcopy(load.Toy_info) if "pol" in parent_pdf_set: toylh = toy.mkPDF("ToyLH_polarized", 0)