Package: pyhisto
Python Histogram moduleThis librabry provides histogram classes to perform data analysis.Contrary to some data analysis library such asPandaswhich generate histogram on demand from the whoel set of data, this libraryjust storesthe histogram in bins.The histograms are exported as ascii files (and can be reloaded from these files).Getting StartedThe following instructions will get you a copy of the project up and running on your local machine.InstallingThere are several ways to install the module::thumbsup: (recommended): usepip. The pyhisto is uploaded to the PyPi repository, so just runningpip install pyhistoshould install the library on your local environnement.Download thepyhist.tar.gzfile, unzip and run thesetupscript withing the directory:$  python3 setup.py installGet a local copy of the git directory (not recommenced)Dependenciespyhistois build with no dependencies for the use of histograms. For more advanced features in thepyhist.toolssubmodule, you will neednumpyandmatplotlibinstalled. If they are not, the features using them won't work, but the rest of the library will still load and be useable.UsageThepyhistomodule can be tested live (in cunjunction with another library) on Binder:BinThe basic for 1D histograms is aBinobject. That is an object that keep record of the number of counts between to values (edges).Main properties are:Bin.countBin.lowedgeBin.upedgeMain methods are:Bin.width()Bin.center()The bin can be typed into astrorfloat. UsingBin(fromstring=z), the Bin is instanciated using thezstring, as formated bystr(Bin).Binobjects can be added together, or mutliplied and divied by floats. Comparison operators (<,>, ...) on aBinare comparingBin.count.HistogramThe basis class isHistogramwhich isBincontainer with added function for management.Histogramis instantiated several ways:Histogram(nbins: int, xmin: float = -0.5, xmax: Optional): wherenbinsis the number of bins,xminthe low edge of the first bin, andxmaxthe up edge of the last bin. Ifxminis not given, it is set at-0.5(so that it's centered on 0). Ifxmaxis not given it is taken asxmin + nbins.Histogram(fromstring: str)where the argument is a string, formatted asstr(Histogram)return.Histogram(fromfile: :str)where the argument is a file path where to read a string (just likefromstring).Histogram(frombins: list)with a list ofBinobject.When used as a container/list (i.e.Histogram[i],for inloops, ...)Histogrambehaves like a list of the bins.+,-,*,\operators either operates between one histogram and a scalar, or between two histograms of the same number of bins (no checking of bins limits is done).-emptyindex, find, fastindex, slice
fill, fast fill-copye, empty copyxyautocrop, evalLazy histogramsLazyhistograms are simpler interfaces to the histograms, their are designed to be litgher in memory and faster in usage, but with limited capabilities. They are recommended when filling the histograms from a data sources when speed is an imporant factor.Ghost histogramsGhosthistograms have the same interface as lazy histograms, but do nothing. They are intended as a way to avoid time-expensiveifchecks when filling several histograms by filling the non interesting data into aghosthistogramdirectly.Output filesDevelopment statusAnalyticsAll badgesCaveatsSome part of the code have anon-pythonictaste for several reasons:Adaptation of non python code from other physics data analysis toolsCompatibility with early version of the codePracticality beats purityThe goal is to develop the module under the hood and improve it's performance, portabilty, simplicity.Any comments and suggestions are helpful.AuthorsGreg Henning- ghenning​.at.​iphc․cnrs․frLicenseThis project is licensed under the CeCILL FREE SOFTWARE LICENSE AGREEMENT.SeeLICENSEfor more.