Python Histogram Library
Project description
Python Histogram module
This librabry provides histogram classes to perform data analysis.
Contrary to some data analysis library such as Pandas
which generate histogram on demand from the whoel set of data, this library just stores the histogram in bins.
The histograms are exported as ascii files (and can be reloaded from these files).
Getting Started
The following instructions will get you a copy of the project up and running on your local machine.
Installing
There are several ways to install the module:
- :thumbsup: (recommended): use
pip
. The pyhisto is uploaded to the PyPi repository, so just runningpip install pyhisto
should install the library on your local environnement. - Download the
pyhist.tar.gz
file, unzip and run thesetup
script withing the directory:$ python3 setup.py install
- Get a local copy of the git directory (not recommenced)
Dependencies
pyhisto
is build with no dependencies for the use of histograms. For more advanced features in the pyhist.tools
submodule, you will need numpy
and matplotlib
installed. If they are not, the features using them won't work, but the rest of the library will still load and be useable.
Usage
The pyhisto
module can be tested live (in cunjunction with another library) on Binder:
Bin
The basic for 1D histograms is a Bin
object. That is an object that keep record of the number of counts between to values (edges).
Main properties are:
Bin.count
Bin.lowedge
Bin.upedge
Main methods are:
Bin.width()
Bin.center()
The bin can be typed into a str
or float
. Using Bin(fromstring=z)
, the Bin is instanciated using the z
string, as formated by str(Bin)
.
Bin
objects can be added together, or mutliplied and divied by floats. Comparison operators (<
, >
, ...) on a Bin
are comparing Bin.count
.
Histogram
The basis class is Histogram
which is Bin
container with added function for management.
Histogram
is instantiated several ways:
Histogram(nbins: int, xmin: float = -0.5, xmax: Optional)
: wherenbins
is the number of bins,xmin
the low edge of the first bin, andxmax
the up edge of the last bin. Ifxmin
is not given, it is set at-0.5
(so that it's centered on 0). Ifxmax
is 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 ofBin
object.
When used as a container/list (i.e. Histogram[i]
, for in
loops, ...) Histogram
behaves 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).
-empty
index, find, fastindex, slice fill, fast fill
-copye, empty copy
xy
autocrop, eval
Lazy histograms
Lazy histograms 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 histograms
Ghost histograms have the same interface as lazy histograms, but do nothing. They are intended as a way to avoid time-expensive if
checks when filling several histograms by filling the non interesting data into a ghosthistogram
directly.
Output files
Development status
Analytics
-
All badges
Caveats
Some part of the code have a non-pythonic taste for several reasons:
- Adaptation of non python code from other physics data analysis tools
- Compatibility with early version of the code
- Practicality beats purity
The goal is to develop the module under the hood and improve it's performance, portabilty, simplicity.
Any comments and suggestions are helpful.
Authors
- Greg Henning - ghenning.at.iphc․cnrs․fr
License
This project is licensed under the CeCILL FREE SOFTWARE LICENSE AGREEMENT.
See LICENSE for more.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyhisto-0.1.2.tar.gz
.
File metadata
- Download URL: pyhisto-0.1.2.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 239507f9dea83d2819259dc89361e077540abe6a0e308c68d20c4c07fe3d9837 |
|
MD5 | ad6ce01c0d67ad5efbff5e6bb00f4ba6 |
|
BLAKE2b-256 | 7d72cb4517bd94f38f6e985225f0ea3268f76e289985300c4c2b8f7b5b5f7b93 |
File details
Details for the file pyhisto-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: pyhisto-0.1.2-py3-none-any.whl
- Upload date:
- Size: 30.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9d707dce529bba730cb936d73a540fc8bc1f18dafb7357e8b78aa3eaef35bec |
|
MD5 | b5986bbd5ca2661c40a3afc495545ee5 |
|
BLAKE2b-256 | 94469ff34a1267d4abd474cf8f7d7b27b6bc6760b66d343882d4da339c6c4c1c |