跳转到主要内容

FastJet和NumPy之间的接口

项目描述

  • pyjet 在过去几年中一直保持简约风格。在此期间,Scikit-HEP生态系统启动了一个新项目,以提供一个现代化的Pythonic喷注查找包。

  • fastjet 提供了官方FastJet绑定到Python和Awkward Array。 有关详细信息,请参阅GitHub存储库。

pyjet:FastJet和NumPy之间的接口

PyPI version Zenodo link Test status Wheel builds Binder

pyjet 允许您在 FastJet 上使用 NumPy 数组进行喷注聚类。默认情况下,pyjet 仅依赖于 NumPy,并在内部使用 FastJet 的独立 fjcore 版本。接口代码使用 Cython 编写,然后编译为 C++,因此速度快。请注意,如果您使用 pyjet,则表示您正在使用 FastJet,并且应该引用此处列出的论文 [此处]

严格依赖

入门

pyjet 提供了 cluster() 函数,该函数接受一个 NumPy 数组作为输入,并返回一个 ClusterSequence,您可以从其中访问喷注

from pyjet import cluster
from pyjet.testdata import get_event

vectors = get_event()
sequence = cluster(vectors, R=1.0, p=-1)
jets = sequence.inclusive_jets()  # list of PseudoJets
exclusivejets = sequence.exclusive_jets(3)  # Find the cluster history when there are 3 jets

输入以 numpy 的结构数组形式给出。输入数组 vectors 的前四个字段必须是以下之一

np.dtype([('pT', 'f8'), ('eta', 'f8'), ('phi', 'f8'), ('mass', 'f8')])

或者如果 cluster(..., ep=True)

np.dtype([('E', 'f8'), ('px', 'f8'), ('py', 'f8'), ('pz', 'f8')])

请注意,输入数组的字段名称不需要与“pT”,“eta”,“phi”,“mass”等匹配。pyjet 仅假设前四个字段是这些量。此数组还可以有其他类型的任何附加字段。附加字段将成为 PseudoJet 对象的属性。

查看 示例 以开始使用

https://github.com/scikit-hep/pyjet/raw/master/examples/jet_areas.png

独立安装

要简单使用内置的 FastJet 源,从您的虚拟环境运行

python -m pip install pyjet

然后就可以使用了!如果您有旧版本的 pip (<10),则需要已安装 Cython 和 Numpy 才能从源代码构建 - 但是在大多数系统上,您应该得到一个二进制轮。

获取 example.py 并运行它

    curl -O https://raw.githubusercontent.com/scikit-hep/pyjet/master/examples/example.py
    python example.py
    jet#          pT        eta        phi       mass  #constit.
    1        983.280     -0.868      2.905     36.457         34
    2        901.745      0.221     -0.252     51.850         34
    3         67.994     -1.194     -0.200     11.984         32
    4         12.465      0.433      0.673      5.461         13
    5          6.568     -2.629      1.133      2.099          9
    6          6.498     -1.828     -2.248      3.309          6

    The 6th jet has the following constituents:
    PseudoJet(pt=0.096, eta=-2.166, phi=-2.271, mass=0.000)
    PseudoJet(pt=2.200, eta=-1.747, phi=-1.972, mass=0.140)
    PseudoJet(pt=1.713, eta=-2.037, phi=-2.469, mass=0.940)
    PseudoJet(pt=0.263, eta=-1.682, phi=-2.564, mass=0.140)
    PseudoJet(pt=1.478, eta=-1.738, phi=-2.343, mass=0.940)
    PseudoJet(pt=0.894, eta=-1.527, phi=-2.250, mass=0.140)

    Get the constituents as an array (pT, eta, phi, mass):
    [( 0.09551261, -2.16560157, -2.27109083,   4.89091390e-06)
     ( 2.19975694, -1.74672746, -1.97178728,   1.39570000e-01)
     ( 1.71301882, -2.03656511, -2.46861524,   9.39570000e-01)
     ( 0.26339374, -1.68243005, -2.56397904,   1.39570000e-01)
     ( 1.47781519, -1.7378898 , -2.34304346,   9.39570000e-01)
     ( 0.89353864, -1.52729244, -2.24973202,   1.39570000e-01)]

    or (E, px, py, pz):
    [( 0.42190436, -0.06155242, -0.07303395, -0.41095089)
     ( 6.50193926, -0.85863306, -2.02526044, -6.11692764)
     ( 6.74203628, -1.33952806, -1.06775374, -6.45273802)
     ( 0.74600384, -0.22066287, -0.1438199 , -0.68386087)
     ( 4.43164941, -1.0311407 , -1.05862485, -4.07096881)
     ( 2.15920027, -0.56111108, -0.69538886, -1.96067711)]

Reclustering the constituents of the hardest jet with the kt algorithm
[PseudoJet(pt=983.280, eta=-0.868, phi=2.905, mass=36.457)]

Go back in the clustering sequence to when there were two jets
PseudoJet(pt=946.493, eta=-0.870, phi=2.908, mass=20.117)
PseudoJet(pt=36.921, eta=-0.800, phi=2.821, mass=4.119)

Ask how many jets there are with a given dcut
There are 9 jets with a dcut of 0.5

Get the jets with the given dcut
1 PseudoJet(pt=308.478, eta=-0.865, phi=2.908, mass=2.119)
2 PseudoJet(pt=256.731, eta=-0.868, phi=2.906, mass=0.140)
3 PseudoJet(pt=142.326, eta=-0.886, phi=2.912, mass=0.829)
4 PseudoJet(pt=135.971, eta=-0.870, phi=2.910, mass=0.140)
5 PseudoJet(pt=91.084, eta=-0.864, phi=2.899, mass=1.530)
6 PseudoJet(pt=30.970, eta=-0.831, phi=2.822, mass=2.124)
7 PseudoJet(pt=7.123, eta=-0.954, phi=2.939, mass=1.017)
8 PseudoJet(pt=5.951, eta=-0.626, phi=2.818, mass=0.748)
9 PseudoJet(pt=4.829, eta=-0.812, phi=3.037, mass=0.384)

