예제 #1
0
def newNumArrayTuple(arrays, labels, name="", register=1):
    """
    Define and register an new hippo NumArray
    usage: nt = newNumArrayTuple( (x, y, ...), ("x", "y", ...),
                                  name="", register=1 )
    """
    nt = hippo.NumArrayTuple()
    for array, label in zip(arrays, labels):
        nt.addColumn(label, array)
    if name != "":
        nt.setName(name)
    if register:
        registerNTuple(nt)
    addNTuple(nt, key=name)
    return nt
예제 #2
0
 def makeNTuple(self, name=None, useNumArray=1):
     import hippo, sys, numarray
     if useNumArray:
         nt = hippo.NumArrayTuple()
     else:
         nt = hippo.NTuple()
     if name != None:
         nt.setTitle(name)
     ntc = hippo.NTupleController.instance()
     ntc.registerNTuple(nt)
     for name in self.names:
         if type(self.__dict__[name][0]) == np.ndarray:
             columns = self.__dict__[name]
             columns.transpose()
             for i, col in zip(xrange(sys.maxint), columns):
                 colname = "%s%i" % (name, i)
                 nt.addColumn(colname, col)
         else:
             nt.addColumn(name, self.__dict__[name])
     return nt
예제 #3
0
 def makeNTuple(self, name=None, useNumArray=1):
     import hippo
     if useNumArray:
         nt = hippo.NumArrayTuple()
     else:
         nt = hippo.NTuple()
     if name != None:
         nt.setTitle(name)
     ntc = hippo.NTupleController.instance()
     ntc.registerNTuple(nt)
     for name in self.names:
         if len(self.__dict__[name].shape) > 1:  # have multicolumn variable
             columns = self.__dict__[name]
             columns.transpose()
             for i, col in enumerate(columns):
                 colname = "%s%i" % (name, i)
                 nt.addColumn(colname, col)
         else:
             try:
                 nt.addColumn(name, self.__dict__[name])
             except TypeError:
                 pass
     return nt
예제 #4
0
파일: fft.py 프로젝트: tfeusels/hippodraw
    import numpy as num
    import numpy.random as ra
except :
    import numarray as num
    import num.random_array as ra


canvas.setPlotMatrix ( 1, 3 )

#
# 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