Пример #1
0
def run():    
    # Here should go some meaningful data sample to test the transform.
    # Can you write one?
    n = 512
    data = numx.zeros((n,))
    x = numx.arange(n) * (2 * numx.pi / n)
    y = numx.cos(x*5)
    #result = transform(y)

    wavefreq, resampled = compress(y)

    pylab.figure(1)
    pylab.hold(0)
    pylab.plot(x,y,x,resampled)
    pylab.grid(1)
    
    pylab.figure(2)
    pylab.hold(0)
    pylab.plot(wavefreq[:30], '.-')
    pylab.grid(1)

    pylab.figure(3)
    pylab.hold(0)
    pylab.plot(wavefreq[:50], '.-')
    pylab.grid(1)
Пример #2
0
Файл: fft.py Проект: pygsl/pygsl
def real_example_simple1():
    n = 32
    data = numx.cos(1 * (numx.arange(n) * (2 * numx.pi / n))).astype(
        numx.Float32)
    print(data)
    result = fft.real_transform_float(data)
    print(result)
Пример #3
0
def run():
    # Here should go some meaningful data sample to test the transform.
    # Can you write one?
    n = 512
    data = numx.zeros((n, ))
    x = numx.arange(n) * (2 * numx.pi / n)
    y = numx.cos(x * 5)
    #result = transform(y)

    wavefreq, resampled = compress(y)

    pylab.figure(1)
    pylab.hold(0)
    pylab.plot(x, y, x, resampled)
    pylab.grid(1)

    pylab.figure(2)
    pylab.hold(0)
    pylab.plot(wavefreq[:30], '.-')
    pylab.grid(1)

    pylab.figure(3)
    pylab.hold(0)
    pylab.plot(wavefreq[:50], '.-')
    pylab.grid(1)
Пример #4
0
def complex_example_simple():
    n = 16
    data = numx.arange(n) * (2 * numx.pi / n)
    data = numx.cos(data) +0j
    space = fft.complex_workspace(n)
    wavetable = fft.complex_wavetable(n)

    print data
    #data[:11] = 1.0
    #data[11:] = 1.0
    tmp = fft.complex_backward(data, space, wavetable)
    print "tmp", tmp
Пример #5
0
Файл: fft.py Проект: pygsl/pygsl
def complex_example_simple():
    n = 16
    data = numx.arange(n) * (2 * numx.pi / n)
    data = numx.cos(data) + 0j
    space = fft.complex_workspace(n)
    wavetable = fft.complex_wavetable(n)

    print(data)
    #data[:11] = 1.0
    #data[11:] = 1.0
    pygsl.init.set_debug_level(0)
    tmp = fft.complex_backward(data, space, wavetable)
    print("tmp", tmp)
Пример #6
0
def run():
    r = rng.rng()
    bw = bspline(4, nbreak)

    # Data to be fitted
    x = 15. / (N - 1) * numx.arange(N)
    y = numx.cos(x) * numx.exp(0.1 * x)
    sigma = .1
    w = 1.0 / sigma**2 * numx.ones(N)
    dy = r.gaussian(sigma, N)
    y = y + dy

    # use uniform breakpoints on [0, 15]
    bw.knots_uniform(0.0, 15.0)

    X = numx.zeros((N, ncoeffs))
    for i in range(N):
        B = bw.eval(x[i])
        X[i, :] = B

    # do the fit
    c, cov, chisq = multifit.wlinear(X, w, y,
                                     multifit.linear_workspace(N, ncoeffs))

    # output the smoothed curve
    res_y = []
    res_y_err = []
    for i in range(N):
        B = bw.eval(x[i])
        yi, yi_err = multifit.linear_est(B, c, cov)
        res_y.append(yi)
        res_y_err.append(yi_err)
        #print yi, yerr
    res_y = numx.array(res_y)
    res_y_err = numx.array(res_y_err)
    return (
        x,
        y,
    ), (x, res_y), res_y_err
