@@ -106,9 +106,9 @@ def evolve_fit(
106
106
else :
107
107
raise ValueError (f"dump_eko not provided and { eko_path = } not found" )
108
108
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 )
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
112
113
113
with eko .EKO .read (eko_path ) as eko_op :
114
114
# Read the cards directly from the eko to make sure they are consistent
@@ -126,18 +126,42 @@ def evolve_fit(
126
126
info ["XMax" ] = float (x_grid [- 1 ])
127
127
# Save the PIDs in the info file in the same order as in the evolution
128
128
info ["Flavors" ] = basis_rotation .flavor_basis_pids
129
- info ["NumFlavors" ] = theory . heavy . num_flavs_max_pdf
129
+ info ["NumFlavors" ] = 5 # TODO: Maximum number in evol
130
130
dump_info_file (usr_path , info )
131
131
132
- def _wrap_evolve (pdf , replica ):
133
- evolved_blocks = evolve_exportgrid (pdf , eko_op , x_grid )
134
- dump_evolved_replica (evolved_blocks , usr_path , int (replica .removeprefix ("replica_" )))
135
-
136
- # Choose the number of cores to be the Minimal value
137
- nb_cores = min (NUM_CORES , abs (ncores ))
138
- Parallel (n_jobs = nb_cores )(
139
- delayed (_wrap_evolve )(pdf , r ) for r , pdf in initial_PDFs_dict .items ()
140
- )
132
+ # Read the information from all replicas into what eko wants:
133
+ all_replicas = []
134
+ for pdf_data in initial_PDFs_dict .values ():
135
+ all_replicas .append (np .array (pdf_data ["pdfgrid" ]).T )
136
+
137
+ all_evolved , _ = apply .apply_grids (eko_op , np .array (all_replicas ))
138
+ #{(Q2, nf): (replica, flavour, x)}
139
+ nreplicas = len (all_replicas )
140
+ all_evolved = [{i : k [r ] for i ,k in all_evolved .items ()} for r in range (nreplicas )]
141
+
142
+ # Now, replica by replica, break into blocks
143
+ targetgrid = eko_op .xgrid .tolist ()
144
+ by_nf = defaultdict (list )
145
+ for q , nf in sorted (eko_op .evolgrid , key = lambda ep : ep [1 ]):
146
+ by_nf [nf ].append (q )
147
+ q2block_per_nf = {nf : sorted (qs ) for nf , qs in by_nf .items ()}
148
+
149
+ for replica , evolved_pdf in enumerate (all_evolved ):
150
+ blocks = []
151
+ for nf , q2grid in q2block_per_nf .items ():
152
+
153
+ def pdf_xq2 (pid , x , Q2 ):
154
+ x_idx = targetgrid .index (x )
155
+ pid_idx = info ["Flavors" ].index (pid )
156
+ return x * evolved_pdf [(Q2 , nf )][pid_idx ][x_idx ]
157
+ # return x * evolved_pdf[(Q2, nf)]["pdfs"][pid][x_idx]
158
+
159
+ block = genpdf .generate_block (
160
+ pdf_xq2 , xgrid = targetgrid , sorted_q2grid = q2grid , pids = basis_rotation .flavor_basis_pids
161
+ )
162
+ blocks .append (block )
163
+
164
+ dump_evolved_replica (blocks , usr_path , int (replica + 1 ))
141
165
142
166
# remove folder:
143
167
# The function dump_evolved_replica dumps the replica files in a temporary folder
@@ -188,6 +212,8 @@ def evolve_exportgrid(exportgrid, eko, x_grid):
188
212
"""
189
213
# construct LhapdfLike object
190
214
pdf_grid = np .array (exportgrid ["pdfgrid" ]).transpose ()
215
+
216
+
191
217
pdf_to_evolve = utils .LhapdfLike (pdf_grid , exportgrid ["q20" ], x_grid )
192
218
# evolve pdf
193
219
evolved_pdf = apply .apply_pdf (eko , pdf_to_evolve )
0 commit comments