Esempio n. 1
0
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."
Esempio n. 2
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()
Esempio n. 3
0
from hippo import DataArray
da = DataArray ( 'NTuple' ) # use NTuple to store data
da.register ( 'randomized line' ) # name the data source

# Fill the contents by adding named columns in the order expected by
# the fitter (more later)

da['x'] =  x
da['y'] =  y
da['xerr'] = xerr
da['yerr'] = yerr

# Create an XY plot, ignoring xerr, and add it to the canvas.
from hippo import Display
disp = Display ('XY Plot', da, ('x', 'y', 'nil', 'yerr' ) )
canvas.addDisplay ( disp )

# Get the name of the available fitters from the factory
from hippo import FitterFactory
factory = FitterFactory.instance()
fitters = factory.names()
print fitters

# Create a fitter, in this case Minuit Migrad algorithm with Chi Sq
migrad = factory.create ( fitters[1] )
print migrad.name()


# create a function
f = Linear ()
print f.name()
Esempio n. 4
0
da = DataArray('NTuple')  # use NTuple to store data
da.register('randomized line')  # name the data source

# Fill the contents by adding named columns in the order expected by
# the fitter (more later)

da['x'] = x
da['y'] = y
da['xerr'] = xerr
da['yerr'] = yerr

# Create an XY plot, ignoring xerr, and add it to the canvas.
from hippo import Display

disp = Display('XY Plot', da, ('x', 'y', 'nil', 'yerr'))
canvas.addDisplay(disp)

# Get the name of the available fitters from the factory
from hippo import FitterFactory

factory = FitterFactory.instance()
fitters = factory.names()
print fitters

# Create a fitter, in this case Minuit Migrad algorithm with Chi Sq
migrad = factory.create(fitters[1])
print migrad.name()

# create a function
f = Linear()
print f.name()
Esempio n. 5
0
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."
Esempio n. 6
0
# Create NTuple with its's controller.
ntc = NTupleController.instance()

#
# create full path to the file in case this script is not run from this
# directory
#
import sys
full_path = sys.path[0] + '/' + 'aptuple.tnt'
nt = ntc.createNTuple ( full_path )

from hippo import Display

# Create a histogram
hist = Display ("Histogram", nt, ('Age', ) )
canvas.addDisplay( hist )

# Overlay another histogram.
hist.addDataRep ( 'Histogram', nt, ['Service'] )

#
# Set the line style and color
#
reps = hist.getDataReps ()
from hippo import Line
print "The available line styles are ..."
print Line.values
print ""
try :
    reps[1].set ( Line.dash )
except RuntimeError, detail :
Esempio n. 7
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()
Esempio n. 8
0
"""
   Demonstrates making simple XY plot.  

   author Paul F. Kunz <*****@*****.**>
"""
#
# load the HippoDraw module
#
from load_hippo import app, canvas

from hippo import Display

# Create list of data
energy = [90.74, 91.06, 91.43, 91.50, 92.16, 92.22, 92.96, 89.24, 89.98, 90.35]
sigma = [29.0, 30.0, 28.40, 28.80, 21.95, 22.90, 13.50, 4.50, 10.80, 24.20]
errors = [5.9, 3.15, 3.0, 5.8, 7.9, 3.1, 4.6, 3.5, 4.6, 3.6]

# make a plot to test it.
xy = Display("XY Plot", [energy, sigma, errors],
             ['Energy', 'Sigma', 'nil', 'error'])

canvas.addDisplay(xy)

xy.setTitle('Mark II Z0 scan')

print "An XY plot is now displayed.   You can use the Inspector dialog"
print "to modify the appearance or fit a function to it."
Esempio n. 9
0
#
# generate a random ordered sequence
#
npts = 400000
times = num.sort ( ra.uniform ( 1e9, 1e10, (npts, ) ) )

ds = hippo.NumArrayTuple ()
ds.addColumn ( 'times', times )

#
# Use the hippo FFT utility to get binned light curve display the
# normalized contents of the bins
#
lightcurve, bintimes = hippofft.simpleLightCurve( ds,'times', numberbins=4096 )
canvas.addDisplay ( lightcurve )

#
# Calculate the power spectrum by giving hippo the range and unit of
# time
#
range = lightcurve.getRange ( 'x' )
onetick = 1. / 20.0e6
spectrum = hippofft.powerSpectrum ( bintimes, range, onetick )

#
# The spectrum return is ntuple of two columns which can be used
# directly to plot it as an XY plot
#
labels = spectrum.getLabels()
xyplot = hippo.Display ( 'XY Plot', spectrum, labels )
Esempio n. 10
0
#
from hippo import NTupleController
ntc = NTupleController.instance()
#
# Create full path to example file in case this script is not run from
# this directory.
#
full_path = sys.path[0] + '/' + 'aptuple.tnt'

nt1 = ntc.createNTuple ( full_path )

canvas.setPlotMatrix ( 2, 3 )
from hippo import Display

hist = Display ( "Histogram", nt1, ("Cost", ) )
canvas.addDisplay( hist )

# Get the data representation so we can add function to it.
datarep1 = hist.getDataRep()
from hippo import Function
gauss = Function ( "Gaussian", datarep1 )
gauss.addTo ( hist )

# Get the function parameters and display them.
print "Before fitting"
parmnames = gauss.parmNames ( )
print parmnames

parms = gauss.parameters ( )
print parms
Esempio n. 11
0
print "Names of the Header/Data Units are..."
print hdus

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

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

from hippo import Display

#
# Create a 1D histograms
#
hist1 = Display ( "Histogram", events, ('GLON', ) )
canvas.addDisplay ( hist1 )

hist2 = Display ( "Histogram", events, ('GLAT', ) )
canvas.addDisplay ( hist2 )

#
# Create a cut
#
cut = hippo.Cut ( events, ( 'zenith_angle', ) )
canvas.addDisplay ( cut )
cut.setCutRange ( 80., 90., 'x' )
#
# Add this cut to multiple displays ( a Python tuple of displays ).
#
cut.addTargets ( ( hist1, hist2 ) )
Esempio n. 12
0
#
# labels of columns that will be used often
#
data = 'data'
sqdata = 'sqrt(data)'

#
# Create and fill two columns
#
da1[data] = num.array(range(10), d_type)
da1[sqdata] = num.sqrt(da1[data])

#
# Plot them
#
xyplot = Display('XY Plot', da1, (data, sqdata, 'nil', 'nil'))
canvas.addDisplay(xyplot)

#
# Create a similar array
#
da2[data] = num.array(range(10, 20, 1), d_type)
da2[sqdata] = num.sqrt(da2[data])

#
# Append second to first
#
da1.append(da2)

print "Should see 20 data points, the result of appending two DataArrays"
Esempio n. 13
0
# labels of columns that will be used often
#
data = 'data'
sqdata = 'sqrt(data)'

#
# Create and fill two columns
#
da1 [ data ] = num.array ( range ( 10),  d_type )
da1 [ sqdata ] = num.sqrt ( da1 [ data ] )

#
# Plot them
#
xyplot = Display ( 'XY Plot', da1, ( data, sqdata, 'nil', 'nil' ) )
canvas.addDisplay ( xyplot )

#
# Create a similar array
#
da2 [ data ] = num.array ( range ( 10, 20, 1 ), d_type)
da2 [ sqdata ] = num.sqrt ( da2 [ data ] )

#
# Append second to first
#
da1.append ( da2 )


print "Should see 20 data points, the result of appending two DataArrays"
Esempio n. 14
0
print "Names of the Header/Data Units are..."
print hdus

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


# Set matrix of ploats
canvas.setPlotMatrix ( 3, 3 )

from hippo import Display, Cut

#
# Create a 1D histogram
#
hist = Display ( "Histogram", events, ('GLON', ) )
canvas.addDisplay ( hist )

#
# First create cuts individually 
#
from hippo import Cut
cut1 = Cut ( events, ( 'zenith_angle', ) )
canvas.addDisplay ( cut1 )
cut1.setCutRange (  80., 100., 'x' )

#
# Create a another cut and set its range
#
cut2 = Cut ( events, ( 'energy', ) )
canvas.addDisplay ( cut2 )
cut2.setCutRange ( 1e3, 1e4, 'x' )
Esempio n. 15
0
"""
import random
from time import sleep

from load_hippo import app, canvas

from hippo import Display, NTuple, NTupleController

# Create static histogram and add it to canvas.
sthist = Display ( "Static Histogram" )
sthist.setTitle ( "Gaussian Distribution (static hist)" )
sthist.setLabel ( 'x', 'X' )
sthist.setRange ( 'x', 0, 100)
sthist.setBinWidth ( 'x', 1. )
canvas.addDisplay ( sthist )

# Create second static histogram and add it to canvas
sthists = Display ( "Static Histogram" )
sthists.setTitle ( "Gaussian Distribution (low statistics)" )
sthists.setLabel ( 'x', 'X' )
sthists.setRange ( 'x', 0, 100)
sthists.setBinWidth ( 'x', 1. )
canvas.addDisplay ( sthists )

# Create empty NTuple and set the column label.
# Setting the column labels sets the number of columns
ntuple = NTuple ( )
ntuple.setTitle ( 'Gaussian Distribution' )
ntuple.setLabels ( ('X value', ) )
Esempio n. 16
0
print "Names of the Header/Data Units are..."
print hdus

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

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

from hippo import Display

#
# Create a 1D histogram
#
hist = Display("Histogram", events, ('GLON', ))
canvas.addDisplay(hist)

#
# Create a cut and set its range
#
from hippo import Cut
cut1 = Cut(events, ('zenith_angle', ))
canvas.addDisplay(cut1)
cut1.setCutRange(80., 100., 'x')

#
# Create a another cut and set its range
#
cut2 = Cut(events, ('energy', ))
canvas.addDisplay(cut2)
cut2.setCutRange(1e3, 1e4, 'x')
Esempio n. 17
0
full_path = sys.path[0] + '/' + 'aptuple.tnt'


# Read an ASCII NTuple file to create an NTuple.
ntc = NTupleController.instance()
nt1 = ntc.createNTuple ( full_path )

from hippo import Display

# Change the matrix from the default
canvas.setPlotMatrix ( 3, 4 )

# Create the  displays.

hist = Display ("Histogram", nt1, ('Cost', ) )
canvas.addDisplay( hist )

profile = Display ( "Profile", nt1, ('Age', 'Cost' ))
canvas.addDisplay ( profile )

color = Display ( "Color Plot", nt1, ('Age', 'Cost' ))
color.setBinWidth ( 'x', 1.0 )
canvas.addDisplay ( color )

contour = Display ( "Contour Plot", nt1, ('Age', 'Cost' ))
contour.setBinWidth ( 'x', 1.0 )
canvas.addDisplay ( contour )

profile2D = Display ( "Profile 2D", nt1, ('Age', 'Cost', 'Service' ))
canvas.addDisplay ( profile2D )
Esempio n. 18
0
# Create NTuple with its's controller.
ntc = NTupleController.instance()

#
# create full path to the file in case this script is not run from this
# directory
#
import sys
full_path = sys.path[0] + '/' + 'aptuple.tnt'
nt = ntc.createNTuple(full_path)

from hippo import Display

# Create a histogram
hist = Display("Histogram", nt, ('Age', ))
canvas.addDisplay(hist)

# Overlay another histogram.
hist.addDataRep('Histogram', nt, ['Service'])

#
# Set the line style and color
#
reps = hist.getDataReps()
from hippo import Line
print "The available line styles are ..."
print Line.values
print ""
try:
    reps[1].set(Line.dash)
except RuntimeError, detail:
Esempio n. 19
0
"""
   Demonstrates making simple XY plot.  

   author Paul F. Kunz <*****@*****.**>
"""
#
# load the HippoDraw module
#
from load_hippo import app, canvas

from hippo import Display

# Create list of data
energy = [90.74, 91.06, 91.43, 91.50, 92.16, 92.22, 92.96, 89.24, 89.98, 90.35]
sigma  = [ 29.0, 30.0,  28.40, 28.80, 21.95, 22.90, 13.50,  4.50, 10.80, 24.20]
errors = [  5.9,  3.15,  3.0,   5.8,  7.9,   3.1,   4.6,    3.5,   4.6,   3.6]

# make a plot to test it.
xy = Display ( "XY Plot", [ energy, sigma, errors ],
               ['Energy', 'Sigma', 'nil', 'error' ] )

canvas.addDisplay ( xy )

xy.setTitle ( 'Mark II Z0 scan' )

print "An XY plot is now displayed.   You can use the Inspector dialog"
print "to modify the appearance or fit a function to it."