|
8 | 8 | import numpy as np |
9 | 9 |
|
10 | 10 | import eko |
| 11 | +from eko import basis_rotation, runner |
11 | 12 | from eko.interpolation import XGrid |
12 | 13 | from eko.io import manipulate |
13 | | -from eko import basis_rotation, runner |
14 | 14 | from reportengine.compat import yaml |
15 | 15 |
|
16 | 16 | from . import eko_utils, utils |
|
26 | 26 |
|
27 | 27 |
|
28 | 28 | def evolve_fit( |
29 | | - fit_folder, |
30 | | - q_fin, |
31 | | - q_points, |
32 | | - op_card_dict, |
33 | | - theory_card_dict, |
34 | | - force, |
35 | | - eko_path, |
36 | | - dump_eko=None, |
| 29 | + fit_folder, q_fin, q_points, op_card_dict, theory_card_dict, force, eko_path, dump_eko=None |
37 | 30 | ): |
38 | 31 | """ |
39 | 32 | Evolves all the fitted replica in fit_folder/nnfit |
@@ -128,12 +121,12 @@ def evolve_fit( |
128 | 121 | for rep_idx in range(1, n_replicas + 1): |
129 | 122 | # swap photon postion to match eko.basis_roation.flavor_basis_pids |
130 | 123 | pdfgrid = np.array(initial_PDFs_dict[f"replica_{rep_idx}"]["pdfgrid"]) |
131 | | - pdfgrid = np.append(pdfgrid[:,-1].reshape(x_grid.size,1), pdfgrid[:,:-1], axis=1) |
| 124 | + pdfgrid = np.append(pdfgrid[:, -1].reshape(x_grid.size, 1), pdfgrid[:, :-1], axis=1) |
132 | 125 | # and divide by x |
133 | | - all_replicas.append(pdfgrid.T / x_grid ) |
| 126 | + all_replicas.append(pdfgrid.T / x_grid) |
134 | 127 |
|
135 | 128 | # reshape the xgrid eko if necessary |
136 | | - if not XGrid(x_grid) == eko_op.xgrid: |
| 129 | + if XGrid(x_grid) != eko_op.xgrid: |
137 | 130 | for _, elem in eko_op.items(): |
138 | 131 | elem = manipulate.xgrid_reshape( |
139 | 132 | elem, |
@@ -201,53 +194,6 @@ def load_fit(usr_path): |
201 | 194 | return pdf_dict |
202 | 195 |
|
203 | 196 |
|
204 | | -def evolve_exportgrid(exportgrid, eko, x_grid): |
205 | | - """ |
206 | | - Evolves the provided exportgrid for the desired replica with the eko and returns the evolved block |
207 | | -
|
208 | | - Parameters |
209 | | - ---------- |
210 | | - exportgrid: dict |
211 | | - exportgrid of pdf at fitting scale |
212 | | - eko: eko object |
213 | | - eko operator for evolution |
214 | | - xgrid: list |
215 | | - xgrid to be used as the targetgrid |
216 | | - Returns |
217 | | - ------- |
218 | | - : list(np.array) |
219 | | - list of evolved blocks |
220 | | - """ |
221 | | - # construct LhapdfLike object |
222 | | - pdf_grid = np.array(exportgrid["pdfgrid"]).transpose() |
223 | | - |
224 | | - pdf_to_evolve = utils.LhapdfLike(pdf_grid, exportgrid["q20"], x_grid) |
225 | | - # evolve pdf |
226 | | - evolved_pdf = apply.apply_pdf(eko, pdf_to_evolve) |
227 | | - # generate block to dump |
228 | | - targetgrid = eko.bases.targetgrid.tolist() |
229 | | - |
230 | | - # Finally separate by nf block (and order per nf/q) |
231 | | - by_nf = defaultdict(list) |
232 | | - for q, nf in sorted(eko.evolgrid, key=lambda ep: ep[1]): |
233 | | - by_nf[nf].append(q) |
234 | | - q2block_per_nf = {nf: sorted(qs) for nf, qs in by_nf.items()} |
235 | | - |
236 | | - blocks = [] |
237 | | - for nf, q2grid in q2block_per_nf.items(): |
238 | | - |
239 | | - def pdf_xq2(pid, x, Q2): |
240 | | - x_idx = targetgrid.index(x) |
241 | | - return x * evolved_pdf[(Q2, nf)]["pdfs"][pid][x_idx] |
242 | | - |
243 | | - block = genpdf.generate_block( |
244 | | - pdf_xq2, xgrid=targetgrid, sorted_q2grid=q2grid, pids=basis_rotation.flavor_basis_pids |
245 | | - ) |
246 | | - blocks.append(block) |
247 | | - |
248 | | - return blocks |
249 | | - |
250 | | - |
251 | 197 | def dump_evolved_replica(evolved_blocks, usr_path, replica_num): |
252 | 198 | """ |
253 | 199 | Dump the evolved replica given by evolved_block as the replica num "replica_num" in |
|
0 commit comments