Name | numpythia JSON |
Version |
1.3.1
JSON |
| download |
home_page | http://github.com/scikit-hep/numpythia |
Summary | The interface between PYTHIA and NumPy |
upload_time | 2023-01-06 19:22:20 |
maintainer | the Scikit-HEP admins |
docs_url | None |
author | |
requires_python | >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.* |
license | GPLv3 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
.. -*- mode: rst -*-
***************************************************************
:warning:numpythia is deprecated and unmaintained:warning:
***************************************************************
``numpythia`` has not been actively maintained for a couple of years. This is mostly due to the emergence of new alternatives which are both faster and more flexible.
For example:
* The `official Pythia 8 (SWIG) bindings available from Conda. <https://anaconda.org/conda-forge/pythia8>`_
* The `impy <https://github.com/impy-project/impy>`_ project implementing a generic user interface to popular event generators
used in cosmic ray and high-energy particle physics.
numpythia: The interface between PYTHIA and NumPy
=================================================
.. image:: https://img.shields.io/pypi/v/numpythia.svg
:target: https://pypi.python.org/pypi/numpythia
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1471492.svg
:target: https://doi.org/10.5281/zenodo.1471492
.. image:: https://github.com/scikit-hep/numpythia/workflows/Main/badge.svg?branch=master
:target: https://github.com/scikit-hep/numpythia/actions
:alt: Test status
numpythia provides an interface between `PYTHIA
<http://home.thep.lu.se/Pythia/>`_ and `NumPy
<http://www.numpy.org/>`_ allowing you to generate events as NumPy arrays of
particle four-momenta. By default numpythia only depends on NumPy and builds
internal copies of the PYTHIA and `HepMC <http://hepmc.web.cern.ch/hepmc/>`_
source code.
Standalone Installation
-----------------------
To simply use the built-in PYTHIA and HepMC::
pip install -v numpythia
And you're good to go!
Support for building against an external PYTHIA is on the wishlist.
Note that if you are using a Mac OSX system, then installation may require setting an
environment variable as `explained here <https://github.com/pytorch/pytorch/issues/1434>`_.
Strict dependencies
-------------------
- `Python <http://docs.python-guide.org/en/latest/starting/installation/>`__ (2.7+, 3.7+)
- `Numpy <https://scipy.org/install.html>`__
- `six <https://six.readthedocs.io/>`__
- Source builds: `Cython <https://cython.org/>`__ and a compiler.
Getting started
---------------
.. code-block:: python
>>> from numpythia import Pythia, hepmc_write, hepmc_read
>>> from numpythia import STATUS, HAS_END_VERTEX, ABS_PDG_ID
>>> from numpythia.testcmnd import get_cmnd
>>> from numpy.testing import assert_array_equal
>>> pythia = Pythia(get_cmnd('w'), random_state=1)
>>> selection = ((STATUS == 1) & ~HAS_END_VERTEX &
(ABS_PDG_ID != 12) & (ABS_PDG_ID != 14) & (ABS_PDG_ID != 16))
>>> # generate events while writing to ascii hepmc
>>> for event in hepmc_write('events.hepmc', pythia(events=1)):
>>> array1 = event.all(selection)
>>> # read the same event back from ascii hepmc
>>> for event in hepmc_read('events.hepmc'):
>>> array2 = event.all(selection)
>>> assert_array_equal(array1, array2)
True
The dtype of any array of particle information is:
.. code-block:: python
np.dtype([('E', 'f8'), ('px', 'f8'), ('py', 'f8'), ('pz', 'f8'), ('pt', 'f8'),
('mass', 'f8'), ('rap', 'f8'), ('eta', 'f8'), ('theta', 'f8'),
('phi', 'f8'), ('prodx', 'f8'), ('prody', 'f8'), ('prodz', 'f8'),
('prodt', 'f8'), ('pdgid', 'i4'), ('status', 'i4')])
Also see `pyjet <https://github.com/scikit-hep/pyjet>`_ for jet clustering.
Tutorial
--------
Setting PYTHIA
~~~~~~~~~~~~~~
PYTHIA settings can be passed in one of three ways: through the `**kwargs` arguments of the constructor `Pythia(..., **kwargs)`:
.. code-block:: python
>>> pythia = Pythia(..., Beams_eCM=13000.)
Or as a dictionary:
.. code-block:: python
>>> pythia = Pythia(..., params={'Beams:eCM': 13000.})
Or via a Python command file:
.. code-block:: python
>>> pythia = Pythia(config='path/to/config.cmd')
The full list of settings can be found on the `PYTHIA homepage <http://home.thep.lu.se/Pythia/>`_.
Note that the ":" in settings names is replaced by a "_" if using `kwargs`.
`kwargs` take precedence over `params` and they both take precedence over `config`.
Example config files can be found under the `numpythia.testcmnd` directory.
Generate events
~~~~~~~~~~~~~~~
To generate events do
.. code-block:: python
>>> events = pythia(events=100)
>>> events
<generator at 0x10cf06f78>
where **events** is a generator of ``GenEvent`` containing all the generated particles.
Generated particles can be accessed through the ``all``, ``first`` and ``last``
methods which have two optional arguments ``selection`` and ``return_hepmc``.
Selection is a filter or a combination of filters with bitwise operations (as
shown in the *getting started* example) applied on the particles in the event.
The available filters are
.. code-block:: python
STATUS, PDG_ID, ABS_PDG_ID, HAS_END_VERTEX, HAS_PRODUCTION_VERTEX,
HAS_SAME_PDG_ID_DAUGHTER, IS_STABLE, IS_BEAM
``return_hepmc`` is by default set to ``False`` when using ``all``:
.. code-block:: python
>>> for e in events:
>>> array = e.all(selection)
returns an array of particles, with the dtype described above. ``return_hepmc`` is
by default set to ``True`` for ``first`` and ``last``:
.. code-block:: python
>>> for e in events:
>>> gen_part_f = e.first(selection)
>>> gen_part_l = e.last(selection)
returns a ``GenParticle``.
Generated particle
~~~~~~~~~~~~~~~~~~
``GenParticle`` is the numpythia interface of
`HepMC::GenParticle <http://lcgapp.cern.ch/project/simu/HepMC/205/html/classHepMC_1_1GenParticle.html>`_,
and has the following attributes
.. code-block:: python
pid, status, e, px, py, pz, pt, eta, phi, mass, theta, rap
``GenParticle`` also has the following methods ``parents``, ``children``, ``ancestors``,
``descendants`` and ``siblings`` both with the two optional arguments ``selection``
and ``return_hepmc`` described before. For instance:
.. code-block:: python
>>> for e in events:
>>> w = e.last((ABS_PDG_ID == 24) & HAS_END_VERTEX))
>>> w.children()
array([(240.60708981, 115.76101664, 126.16766767, -169.03439984, 171.22760682, 0.5, -0.87228439, -0.87228739, 2.34974894, 0.82838703, 0., 0., 0., 0., 3, 23),
( 52.59241372, 9.21296404, 50.77873929, -10.01763001, 51.60774235, 1.5, -0.19283178, -0.19291222, 1.76252302, 1.39131523, 0., 0., 0., 0., -4, 23)],
dtype=[('E', '<f8'), ('px', '<f8'), ('py', '<f8'), ('pz', '<f8'), ('pT', '<f8'), ('mass', '<f8'), ('rap', '<f8'), ('eta', '<f8'), ('theta', '<f8'), ('phi', '<f8'), ('prodx', '<f8'), ('prody', '<f8'), ('prodz', '<f8'), ('prodt', '<f8'), ('pdgid', '<i4'), ('status', '<i4')])
Raw data
{
"_id": null,
"home_page": "http://github.com/scikit-hep/numpythia",
"name": "numpythia",
"maintainer": "the Scikit-HEP admins",
"docs_url": null,
"requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*",
"maintainer_email": "scikit-hep-admins@googlegroups.com",
"keywords": "",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/10/76/4d3f8ed235a9e5d316b1b64882ecc1d9b9773e41ee97aea9b3456d4ff6d1/numpythia-1.3.1.tar.gz",
"platform": null,
"description": ".. -*- mode: rst -*-\r\n\r\n***************************************************************\r\n:warning:numpythia is deprecated and unmaintained:warning:\r\n***************************************************************\r\n\r\n``numpythia`` has not been actively maintained for a couple of years. This is mostly due to the emergence of new alternatives which are both faster and more flexible.\r\nFor example:\r\n\r\n* The `official Pythia 8 (SWIG) bindings available from Conda. <https://anaconda.org/conda-forge/pythia8>`_\r\n* The `impy <https://github.com/impy-project/impy>`_ project implementing a generic user interface to popular event generators\r\n used in cosmic ray and high-energy particle physics.\r\n\r\nnumpythia: The interface between PYTHIA and NumPy\r\n=================================================\r\n\r\n.. image:: https://img.shields.io/pypi/v/numpythia.svg\r\n :target: https://pypi.python.org/pypi/numpythia\r\n\r\n.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1471492.svg\r\n :target: https://doi.org/10.5281/zenodo.1471492\r\n\r\n.. image:: https://github.com/scikit-hep/numpythia/workflows/Main/badge.svg?branch=master\r\n :target: https://github.com/scikit-hep/numpythia/actions\r\n :alt: Test status\r\n\r\nnumpythia provides an interface between `PYTHIA\r\n<http://home.thep.lu.se/Pythia/>`_ and `NumPy\r\n<http://www.numpy.org/>`_ allowing you to generate events as NumPy arrays of\r\nparticle four-momenta. By default numpythia only depends on NumPy and builds\r\ninternal copies of the PYTHIA and `HepMC <http://hepmc.web.cern.ch/hepmc/>`_\r\nsource code.\r\n\r\nStandalone Installation\r\n-----------------------\r\n\r\nTo simply use the built-in PYTHIA and HepMC::\r\n\r\n pip install -v numpythia\r\n\r\nAnd you're good to go!\r\n\r\nSupport for building against an external PYTHIA is on the wishlist.\r\n\r\nNote that if you are using a Mac OSX system, then installation may require setting an\r\nenvironment variable as `explained here <https://github.com/pytorch/pytorch/issues/1434>`_.\r\n\r\nStrict dependencies\r\n-------------------\r\n\r\n- `Python <http://docs.python-guide.org/en/latest/starting/installation/>`__ (2.7+, 3.7+)\r\n- `Numpy <https://scipy.org/install.html>`__\r\n- `six <https://six.readthedocs.io/>`__\r\n- Source builds: `Cython <https://cython.org/>`__ and a compiler.\r\n\r\nGetting started\r\n---------------\r\n\r\n.. code-block:: python\r\n\r\n >>> from numpythia import Pythia, hepmc_write, hepmc_read\r\n >>> from numpythia import STATUS, HAS_END_VERTEX, ABS_PDG_ID\r\n >>> from numpythia.testcmnd import get_cmnd\r\n >>> from numpy.testing import assert_array_equal\r\n\r\n >>> pythia = Pythia(get_cmnd('w'), random_state=1)\r\n\r\n >>> selection = ((STATUS == 1) & ~HAS_END_VERTEX &\r\n (ABS_PDG_ID != 12) & (ABS_PDG_ID != 14) & (ABS_PDG_ID != 16))\r\n\r\n >>> # generate events while writing to ascii hepmc\r\n >>> for event in hepmc_write('events.hepmc', pythia(events=1)):\r\n >>> array1 = event.all(selection)\r\n\r\n >>> # read the same event back from ascii hepmc\r\n >>> for event in hepmc_read('events.hepmc'):\r\n >>> array2 = event.all(selection)\r\n\r\n >>> assert_array_equal(array1, array2)\r\n True\r\n\r\nThe dtype of any array of particle information is:\r\n\r\n.. code-block:: python\r\n\r\n np.dtype([('E', 'f8'), ('px', 'f8'), ('py', 'f8'), ('pz', 'f8'), ('pt', 'f8'),\r\n ('mass', 'f8'), ('rap', 'f8'), ('eta', 'f8'), ('theta', 'f8'),\r\n ('phi', 'f8'), ('prodx', 'f8'), ('prody', 'f8'), ('prodz', 'f8'),\r\n ('prodt', 'f8'), ('pdgid', 'i4'), ('status', 'i4')])\r\n\r\nAlso see `pyjet <https://github.com/scikit-hep/pyjet>`_ for jet clustering.\r\n\r\nTutorial\r\n--------\r\n\r\nSetting PYTHIA\r\n~~~~~~~~~~~~~~\r\n\r\nPYTHIA settings can be passed in one of three ways: through the `**kwargs` arguments of the constructor `Pythia(..., **kwargs)`:\r\n\r\n.. code-block:: python\r\n\r\n >>> pythia = Pythia(..., Beams_eCM=13000.)\r\n\r\nOr as a dictionary:\r\n\r\n.. code-block:: python\r\n\r\n >>> pythia = Pythia(..., params={'Beams:eCM': 13000.})\r\n\r\nOr via a Python command file:\r\n\r\n.. code-block:: python\r\n\r\n >>> pythia = Pythia(config='path/to/config.cmd')\r\n\r\nThe full list of settings can be found on the `PYTHIA homepage <http://home.thep.lu.se/Pythia/>`_.\r\n\r\nNote that the \":\" in settings names is replaced by a \"_\" if using `kwargs`.\r\n`kwargs` take precedence over `params` and they both take precedence over `config`.\r\nExample config files can be found under the `numpythia.testcmnd` directory.\r\n\r\nGenerate events\r\n~~~~~~~~~~~~~~~\r\n\r\nTo generate events do\r\n\r\n.. code-block:: python\r\n\r\n >>> events = pythia(events=100)\r\n >>> events\r\n <generator at 0x10cf06f78>\r\n\r\nwhere **events** is a generator of ``GenEvent`` containing all the generated particles.\r\n\r\nGenerated particles can be accessed through the ``all``, ``first`` and ``last``\r\nmethods which have two optional arguments ``selection`` and ``return_hepmc``.\r\nSelection is a filter or a combination of filters with bitwise operations (as\r\nshown in the *getting started* example) applied on the particles in the event.\r\nThe available filters are\r\n\r\n.. code-block:: python\r\n\r\n STATUS, PDG_ID, ABS_PDG_ID, HAS_END_VERTEX, HAS_PRODUCTION_VERTEX,\r\n HAS_SAME_PDG_ID_DAUGHTER, IS_STABLE, IS_BEAM\r\n\r\n``return_hepmc`` is by default set to ``False`` when using ``all``:\r\n\r\n.. code-block:: python\r\n\r\n >>> for e in events:\r\n >>> array = e.all(selection)\r\n\r\nreturns an array of particles, with the dtype described above. ``return_hepmc`` is\r\nby default set to ``True`` for ``first`` and ``last``:\r\n\r\n.. code-block:: python\r\n\r\n >>> for e in events:\r\n >>> gen_part_f = e.first(selection)\r\n >>> gen_part_l = e.last(selection)\r\n\r\nreturns a ``GenParticle``.\r\n\r\nGenerated particle\r\n~~~~~~~~~~~~~~~~~~\r\n\r\n``GenParticle`` is the numpythia interface of\r\n`HepMC::GenParticle <http://lcgapp.cern.ch/project/simu/HepMC/205/html/classHepMC_1_1GenParticle.html>`_,\r\nand has the following attributes\r\n\r\n.. code-block:: python\r\n\r\n pid, status, e, px, py, pz, pt, eta, phi, mass, theta, rap\r\n\r\n``GenParticle`` also has the following methods ``parents``, ``children``, ``ancestors``,\r\n``descendants`` and ``siblings`` both with the two optional arguments ``selection``\r\nand ``return_hepmc`` described before. For instance:\r\n\r\n.. code-block:: python\r\n\r\n >>> for e in events:\r\n >>> w = e.last((ABS_PDG_ID == 24) & HAS_END_VERTEX))\r\n >>> w.children()\r\n array([(240.60708981, 115.76101664, 126.16766767, -169.03439984, 171.22760682, 0.5, -0.87228439, -0.87228739, 2.34974894, 0.82838703, 0., 0., 0., 0., 3, 23),\r\n ( 52.59241372, 9.21296404, 50.77873929, -10.01763001, 51.60774235, 1.5, -0.19283178, -0.19291222, 1.76252302, 1.39131523, 0., 0., 0., 0., -4, 23)],\r\n dtype=[('E', '<f8'), ('px', '<f8'), ('py', '<f8'), ('pz', '<f8'), ('pT', '<f8'), ('mass', '<f8'), ('rap', '<f8'), ('eta', '<f8'), ('theta', '<f8'), ('phi', '<f8'), ('prodx', '<f8'), ('prody', '<f8'), ('prodz', '<f8'), ('prodt', '<f8'), ('pdgid', '<i4'), ('status', '<i4')])\r\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "The interface between PYTHIA and NumPy",
"version": "1.3.1",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "10764d3f8ed235a9e5d316b1b64882ecc1d9b9773e41ee97aea9b3456d4ff6d1",
"md5": "8f1da01575c4760b71fde8f33e90bcca",
"sha256": "e18bf8996098a7fe1fd3141d04d7b3e8c667b051982d25b26898456bc8d5c2d3"
},
"downloads": -1,
"filename": "numpythia-1.3.1.tar.gz",
"has_sig": false,
"md5_digest": "8f1da01575c4760b71fde8f33e90bcca",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*",
"size": 11092603,
"upload_time": "2023-01-06T19:22:20",
"upload_time_iso_8601": "2023-01-06T19:22:20.192101Z",
"url": "https://files.pythonhosted.org/packages/10/76/4d3f8ed235a9e5d316b1b64882ecc1d9b9773e41ee97aea9b3456d4ff6d1/numpythia-1.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-06 19:22:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "scikit-hep",
"github_project": "numpythia",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "numpythia"
}