def convolve_one(pdf, observable, logger=None): import applwrap from smpdflib.core import PDF, APPLGridObservable #analysis:ignore res = {} import os logging.debug("Convolving in PID: %d" % os.getpid()) logging.info("Convolving %s with %s" % (observable, pdf)) with pdf, observable: for rep in pdf.reps: applwrap.pdfreplica(rep) res[rep] = np.array(applwrap.convolute(observable.order)) return res
def make_convolution(pdf, observables): datas = defaultdict(lambda:OrderedDict()) if not observables: return {} with(pdf): for obs in observables: with obs: for rep in pdf.reps: sys.stdout.write('\r-> Computing replica %d of %s' % (rep, pdf)) sys.stdout.flush() applwrap.pdfreplica(rep) res = applwrap.convolute(obs.order) datas[obs][rep] = np.array(res) sys.stdout.write('\n') return datas