Skip to content

Commit 314abc2

Browse files
giacomomagniscarlehoff
authored andcommitted
sort replicas and dived by x
1 parent 5797865 commit 314abc2

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

n3fit/src/evolven3fit/evolve.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,35 +122,38 @@ def evolve_fit(
122122
info["NumFlavors"] = 5 # TODO: Maximum number in evol
123123
dump_info_file(usr_path, info)
124124

125-
# Read the information from all replicas into what eko wants:
125+
# Read the information from all the sorted replicas into what eko wants
126+
n_replicas = len(initial_PDFs_dict)
126127
all_replicas = []
127-
for pdf_data in initial_PDFs_dict.values():
128+
for rep_idx in range(1, n_replicas + 1):
128129
# swap photon postion to match eko.basis_roation.flavor_basis_pids
129-
pdfgrid = np.array(pdf_data["pdfgrid"])
130+
pdfgrid = np.array(initial_PDFs_dict[f"replica_{rep_idx}"]["pdfgrid"])
130131
pdfgrid = np.append(pdfgrid[:,-1].reshape(x_grid.size,1), pdfgrid[:,:-1], axis=1)
131-
all_replicas.append(pdfgrid.T)
132+
# and divide by x
133+
all_replicas.append(pdfgrid.T / x_grid )
132134

133135
# reshape the xgrid eko if necessary
134-
for _, elem in eko_op.items():
135-
elem = manipulate.xgrid_reshape(
136-
elem,
137-
eko_op.xgrid,
138-
op.configs.interpolation_polynomial_degree,
139-
targetgrid=XGrid(x_grid),
140-
inputgrid=XGrid(x_grid),
141-
)
136+
if not XGrid(x_grid) == eko_op.xgrid:
137+
for _, elem in eko_op.items():
138+
elem = manipulate.xgrid_reshape(
139+
elem,
140+
eko_op.xgrid,
141+
op.configs.interpolation_polynomial_degree,
142+
targetgrid=XGrid(x_grid),
143+
inputgrid=XGrid(x_grid),
144+
)
142145

143-
# {(Q2, nf): (replica, flavour, x)}
146+
# output is {(Q2, nf): (replica, flavour, x)}
144147
all_evolved, _ = apply.apply_grids(eko_op, np.array(all_replicas))
145148

146-
# Now, replica by replica, break into blocks
149+
# Now, replica by replica, break into nf blocks
147150
targetgrid = eko_op.xgrid.tolist()
148151
by_nf = defaultdict(list)
149152
for q2, nf in sorted(eko_op.evolgrid, key=lambda ep: ep[1]):
150153
by_nf[nf].append(q2)
151154
q2block_per_nf = {nf: sorted(q2s) for nf, q2s in by_nf.items()}
152155

153-
for replica in range(len(all_replicas)):
156+
for replica in range(n_replicas):
154157
blocks = []
155158
for nf, q2grid in q2block_per_nf.items():
156159

@@ -166,8 +169,7 @@ def pdf_xq2(pid, x, Q2):
166169
pids=basis_rotation.flavor_basis_pids,
167170
)
168171
blocks.append(block)
169-
170-
dump_evolved_replica(blocks, usr_path, int(replica + 1))
172+
dump_evolved_replica(blocks, usr_path, replica + 1)
171173

172174
# remove folder:
173175
# The function dump_evolved_replica dumps the replica files in a temporary folder

0 commit comments

Comments
 (0)