Skip to main content

PDF interpolation with Tensorflow

Project description

DOI arxiv

Documentation Status pytest AUR

PDFFlow

PDFFlow is parton distribution function interpolation library written in Python and based on the TensorFlow framework. It is developed with a focus on speed and efficiency, enabling researchers to perform very expensive calculation as quick and easy as possible.

The key features of PDFFlow is the possibility to query PDF sets on GPU accelerators.

Documentation

The documentation for PDFFlow can be consulted in the readthedocs page: pdfflow.readthedocs.io.

Installation

The package can be installed with pip:

python3 -m pip install pdfflow

If you prefer a manual installation just use:

python setup.py install

or if you are planning to extend or develop code just use:

python setup.py develop

⚠ Note: Use the latest version of TensorFlow!

TensorFlow is updated frequently and a later version of TensorFlow will often offer better performance in both GPUs and CPUs. Although it can be made to work with earlier versions, PDFFlow is only supported for TensorFlow>2.1.

Minimal Working Example

Below a minimalistic example where PDFFlow is used to generate a 10 values of the PDF for 2 members for three different flavours.

from pdfflow import mkPDFs
import tensorflow as tf

pdf = mkPDFs("NNPDF31_nnlo_as_0118", [0,2])
x = tf.random.uniform([10], dtype=tf.float64)
q2 = tf.random.uniform([10], dtype=tf.float64)*20 + 10
pid = tf.cast([-1,21,1], dtype=tf.int32)

result = pdf.xfxQ2(pid, x, q2)

Note the usage of the dtype keyword inm the TensorFlow calls. This is used to ensure that float64 is being used all across the program. For convenience, we ship two functions, int_me and float_me which are simply wrappers to tf.cast with the right types.

These wrappers can be used over TensorFlow types but also numpy values:

from pdfflow import mkPDFs, int_me, float_me
import tensorflow as tf
import numpy as np

pdf = mkPDFs("NNPDF31_nnlo_as_0118", [0,2])
x = float_me(np.random.rand(10))
q2 = float_me(tf.random.uniform([10])*20 + 10)
pid = int_me([-1,21,1])

result = pdf.xfxQ2(pid, x, q2)

Citation policy

If you use the package pelase cite the following paper and zenodo references:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdfflow-1.2.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

pdfflow-1.2-py3-none-any.whl (39.4 kB view details)

Uploaded Python 3

File details

Details for the file pdfflow-1.2.tar.gz.

File metadata

  • Download URL: pdfflow-1.2.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for pdfflow-1.2.tar.gz
Algorithm Hash digest
SHA256 06e198b84a0369e6f0eb3d48e4bafbd77a33ac73a1f6761a67baf9ce86dbac68
MD5 f7ef3c1c607eae5c13b2060514323de4
BLAKE2b-256 f4aac3d623f4896526d2897efb082cc0c1ee242918efaf58af46175daa24643d

See more details on using hashes here.

File details

Details for the file pdfflow-1.2-py3-none-any.whl.

File metadata

  • Download URL: pdfflow-1.2-py3-none-any.whl
  • Upload date:
  • Size: 39.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for pdfflow-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 13fdbaf115cd136cfd51dc604aa057668c0892a40e5ec74c07a904ae9be7d41b
MD5 2dbb85ea50a2cea016eccc2b46afba20
BLAKE2b-256 1487ec56a8c02f5dff984f24ca76f2a04af525a9a2b5f39b38ffc2ea65766c22

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page