Package: kafe
Aboutkafeis a data fitting framework designed for use in undergraduate
physics lab courses. It is open-source software licensed under the GNU
Public License.It provides a basic Python toolkit for fitting models to data as well as
for visualizing the fit result. It relies on Python packages such asNumPyandmatplotlib, and uses the Python interface to the minimizerMINUITcontained in CERN’s data analysis framework ROOT or toiminuit, which is
available as a separate Python package.The software originated as part of a bachelor’s thesis in physicsInstitut
für Experimentelle Kernphysik(IEKP) at theKarlsruhe Insitute of Technology(KIT). Development is currently slow, but ongoing.Contributors:Günter Quast <guenter (dot) quast (at) online (dot) de>Daniel Savoiu <daniel (dot) savoiu (at) cern (dot) ch>For more information, please consult the HTML documentation indoc/html/index.htmlor onReadTheDocs.Requirementskaferuns under both Python 2 (>=2.7.9) and Python 3 (tested with3.5.2).Some additional Python packages are required. The recommended versions of these are
as follows. Please note that more recent versions of these packages should work
as well:SciPy>= 0.17.0NumPy>= 1.11.2matplotlib>= 1.5.0Additionally, a function minimizer is needed.kafeimplements interfaces to two
function minimizers and requires at least one of them to be installed:MINUIT, which is included inCERN’s data analysis packageROOT(>= 5.34), oriminuit(>= 1.2, < 2.0), which is independent of ROOTFinally,kaferequires a number of external programs:ALaTeXdistribution (tested withTeX Live), sinceLaTeXis
used by matplotlib for typesetting labels and mathematical expressions.dvipngfor converting DVI files to PNG graphicsInstallation notes (Linux)Most of the above packages and programs can be installed through the package manager on most Linux
distributions.kafewas developed for use on Linux desktop systems. Please note that all
commands below should be run as root.InstallNumPy,SciPyandmatplotlibThese packages should be available in the package manager.In Ubuntu/Mint/Debian:apt-getinstallpython-numpypython-scipypython-matplotlibIn Fedora/RHEL/CentOS:yuminstallnumpyscipypython-matplotlibInstallROOTNote: This section is written with ROOT version 5.34 in mind.
When using this version, take care that the Python bindings (PyROOT)
are compiled for the version of Python you intend to use (either 2.x or 3.x),
as it is not possible to use both. For newer versions of ROOT (i.e. 6 and
above), this should no longer be an issue.ROOT and its Python bindings can be obtained via the package manager in
Ubuntu/Mint/Debian:apt-getinstallroot-systemlibroot-bindings-python5.34libroot-bindings-python-devOr, in Fedora/RHEL/CentOS:yuminstallrootroot-pythonThis setup is usually sufficient. However, you may decide to build ROOT yourself. In this case,
be sure to compile withPyROOTsupport. Additionally, for Python to see thePyROOTbindings,
the following environment variables have to be set correctly:exportROOTSYS=<directorywhereROOTisinstalled>exportLD_LIBRARY_PATH=$ROOTSYS/lib:$PYTHONDIR/lib:$LD_LIBRARY_PATHexportPYTHONPATH=$ROOTSYS/lib:$PYTHONPATHFor more info, refer tohttp://root.cern.ch/drupal/content/pyroot.Installiminuitiminuitis a Python wrapper for the Minuit minimizer which is
independent of ROOT. If compiling/installing ROOT is not possible,
this minimizer can be used instead.To install theiminuitpackage for Python, thePip installeris recommended:pipinstalliminuitIf you don’t havePipinstalled, get it from the package manager.In Ubuntu/Mint/Debian, do:apt-getinstallpython-pipIn Fedora/RHEL/CentOS, do:yuminstallpython-pipor useeasy_install(included withsetuptools):easy_installpipYou might also need to install the Python headers foriminuitto
compile properly.In Ubuntu/Mint/Debian, do:apt-getinstalllibpython2.7-devIn Fedora/RHEL/CentOS, do:yuminstallpython-develRead the README file for more information on other dependencies
(there should be adequate packages for your Linux distribution
to satisfy these).InstallkafeTo installkafeusingPip, simply run the helper script as root:./install.shTo remove kafe usingPip, just run the helper script:./uninstall.shAlternatively, installing using Python’ssetuptoolsalso works, but may not
provide a clean uninstall. Use this method if installing withPipis not possible:pythonsetup.pyinstallInstallation notes (Windows)kafecan be installed under Windows, but requires some additional configuration.The recommended Python distribution for working withkafeunder Windows isWinPython, which has the advantage that it is
portable and comes with a number of useful pre-installed packages. Particularly,NumPy,SciPyandmatplotlibare all pre-installed inWinPython.InstalliminuitAfter installingWinPython, start ‘WinPython Command Prompt.exe’ in theWinPythoninstallation directory and runpipinstalliminuitInstallkafeNowkafecan be installed from PyPI by running:pipinstallkafeAlternatively, it may be installed directly usingsetuptools. Just run
the following in ‘WinPython Command Prompt.exe’ after switching to the
directory into which you have downloadedkafe:pythonsetup.pyinstallUsingkafewith ROOT under WindowsIf you wantkafeto work with ROOT’sTMinuitinstead of usingiminuit, then ROOT has to be installed. Please note that ROOT releases
for Windows are 32-bit and using the PyROOT bindings on a 64-bitWinPythondistribution will not work.A pre-built verson of ROOT for Windows is available on the ROOT homepage as a Windows
Installer package. The recommended version isROOT 5.34.
During the installation process, select “Add ROOT to the system PATH for all users”
when prompted. This will set thePATHenvironment variable to include
the relevant ROOT directories. The installer also sets theROOTSYSenvironment
variable, which points to the directory where ROOT in installed. By default,
this isC:\root_v5.34.34.Additionally, for Python to find thePyROOTbindings, thePYTHONPATHenvironment variable must be modified to include thebinsubdirectory
of path where ROOT is installed. On Windows 10, assuming ROOT has been installed
in the default directory (C:\root_v5.34.34), this is achieved as follows:open the Start Menu and start typing “environment variables”select “Edit the system environment variables”click the “Environment Variables…” buttonin the lower part, under “System variables”, look for the “PYTHONPATH” entrymodify/add the “PYTHONPATH” entry:if it doesn’t exist, create it by choosing “New…”,
enter PYTHONPATH as the variable name
andC:\root_v5.34.34\binas the variable valueif it already exists and contains only one path, edit it via “Edit…” and
insertC:\root_v5.34.34\bin;at the beginning of the variable value.
(Note the semicolon!)if the variable already contains several paths, choosing “Edit…” will
show a dialog box to manage them. Choose “New” and writeC:\root_v5.34.34\binclose all opened dialogs with “OK”Now you may try toimport ROOTin theWinPythoninterpreter to check
if everything has been set up correctly.For more information please refer to ROOT’s officialPyROOT Guide.