You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+37-23
Original file line number
Diff line number
Diff line change
@@ -3,17 +3,19 @@
3
3
[](https://gitter.im/HSF/PyHEP?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Python libraries of interest to particle physicists. This is meant to be a living document. Therefore, if you have suggestions, click the edit button then make a pull request with your proposed change.
6
+
Python libraries of interest to particle physicists. This is meant to be a living document. Therefore, if you have suggestions, click the edit button then make a pull request with your proposed change(s).
7
+
8
+
You are more than welcome to join the [HSF/PyHEP Gitter channel](https://gitter.im/HSF/PyHEP) and contribute to the informal discussions there.
7
9
8
10
## New to Python
9
11
10
12
If you are new to Python, the following contains general information on using Python in Science.
11
13
12
-
| Name | Use |
14
+
| Name | Use |
13
15
| ------------ | --------------- |
14
16
|[Software Carpentry Python Lesson ](http://swcarpentry.github.io/python-novice-inflammation/)| Lesson aimed at people who have never used Python before. |
15
17
|[Scipy tutorials](https://scipy2017.scipy.org/ehome/220975/493423/)| You'll want the beginner courses, the intermediate/advanced courses are actually quite advanced. Setup instructions are linked on the page, videos are [here](https://www.youtube.com/playlist?list=PLYx7XA2nY5GfdAFycPLBdUDOUtdQIVoMf)|
16
-
|[Dive into Python 3](http://www.diveintopython3.net/index.html)| Very useful for learning python, though it's a bit old and doesn't cover any of the scientific python stuff you really need. |
18
+
|[Dive into Python 3](http://www.diveintopython3.net/index.html)| Very useful for learning python, though it's a bit old and doesn't cover any of the scientific python stuff you really need. |
| Many EdX and Coursera courses | Often introductory CS courses which can teach other useful skills (algorithms and datastructures) |
19
21
|[The python docs](https://docs.python.org/3/)||
@@ -35,43 +37,56 @@ Some more advanced talks of interested:
35
37
36
38
## Getting Python
37
39
38
-
| Name | Use |
40
+
| Name | Use |
39
41
| ------------ | --------------- |
40
42
|[Anaconda Package Manager](https://conda.io/docs/user-guide/getting-started.html)| Anaconda packages most scientific Python libraries while also living purely in user space. Therefore, you don't need special permissions to setup. |
41
-
|[pipenv](https://pipenv.readthedocs.io/en/latest/)| Official Python way |
43
+
|[pipenv](https://pipenv.readthedocs.io/en/latest/)| Official Python way.|
42
44
|[ripa](https://github.com/tunnell/ripa)| ripa solves the packaging issue by letting you install packages (or requirements.txt) where priority given to conda channels, otherwise fetches from PyPI. (Works but rough) |
43
45
44
46
45
47
## Scientific Python Stack
46
48
47
49
The packages that are used in Physics and/or data science within Python grew somewhat organically before forming the current ecosystem. Detailed information on what exists can be found [here](https://scipy.org/about.html), but we will summarize here.
48
50
49
-
| Name | Use |
51
+
| Name | Use |
50
52
| ------------ | --------------- |
51
53
|[jupyter notebook](https://jupyter.org)| Main one way of doing interactive and/or exploratory analysis. |
52
-
|[numpy](http://www.numpy.org)| Array and matrix operations (including math operations) at C speeds. |
54
+
|[numpy](http://www.numpy.org)| Array and matrix operations (including math operations) at C speeds. |
53
55
|[pandas](https://pandas.pydata.org)| A very elegant way to work with tabular data (i.e. ntuples) with in memory calculations. Especially good at time series. |
54
-
[xarray](http://xarray.pydata.org/en/stable/why-xarray.html#core-data-structures) | Extension of pandas to N-Dim structures |
55
-
|[h5py](http://www.h5py.org/)| Simple numpy to HDF5 bindings (backend for Keras saved models) |
56
+
[xarray](http://xarray.pydata.org/en/stable/why-xarray.html#core-data-structures) | Extension of pandas to N-Dim structures. |
57
+
|[h5py](http://www.h5py.org/)| Simple numpy to HDF5 bindings (backend for Keras saved models).|
56
58
|[scipy](https://www.scipy.org)| Various scientific routines like minimization. |
57
59
|[matplotlib](https://matplotlib.org)| Main Python plotting library. Start from [matplotlib gallery](https://matplotlib.org/gallery.html) then adapt to your application. |
58
60
|[scikit-learn](http://scikit-learn.org/stable/index.html)| Very easy to use machine learning routines with great examples. |
59
61
62
+
Visualisation:
63
+
64
+
| Name | Use |
65
+
| ------------ | --------------- |
66
+
|[matplotlib](https://matplotlib.org)| Main Python plotting library. Start from [matplotlib gallery](https://matplotlib.org/gallery.html) then adapt to your application. |
67
+
|[seaborn](https://seaborn.pydata.org)| Easier to use plotting library with some statistical routines. Builds on matplotlib, but annoying to customize. |
68
+
|[vegascope](https://github.com/scikit-hep/vegascope)| View Vega/Vega-Lite plots in your web browser from local or remote Python processes. |
69
+
60
70
Notable mentions:
61
71
62
-
| Name | Use |
72
+
| Name | Use |
63
73
| ------------ | --------------- |
64
-
|[seaborn](https://seaborn.pydata.org)| Easier to use plotting library with some statistical routines, builds on matplotlib, but annoying to customize. |
65
74
|[tensorflow](http://scikit-learn.org/stable/index.html)| For deep neural networks. |
66
-
|[pytorch](https://pytorch.org)| deep learning framework for fast, flexible experimentation with dynamic computational graphs |
|[numpythia](https://github.com/scikit-hep/numpythia)| Interface between FastJet and NumPy. |
88
+
|[pyjet](https://github.com/scikit-hep/pyjet)| Interface between PYTHIA and NumPy. |
89
+
75
90
## Jupyter extensions
76
91
77
92
Jupyter has a wide ecosystem of extensions that can be used to extend the functionality. Some useful extensions for HEP data analysis are summarised here.
@@ -85,31 +100,31 @@ Jupyter has a wide ecosystem of extensions that can be used to extend the functi
85
100
86
101
See tutorials here and other resources collected by [IML HEP-ML Resources](https://github.com/iml-wg/HEP-ML-Resources#tutorials)
87
102
88
-
## ROOT
103
+
## ROOT and interoperability with ROOT
89
104
90
105
For many particle physics experiments, a lot of data is stored within ROOT files. This means at very least one must have the ability to read ROOT files. ROOT also serves as a tool suite designed to solve many computational problems encountered in HEP, which means that one may want to access some of this tool suite. The following packages below are worth knowing for these situations:
91
106
92
107
| Package name | Use | Pro | Con | Further information |
|[uproot](https://github.com/scikit-hep/uproot)| Native Python ROOT I/O | Easy to install, fast, no dependence on C++ ROOT | Although can read all ROOT files, can only write ROOT files with specific objects ||
109
+
|[uproot](https://github.com/scikit-hep/uproot)| Native Python ROOT I/O | Easy to install, fast, no dependence on C++ ROOT | Although can read all ROOT files, can only write ROOT files with specific objects.||
95
110
| root_numpy, root_pandas | ROOT to/from Numpy and Pandas, like uproot | full ROOT functionality, like TFormula | slower than uproot, binary incompatibilities with different versions of ROOT ||
96
-
|[ROOT conda](https://nlesc.gitbooks.io/cern-root-conda-recipes/content/installing_root_via_anaconda.html)| Using ROOT within Anaconda | Easy to get ROOT installed with PyROOT support | Not all features of ROOT and getting dated (6.04 Py2.7/3.4 since XENON1T uses that) |[Recipes](https://github.com/NLeSC/root-conda-recipes)|
97
-
|[PyROOT](https://root.cern.ch/pyroot)| Official ROOT Python bindings | Good support and many examples | Raw C++ wrapping results in weird Python code ||
98
-
|[rootpy](http://www.rootpy.org)| Pythonic ROOT access | More logical for people who know Python | Smaller user base than PyROOT, abandoned? |[Repository](https://github.com/rootpy/rootpy/)|
99
-
|[alphatwirl](https://github.com/alphatwirl/alphatwirl)| Summerizing ROOT data into categorical data as Pandas' data frames | Small output size. Easy one-function interface with [qtwirl](https://github.com/alphatwirl/qtwirl)| Not for data type conversion |[Repository](https://github.com/alphatwirl/alphatwirl)|
111
+
|[ROOT conda](https://nlesc.gitbooks.io/cern-root-conda-recipes/content/installing_root_via_anaconda.html)| Using ROOT within Anaconda | Easy to get ROOT installed with PyROOT support | Not all features of ROOT and getting dated (6.04 Py2.7/3.4 since XENON1T uses that) |[Recipes](https://github.com/NLeSC/root-conda-recipes)|
112
+
|[PyROOT](https://root.cern.ch/pyroot)| Official ROOT Python bindings | Good support and many examples | Raw C++ wrapping results in weird Python code ||
113
+
|[rootpy](http://www.rootpy.org)| Pythonic ROOT access | More logical for people who know Python | Smaller user base than PyROOT, abandoned? |[Repository](https://github.com/rootpy/rootpy/)|
114
+
|[alphatwirl](https://github.com/alphatwirl/alphatwirl)| Summerizing ROOT data into categorical data as Pandas' data frames | Small output size. Easy one-function interface with [qtwirl](https://github.com/alphatwirl/qtwirl)| Not for data type conversion |[Repository](https://github.com/alphatwirl/alphatwirl)|
100
115
|[pyhf](https://github.com/diana-hep/pyhf)| statistical analysis / fitting | pure python implementation of HistFactory specification with auto-diff enabled backends in tensorflow, pytorch, and MXNet | not yet interoperable with ROOT-based RooFit models |[pyhf](https://github.com/diana-hep/pyhf)|
101
116
102
117
103
118
## Speeding up code
104
119
105
120
Often, it is not needed anymore to write C++/C routines that get wrapped since there are other ways to speed up your Python code. Namely:
106
121
107
-
| Name | Use |
122
+
| Name | Use |
108
123
| ------------ | --------------- |
109
124
|[numba](https://numba.pydata.org)| Tight loops are often the slow part of Python code, where this compiles them! |
110
125
| Pythran | whole scripts |
111
-
|[numpy](http://www.numpy.org)| Expressing your code as array options means you get native-C speeds. |
112
-
| NumExpr | single pass "mapper" operations (one input → one output |
126
+
|[numpy](http://www.numpy.org)| Expressing your code as array options means you get native-C speeds. |
127
+
| NumExpr | single pass "mapper" operations (one input → one output).|
113
128
114
129
## Binding C/C++ to Python
115
130
@@ -136,4 +151,3 @@ Stealing code from other physicists is its own sign of flattery. Codes that are
136
151
137
152
| Name | Collaboration | Use | Further information | Date added to list |
0 commit comments