Skip to content

Allow the n3fit-vp interface to make use of more than 1 members

Emanuele Roberto Nocera requested to merge use_n3pdf_interface_with_members into master

Created by: scarlehoff

Until now the n3pdf class worked only with the central value (and returned that to vp whenever it asked).

This is a step towards having measures that might depend on more than one replica without having to "get out" of n3fit to generate the lhapdf grids and so on. One example:

import numpy as np
from n3fit.vpinterface import N3PDF
from n3fit.model_gen import pdfNN_layer_generator
from validphys.pdfgrids import xplotting_grid, distance_grids
fake_fl = [{'fl' : i, 'largex' : [0,1], 'smallx': [1,2]} for i in ['u', 'ubar', 'd', 'dbar', 'c', 'cbar', 's', 'sbar']]
fake_x = np.linspace(1e-3,0.8,10)

# Generate two PDFs
grids = []
pdfs = []

for i in range(2):
    pdf_models = pdfNN_layer_generator(nodes=[2, 8], activations=['tanh', 'linear'], seed=i, flav_info=fake_fl, parallel_models=10)
    n3pdf = N3PDF(pdf_models, name=f"n3f_{i}")
    res = xplotting_grid(n3pdf, 1.6, fake_x)
    pdfs.append(n3pdf)
    grids.append(res)

distances = distance_grids(pdfs, grids, 0)

I'll add some tests tomorrow and then I'll mark it for review.

Merge request reports

Loading