def test_histo_plot():
    h_pt = ntuple_column_histo(nt, 'pt')
    histo_plot(h_pt, color='blue', show=False)
import math
from random import gauss
from pyhistuples.pyntuple.ntuple import NTuple
from matplotlib import pyplot
from pyhistuples.pyhistoplots import ntuple_plot, histo_plot, ntuple_column_histo
from pyhistuples.pyhistogram.histogram import Histogram, Axis

mu_p = 15.
mu_pt = 5.
sigma_p = 10.
sigma_pt = 5.

nt = NTuple('x', 'p', 'pt')

h_pt = Histogram(axis=Axis(100, -50, 50, label='pt'))

for x in xrange(10000) :
    val = gauss(mu_pt, sigma_pt)
    h_pt.fill(val)

# greem plot without errors
plot_pt = histo_plot(h_pt, color='green', errorfunction=None)

# blue plot with default errors (poissonSigma)
plot_pt_errors = histo_plot(h_pt, color='blue')

print 'plot_pt range', plot_pt.axes[0].xaxis.get_view_interval()

print 'plot_pt_errors range', plot_pt_errors.axes[0].xaxis.get_view_interval()
Beispiel #3
0
import math
from random import gauss
from pyhistuples.pyntuple.ntuple import NTuple
from matplotlib import pyplot
from pyhistuples.pyhistoplots import ntuple_plot, histo_plot, ntuple_column_histo
from pyhistuples.pyhistogram.histogram import Histogram, Axis

mu_p = 15.
mu_pt = 5.
sigma_p = 10.
sigma_pt = 5.

nt = NTuple('x', 'p', 'pt')

h_pt = Histogram(axis=Axis(100, -50, 50, label='pt'))

for x in xrange(10000):
    val = gauss(mu_pt, sigma_pt)
    h_pt.fill(val)

# greem plot without errors
plot_pt = histo_plot(h_pt, color='green', errorfunction=None)

# blue plot with default errors (poissonSigma)
plot_pt_errors = histo_plot(h_pt, color='blue')

print 'plot_pt range', plot_pt.axes[0].xaxis.get_view_interval()

print 'plot_pt_errors range', plot_pt_errors.axes[0].xaxis.get_view_interval()
Beispiel #4
0
import math
from random import gauss
from pyhistuples.pyntuple.ntuple import NTuple
from matplotlib import pyplot
from pyhistuples.pyhistoplots import ntuple_plot, histo_plot, ntuple_column_histo

mu_p = 15.
mu_pt = 5.
sigma_p = 10.
sigma_pt = 5.

nt = NTuple('x', 'p', 'pt')

for x in xrange(10000) :
    nt.fill('x',x)
    nt.fill('p', gauss(mu_p, sigma_p))
    nt.fill('pt', gauss(mu_pt, sigma_pt))
    nt.write()


pt_plot = ntuple_plot(nt, 'pt')
h_pt = ntuple_column_histo(nt, 'pt')
histo_plot(h_pt, color='blue')
Beispiel #5
0
    def __call__(self, params) :
        return  map(lambda g, e : g-e, fitfunc(params, self.x), self.y)

mu_pt = 5.
sigma_pt = 15.
sigma2_pt=pow(sigma_pt,2)

h_pt = Histogram(axis=Axis(100, -50, 50, label='pt'))

for i in xrange(10000) :
    h_pt.fill(gauss(mu_pt, sigma_pt))

p0 = [15., 10, 1000.] # mu, sigma, integral.

errfunc = ErrFunc(h_pt, fitfunc)

p0, success = optimize.leastsq(errfunc,
                               p0[:])

print 'Success:', success, 'p[0] =', p0[0], ' p[1] =', p0[1], ' p0[2] =', p0[2]

plot_pt = histo_plot(h_pt, color='green')

# plot the fit results on top.
fit=plot_pt.add_subplot(1,1,1)
pt = [bin.centre for bin in h_pt.filledBins()]
fitval = fitfunc(p0,pt)
fit.plot(pt, fitval, 'r')

plot_pt.show()
def test_histo_plot() :
    h_pt = ntuple_column_histo(nt, 'pt')
    histo_plot(h_pt, color='blue', show = False)