コード例 #1
0
def test2Dfit(fitType = None, verbose = False):
    testDebug = 0
    testOptimizer = 'levmar'
    roi = [1, 325, 1, 335]
    conIm = PrincetonSPEFile('testimage.spe')[0].astype(float32)
    conZ = array(meshgrid(arange(roi[0], roi[0] + roi[1]), arange(roi[2], roi[2] + roi[3])))
    if fitType == 'twodgauss':    
        guess = array([ conIm.max(), 162.5, 5, 167.5, 6])
        func = [twodgauss]
    elif fitType == 'twodgausslin':
        guess = array([ 0.01*conIm.max(), 1e-8, 1e-8, conIm.max(), 162.5, 5, 167.5, 6])
        func = [twodlin, twodgauss]

    times = []
    for optimizer in ['leastsq', 'levmar', 'mpfit']:
        f = fit.fit(x = conZ, y = conIm, funcs = func , guess = guess, 
                    debug = testDebug, optimizer = optimizer)
        t1 = time.time()
        f.go()
        t2 = time.time()

        times.append('Optimizer %s took %0.3f s' % (optimizer, (t2-t1)))
   
    for t in times:
        print t
コード例 #2
0
def test2Dfit(fitType=None, verbose=False):
    testDebug = 0
    testOptimizer = 'levmar'
    roi = [1, 325, 1, 335]
    conIm = PrincetonSPEFile('testimage.spe')[0].astype(float32)
    conZ = array(
        meshgrid(arange(roi[0], roi[0] + roi[1]),
                 arange(roi[2], roi[2] + roi[3])))
    if fitType == 'twodgauss':
        guess = array([conIm.max(), 162.5, 5, 167.5, 6])
        func = [twodgauss]
    elif fitType == 'twodgausslin':
        guess = array(
            [0.01 * conIm.max(), 1e-8, 1e-8,
             conIm.max(), 162.5, 5, 167.5, 6])
        func = [twodlin, twodgauss]

    times = []
    for optimizer in ['leastsq', 'levmar', 'mpfit']:
        f = fit.fit(x=conZ,
                    y=conIm,
                    funcs=func,
                    guess=guess,
                    debug=testDebug,
                    optimizer=optimizer)
        t1 = time.time()
        f.go()
        t2 = time.time()

        times.append('Optimizer %s took %0.3f s' % (optimizer, (t2 - t1)))

    for t in times:
        print t
コード例 #3
0
def test():
    t1 = time.time()
    conIm = PrincetonSPEFile('testimage2.spe')
    conIm = conIm.getData().astype(np.float32)
    t2 = time.time()
    print "Read took %.3f msec" % ((t2 - t1) * 1000)

    pylab.figure()
    pylab.imshow(conIm.sum(0))

    t1 = time.time()
    conIm = princeton.readSPE('testimage2.spe').astype(np.float32)
    t2 = time.time()
    print "Read took %.3f msec" % ((t2 - t1) * 1000)

    pylab.figure()
    pylab.imshow(conIm.sum(0))
    pylab.show()
コード例 #4
0
ファイル: testPrinceton.py プロジェクト: BootstrapB/pyspec
def test():
    t1 = time.time()
    conIm = PrincetonSPEFile('testimage2.spe')
    conIm = conIm.getData().astype(np.float32)
    t2 = time.time()
    print "Read took %.3f msec" % ((t2 - t1) * 1000)

    pylab.figure()
    pylab.imshow(conIm.sum(0))

    t1 = time.time()
    conIm = princeton.readSPE('testimage2.spe').astype(np.float32)
    t2 = time.time()
    print "Read took %.3f msec" % ((t2 - t1) * 1000)

    pylab.figure()
    pylab.imshow(conIm.sum(0))
    pylab.show()