You can install Vector with pip and conda.
pip install vector
Vector is a Python library for 2D and 3D spatial vectors, as well as 4D space-time vectors. It is especially intended for performing geometric calculations on arrays of vectors, rather than one vector at a time in a Python for loop.
Vector is part of the Scikit-HEP project, High Energy Physics (HEP) tools in Python.
Vectors may be expressed in any of these coordinate systems:
- the azimuthal plane may be Cartesian
x
y
or polarrho
($\rho$ )phi
($\phi$ ) - the longitudinal axis may be Cartesian
z
, polartheta
($\theta$ ), or pseudorapidityeta
($\eta$ ) - the temporal component for space-time vectors may be Cartesian
t
or proper timetau
($\tau$ )
in any combination. (That is, 4D vectors have 2Γ3Γ2 = 12 distinct coordinate systems.)
Vectors may be included in any of these data types:
- vector.obj objects (pure Python)
- NumPy structured arrays of vectors
- Awkward Arrays of vectors (possibly within variable-length lists or nested record structures)
- SymPy expressions for symbolic (non-numeric) manipulations
- In Numba-compiled functions, with vector.obj objects or Awkward Arrays
Each of these "backends" provides the same suite of properties and methods, through a common "compute" library.
Finally, vectors come in two flavors:
- geometric: only one name for each property or method
- momentum: same property or method can be accessed with several synonyms, such as
pt
($p_T$ , transverse momentum) for the azimuthal magnituderho
($\rho$ ) andenergy
andmass
for the Cartesian timet
and proper timetau
($\tau$ ).
Names and coordinate conventions were chosen to align with ROOT's TLorentzVector and Math::LorentzVector, as well as scikit-hep/math, uproot-methods TLorentzVector, henryiii/hepvector, and coffea.nanoevents.methods.vector.
- Source code on GitHub: scikit-hep/vector
- Report bugs and request features on the GitHub Issues page
- Ask questions on the GitHub Discussions page
- Real-time chat on Gitter: Scikit-HEP/Vector
If you want to contribute to Vector, pull requests are welcome!
Please install the latest version of the main
branch from source or a fork:
git clone https://github.com/scikit-hep/vector.git
cd vector
pip install -e .
Refer to CONTRIBUTING.md for more.
- Vector objects
- NumPy arrays of vectors
- Awkward Arrays of vectors
- Compiling functions on vectors with Numba
- Vector expressions with SymPy
- Making vector objects
- Making NumPy arrays of vectors
- Making Awkward Arrays of vectors
- Making SymPy vector expressions
- Interface for all vectors
- Interface for 2D vectors
- Interface for 3D vectors
- Interface for 4D vectors
- Interface for 2D momentum
- Interface for 3D momentum
- Interface for 4D momentum
Thanks goes to these wonderful people (emoji key):
Jim Pivarski π§ π» π |
Henry Schreiner π§ π» π |
Eduardo Rodrigues π§ π» π |
N!no π |
Peter Fackeldey π |
Luke Kreczko π» |
Nicholas Smith π€ |
Jonas Eschle π€ |
This project follows the all-contributors specification. Contributions of any kind welcome! See CONTRIBUTING.md for information on setting up a development environment.
This library was primarily developed by Saransh Chopra, Henry Schreiner, Jim Pivarski, Eduardo Rodrigues, and Jonas Eschle.
Support for this work was provided by the National Science Foundation cooperative agreement OAC-1836650 and PHY-2323298 (IRIS-HEP) and OAC-1450377 (DIANA/HEP). Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation.