Beispiel #1
0
nt = NTuple()
nt.setLabels(['x'])

xmin = 1.
xmax = 100.
gamma = 2.1
xpmax = math.pow(xmax, 1. - gamma)
xpmin = math.pow(xmin, 1. - gamma)

nsamp = 10000
for i in range(nsamp):
    x = shoot(0, 1)
    xx = math.pow(x * (xpmax - xpmin) + xpmin, 1. / (1. - gamma))
    nt.addRow((xx, ))

from hippo import Display

hist = Display('Histogram', nt, ('x', ))
canvas.addDisplay(hist)

# Set the x and y axis on log scale
hist.setLog('x', True)
hist.setLog('y', True)

# fit to power law function
from hippo import Function
datarep = hist.getDataRep()
powerlaw = Function("PowerLaw", datarep)
powerlaw.addTo(hist)
powerlaw.fit()
Beispiel #2
0
import hippo
app = hippo.HDApp()
canvas = app.canvas()

plot = Display("Color Plot", darray, ('GLON', 'GLAT', 'nil', 'nil'))
canvas.addDisplay(plot)

#
# Calculate Log(energy) and add it as new column
#
import numarray
darray['LogE'] = numarray.log(darray['energy'])

lplot = Display('Histogram', darray, ('LogE', ))
lplot.setLog('y', True)
canvas.addDisplay(lplot)

#
# Compare it with logrithmic binning
#
clplot = Display('Histogram', darray, ('energy', ))
canvas.addDisplay(clplot)
clplot.setLog('x', True)
clplot.setLog('y', True)

#
# Apply a cut to the displays
#
cut = hippo.Cut(darray, ('time', ))
canvas.addDisplay(cut)
Beispiel #3
0
print hdus

events = ntc.createNTuple(full_path, hdus[1])

print "Names of the columns"
labels = events.getLabels()
print labels

from hippo import Display

#
# Create the  displays.
#

hist = Display("Histogram", events, ("energy",))
hist.setLog("x", True)
hist.setLog("y", True)
canvas.addDisplay(hist)

color = Display("Color Plot", events, ("GLON", "GLAT"))
color.setRange("z", 0.5, 150.0)
color.setLog("z", True)
canvas.addDisplay(color)

contour = Display("Contour Plot", events, ("time", "GLON"))
canvas.addDisplay(contour)

profile = Display("Profile", events, ("time", "energy"))
canvas.addDisplay(profile)

print "Created the plots shown on the HippoDraw main page."
Beispiel #4
0
nt = NTuple ()
nt.setLabels ( [ 'x' ] )

xmin = 1.
xmax = 100.
gamma = 2.1
xpmax = math.pow ( xmax, 1. - gamma )
xpmin = math.pow ( xmin, 1. - gamma )

nsamp = 10000
for i in range(nsamp):
    x = shoot(0, 1)
    xx = math.pow ( x*( xpmax - xpmin ) + xpmin, 1./ (1. - gamma) )
    nt.addRow ( (xx, ) )

from hippo import Display

hist = Display ( 'Histogram', nt, ( 'x', ) )
canvas.addDisplay ( hist )

# Set the x and y axis on log scale
hist.setLog ( 'x', True )
hist.setLog ( 'y', True )

# fit to power law function
from hippo import Function
datarep = hist.getDataRep ()
powerlaw = Function ( "PowerLaw", datarep )
powerlaw.addTo( hist )
powerlaw.fit()
Beispiel #5
0
#
# If GemConditionsWord == 7., then fill element with `nbrTkrTriggered',
# otherwise with -1
#
daSvac [ label_TowerTkrTrigGemCond ] = \
       numarray.choose ( t, ( nbrTkrTriggered, -1 ) )
daSvac [ label_TowerCalLeTrigGemCond ] = \
       numarray.choose ( t, ( nbrCalLeTriggered, -1 ) )
tend = time.time()
print "Took %f seconds create the 4 new columns with 500,000 rows each" % \
      (tend -tstart)
        
#
# The rest is standard procedure
#
tkrtrighist = Display ("Histogram", daSvac, (label_TkrTriggered,) )
canvas.addDisplay ( tkrtrighist )
tkrtrighist.setLog ( 'y', True)

calletrighist = Display ("Histogram", daSvac, (label_CalLeTriggered, ) )
canvas.addDisplay ( calletrighist )
calletrighist.setLog ( 'y', True)

tkrtrighist_gemcond = Display ( "Histogram", daSvac,
                                (label_TowerTkrTrigGemCond, ) )
canvas.addDisplay ( tkrtrighist_gemcond )
tkrtrighist_gemcond.setRange ( 'x', 0, 16)
tkrtrighist_gemcond.setLog ( 'y', True)
print tkrtrighist_gemcond.numberOfEntries()

Beispiel #6
0
print hdus

events = ntc.createNTuple(full_path, hdus[1])

print "Names of the columns"
labels = events.getLabels()
print labels

from hippo import Display

#
# Create the  displays.
#

hist = Display("Histogram", events, ('energy', ))
hist.setLog('x', True)
hist.setLog('y', True)
canvas.addDisplay(hist)

color = Display("Color Plot", events, ('GLON', 'GLAT'))
color.setRange('z', 0.5, 150.)
color.setLog('z', True)
canvas.addDisplay(color)

contour = Display("Contour Plot", events, ('time', 'GLON'))
canvas.addDisplay(contour)

profile = Display("Profile", events, ('time', 'energy'))
canvas.addDisplay(profile)

print "Created the plots shown on the HippoDraw main page."
Beispiel #7
0
app = hippo.HDApp()
canvas = app.canvas()

plot = Display("Color Plot", darray, ("GLON", "GLAT", "nil", "nil"))
canvas.addDisplay(plot)


#
# Calculate Log(energy) and add it as new column
#
import numarray

darray["LogE"] = numarray.log(darray["energy"])

lplot = Display("Histogram", darray, ("LogE",))
lplot.setLog("y", True)
canvas.addDisplay(lplot)

#
# Compare it with logrithmic binning
#
clplot = Display("Histogram", darray, ("energy",))
canvas.addDisplay(clplot)
clplot.setLog("x", True)
clplot.setLog("y", True)

#
# Apply a cut to the displays
#
cut = hippo.Cut(darray, ("time",))
canvas.addDisplay(cut)
Beispiel #8
0
print "Number of columns = ", ntuple.columns
labels = ntuple.getLabels()
print "First ten column labels are ... ", labels[:10]
print "Number of rows = ", ntuple.rows

# Create a histogram for one of the columns and add it to the canvas
hist = Display ( "Histogram", ntuple, ('TkrEnergy', ) )

# Up to now, we didn't need the HippoDraw application running.
# Now we do in order to view the data.
app = HDApp()
canvas = app.canvas()
canvas.addDisplay ( hist )

# Set the Y axis on log scale of better viewing
hist.setLog ( 'y', True )

# Add a cut from data in another column
from hippo import Cut
hits_cut = Cut ( ntuple, ('TkrTotalHits',) )
canvas.addDisplay ( hits_cut )
hits_cut.setLog ( 'y', True )

hits_cut.addTarget ( hist )
hits_cut.setCutRange ( 4, 110, 'x' )

# Change the range of the displayed data
hist.setRange ( 'x', 40, 700 )

# fit a function to the histogram
from hippo import Function