使用外部 FastJet 安装

要利用完整的 FastJet 库,包括喷注面积计算和优化的 O(NlnN) kt 和 anti-kt 算法,您首先需要构建和安装 FastJet,然后使用 --external-fastjet 标志安装 pyjet。在构建 FastJet 之前,您需要安装 CGALGMP

基于 Debian 的系统(Ubuntu)

sudo apt-get install libcgal-dev libcgal11v5 libgmp-dev libgmp10

基于 RPM 的系统(Fedora)

sudo dnf install gmp.x86_64 gmp-devel.x86_64 CGAL.x86_64 CGAL-devel.x86_64

在 Mac OS 上

brew install cgal gmp wget

然后运行 pyjet 的 install-fastjet.sh 脚本

curl -O https://raw.githubusercontent.com/scikit-hep/pyjet/master/install-fastjet.sh
chmod +x install-fastjet.sh
sudo ./install-fastjet.sh

现在像这样安装 pyjet

python -m pip install numpy Cython
python setup.py install --external-fastjet

pyjet 现在将使用系统上的外部 FastJet 安装。

关于单位

该包对特定单位不敏感,这些单位仅仅是“传播”通过代码。我们建议使用 HEP 单位,如 hepunits 包units 模块中定义的。

值得注意的是,方位角 phi 以弧度表示,从 pi 变化到 pi。

开发

如果您想为开发设置

python3 -m venv .env
source .env/bin/activate
pip install -e .[dev]
pytest

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源分布

pyjet-1.9.0.tar.gz (100.5 kB 查看散列)

上传于 源码

构建的版本

pyjet-1.9.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (406.5 kB 查看哈希)

上传于 PyPy manylinux: glibc 2.17+ x86-64

pyjet-1.9.0-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (414.0 kB 查看哈希)

上传于 PyPy manylinux: glibc 2.17+ i686

pyjet-1.9.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (406.3 kB 查看哈希)

上传于 PyPy manylinux: glibc 2.17+ x86-64

pyjet-1.9.0-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (413.8 kB 查看哈希)

上传于 PyPy manylinux: glibc 2.17+ i686

pyjet-1.9.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (323.8 kB 查看哈希)

上传于 PyPy manylinux: glibc 2.17+ x86-64

pyjet-1.9.0-pp37-pypy37_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (333.0 kB 查看哈希)

上传于 PyPy manylinux: glibc 2.17+ i686

pyjet-1.9.0-cp310-cp310-win_amd64.whl (303.2 kB 查看哈希)

上传于 CPython 3.10 Windows x86-64

pyjet-1.9.0-cp310-cp310-win32.whl (287.8 kB 查看哈希)

上传于 CPython 3.10 Windows x86

pyjet-1.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB 查看哈希)

上传于 CPython 3.10 manylinux: glibc 2.17+ x86-64

pyjet-1.9.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (1.8 MB 查看哈希)

上传于 CPython 3.10 manylinux: glibc 2.17+ i686

pyjet-1.9.0-cp310-cp310-macosx_10_9_x86_64.whl (412.8 kB 查看哈希值)

上传时间 CPython 3.10 macOS 10.9+ x86-64

pyjet-1.9.0-cp39-cp39-win_amd64.whl (303.9 kB 查看哈希值)

上传时间 CPython 3.9 Windows x86-64

pyjet-1.9.0-cp39-cp39-win32.whl (288.5 kB 查看哈希值)

上传时间 CPython 3.9 Windows x86

pyjet-1.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB 查看哈希值)

上传时间 CPython 3.9 manylinux: glibc 2.17+ x86-64

pyjet-1.9.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (1.8 MB 查看哈希值)

上传时间 CPython 3.9 manylinux: glibc 2.17+ i686

pyjet-1.9.0-cp39-cp39-macosx_10_9_x86_64.whl (413.4 kB 查看哈希值)

上传时间 CPython 3.9 macOS 10.9+ x86-64

pyjet-1.9.0-cp38-cp38-win_amd64.whl (304.1 kB 查看哈希值)

上传时间 CPython 3.8 Windows x86-64

pyjet-1.9.0-cp38-cp38-win32.whl (288.7 kB 查看哈希值)

上传时间 CPython 3.8 Windows x86

pyjet-1.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB 查看哈希值)

上传时间 CPython 3.8 manylinux: glibc 2.17+ x86-64

pyjet-1.9.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (1.8 MB 查看哈希值)

上传时间 CPython 3.8 manylinux: glibc 2.17+ i686

pyjet-1.9.0-cp38-cp38-macosx_10_9_x86_64.whl (412.8 kB 查看散列值)

上传于 CPython 3.8 macOS 10.9+ x86-64

pyjet-1.9.0-cp37-cp37m-win_amd64.whl (303.4 kB 查看散列值)

上传于 CPython 3.7m Windows x86-64

pyjet-1.9.0-cp37-cp37m-win32.whl (195.8 kB 查看散列值)

上传于 CPython 3.7m Windows x86

pyjet-1.9.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB 查看散列值)

上传于 CPython 3.7m manylinux: glibc 2.17+ x86-64

pyjet-1.9.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl (1.7 MB 查看散列值)

上传于 CPython 3.7m manylinux: glibc 2.17+ i686

pyjet-1.9.0-cp37-cp37m-macosx_10_9_x86_64.whl (320.3 kB 查看散列值)

上传于 CPython 3.7m macOS 10.9+ x86-64

支持者