Пример #7
0
def run():
    r = rng.rng()
    bw = bspline(4, nbreak)


    # Data to be fitted
    x = 15. / (N-1) * numx.arange(N)
    y = numx.cos(x) * numx.exp(0.1 * x)    
    sigma = .1
    w = 1.0 / sigma**2 * numx.ones(N) 
    dy = r.gaussian(sigma, N)
    y  = y + dy

    # use uniform breakpoints on [0, 15] 
    bw.knots_uniform(0.0, 15.0)

    X = numx.zeros((N, ncoeffs))
    for i in range(N):
        B = bw.eval(x[i])
        X[i,:] = B
        
    # do the fit
    c, cov, chisq = multifit.wlinear(X, w, y, multifit.linear_workspace(N, ncoeffs))

    # output the smoothed curve
    res_y = []
    res_y_err = []
    for i in range(N):
        B = bw.eval(x[i])
        yi, yi_err = multifit.linear_est(B, c, cov)
        res_y.append(yi)
        res_y_err.append(yi_err)
        #print yi, yerr
    res_y = numx.array(res_y)
    res_y_err = numx.array(res_y_err)    
    return (x, y,), (x, res_y),  res_y_err
Пример #8
0
def fn1(x, params):
    return Numeric.cos(x) + 1.0
Пример #9
0
 def CosOne(self, x, l, args=()):
     y = numx.cos(x * l)
     tmp = self.convert(y)
     f = self.transform(*((tmp, ) + args))
     self._CheckCosResult(f, l)
Пример #10
0
def fn1(x, params):
    return Numeric.cos(x) + 1.0
Пример #11
0
 def CosOne(self, x, l, args=()):
     y = numx.cos(x * l)
     tmp = self.convert(y)
     f = self.transform(*((tmp,) + args))
     self._CheckCosResult(f, l)
Пример #12
0
def g(k, params):    
    numx.cos(k,k)    
    return A / (1.0 - numx.multiply.reduce(k))
Пример #13
0
def fn1(x, params):
    return numx.cos(x) + 1.0
Пример #14
0
     $ python ./interpolation.py > interp.dat
     $ graph -T ps < interp.dat > interp.ps

The result shows a smooth interpolation of the original points.  The
interpolation method can changed simply by varing spline. .

"""
from pygsl import spline, errors
from pygsl import _numobj as numx

print "#m=0,S=2"
n = 10
a = numx.arange(n)
x = a + 0.5 * numx.sin(a)
y = a + numx.cos(a**2)
for i in a:
    print x[i], y[i]

print "#m=1,S=0"
# Generation of the spline object ...  Acceleration is handled internally
myspline = spline.cspline(n)
myspline = spline.linear(n)
acc = myspline._object.get_accel_object()
#print "Accel object", dir(acc)
# initalise with the vector of the independent and the dependent
myspline.init(x,y)
x1 = numx.arange(n * 20) / 20.
for xi in x1:
    #print xi, myspline.eval(xi)
    pass
Пример #15
0
def real_example_simple1():
    n = 32
    data = numx.cos(1*(numx.arange(n) * (2 * numx.pi / n))).astype(numx.Float32)
    print data
    result =  fft.real_transform_float(data)
    print result
Пример #16
0
def g(k, params):
    numx.cos(k, k)
    return A / (1.0 - numx.multiply.reduce(k))
Пример #17
0
     $ python ./interpolation.py > interp.dat
     $ graph -T ps < interp.dat > interp.ps

The result shows a smooth interpolation of the original points.  The
interpolation method can changed simply by varing spline. .

"""
from pygsl import spline, errors, init
from pygsl import _numobj as numx

print ("#m=0,S=2")
n = 10
a = numx.arange(n)
x = a + 0.5 * numx.sin(a)
y = a + numx.cos(a**2)
for i in a:
    print (x[i], y[i])

print ("#m=1,S=0")
# Generation of the spline object ...  Acceleration is handled internally
myspline = spline.cspline(n)
myspline = spline.linear(n)
#acc = myspline._object.get_accel_object()
#print "Accel object", dir(acc)
# initalise with the vector of the independent and the dependent
init.add_c_traceback_frames(1)
#init.set_debug_level(10)
myspline.init(x, y[:3])
#print("Saved error state", init.error_handler_state_get())
Пример #18
0
def fn1(x, params):
    return numx.cos(x) + 1.0