5
5
import sys
6
6
7
7
from ekobox import apply , genpdf , info_file
8
- from joblib import Parallel , delayed
9
8
import numpy as np
10
- import psutil
11
9
12
10
import eko
11
+ from eko .interpolation import XGrid
12
+ from eko .io import manipulate
13
13
from eko import basis_rotation , runner
14
14
from validphys .utils import yaml_safe
15
15
24
24
"level" : logging .DEBUG ,
25
25
}
26
26
27
- NUM_CORES = psutil .cpu_count (logical = False )
28
-
29
27
30
28
def evolve_fit (
31
29
fit_folder ,
@@ -106,11 +104,7 @@ def evolve_fit(
106
104
else :
107
105
raise ValueError (f"dump_eko not provided and { eko_path = } not found" )
108
106
109
- # with eko.EKO.edit(eko_path) as eko_op:
110
- # x_grid_obj = eko.interpolation.XGrid(x_grid)
111
- # eko.io.manipulate.xgrid_reshape(eko_op, targetgrid=x_grid_obj, inputgrid=x_grid_obj)
112
-
113
- with eko .EKO .read (eko_path ) as eko_op :
107
+ with eko .EKO .edit (eko_path ) as eko_op :
114
108
# Read the cards directly from the eko to make sure they are consistent
115
109
theory = eko_op .theory_card
116
110
op = eko_op .operator_card
@@ -126,19 +120,29 @@ def evolve_fit(
126
120
info ["XMax" ] = float (x_grid [- 1 ])
127
121
# Save the PIDs in the info file in the same order as in the evolution
128
122
info ["Flavors" ] = basis_rotation .flavor_basis_pids
129
- info ["NumFlavors" ] = 5 # TODO: Maximum number in evol
123
+ info ["NumFlavors" ] = 5 # TODO: Maximum number in evol
130
124
dump_info_file (usr_path , info )
131
125
132
126
# Read the information from all replicas into what eko wants:
133
127
all_replicas = []
134
128
for pdf_data in initial_PDFs_dict .values ():
135
129
all_replicas .append (np .array (pdf_data ["pdfgrid" ]).T )
136
130
131
+ # reshape the xgrid eko if necessary
132
+ for _ , elem in eko_op .items ():
133
+ elem = manipulate .xgrid_reshape (
134
+ elem ,
135
+ eko_op .xgrid ,
136
+ op .configs .interpolation_polynomial_degree ,
137
+ targetgrid = XGrid (x_grid ),
138
+ inputgrid = XGrid (x_grid ),
139
+ )
140
+
137
141
all_evolved , _ = apply .apply_grids (eko_op , np .array (all_replicas ))
138
- #{(Q2, nf): (replica, flavour, x)}
142
+ # {(Q2, nf): (replica, flavour, x)}
139
143
nreplicas = len (all_replicas )
140
- all_evolved = [{i : k [r ] for i ,k in all_evolved .items ()} for r in range (nreplicas )]
141
-
144
+ all_evolved = [{i : k [r ] for i , k in all_evolved .items ()} for r in range (nreplicas )]
145
+
142
146
# Now, replica by replica, break into blocks
143
147
targetgrid = eko_op .xgrid .tolist ()
144
148
by_nf = defaultdict (list )
@@ -154,10 +158,12 @@ def pdf_xq2(pid, x, Q2):
154
158
x_idx = targetgrid .index (x )
155
159
pid_idx = info ["Flavors" ].index (pid )
156
160
return x * evolved_pdf [(Q2 , nf )][pid_idx ][x_idx ]
157
- # return x * evolved_pdf[(Q2, nf)]["pdfs"][pid][x_idx]
158
161
159
162
block = genpdf .generate_block (
160
- pdf_xq2 , xgrid = targetgrid , sorted_q2grid = q2grid , pids = basis_rotation .flavor_basis_pids
163
+ pdf_xq2 ,
164
+ xgrid = targetgrid ,
165
+ sorted_q2grid = q2grid ,
166
+ pids = basis_rotation .flavor_basis_pids ,
161
167
)
162
168
blocks .append (block )
163
169
@@ -213,7 +219,6 @@ def evolve_exportgrid(exportgrid, eko, x_grid):
213
219
# construct LhapdfLike object
214
220
pdf_grid = np .array (exportgrid ["pdfgrid" ]).transpose ()
215
221
216
-
217
222
pdf_to_evolve = utils .LhapdfLike (pdf_grid , exportgrid ["q20" ], x_grid )
218
223
# evolve pdf
219
224
evolved_pdf = apply .apply_pdf (eko , pdf_to_evolve )
0 commit comments