Exemplo n.º 1
0
def runLoopTest(tau=650.0,nlag=4096,bw=1.0,noise=0,tolfact=10, niter=5,maxfun=1000,maxinitharm=20):
    filename = 'itersim1643_tau%.2fus_noise%.2f' % (tau,noise)
    blah,fbase = os.path.split(filename)
    plotdir = os.path.join(os.path.abspath(os.path.curdir),('%s_plots' % fbase))
    if not os.path.exists(plotdir):
        os.mkdir(plotdir)
    
    ht0 = makeht(tau=tau,nlag=nlag,bw=bw)
    np.save(os.path.join(plotdir,'ht0'), ht0)
    
    CS = initSim(ht0,bw=bw,noise=noise)
    CS.filename = filename
    
    CS.initProfile(maxinitharm=maxinitharm)
    
    np.savez(os.path.join(plotdir,'start'),cs=CS.cs,pp_ref=CS.pp_ref,
             pp_start = CS.data.mean(2).squeeze())
    
    
    for k in range(1,niter+1):
        CS.pp_ref = CS.pp_int.copy()
        CS.loop(make_plots=True,plotdir=plotdir,hf_prev=CS.hf_prev,maxfun=maxfun)
        np.savez(os.path.join(plotdir,('iter%d' % k)),
                 pp_ref=CS.pp_ref,pp_int=CS.pp_int, hf = CS.hf_prev,
                 ht = pycyc.freq2time(CS.hf_prev), csm = CS.modelCS(hf=CS.hf_prev),
                 )
Exemplo n.º 2
0
def runLoopTest(tau=650.0,
                nlag=4096,
                bw=1.0,
                noise=0,
                tolfact=10,
                niter=5,
                maxfun=1000,
                maxinitharm=20):
    filename = 'itersim1643_tau%.2fus_noise%.2f' % (tau, noise)
    blah, fbase = os.path.split(filename)
    plotdir = os.path.join(os.path.abspath(os.path.curdir),
                           ('%s_plots' % fbase))
    if not os.path.exists(plotdir):
        os.mkdir(plotdir)

    ht0 = makeht(tau=tau, nlag=nlag, bw=bw)
    np.save(os.path.join(plotdir, 'ht0'), ht0)

    CS = initSim(ht0, bw=bw, noise=noise)
    CS.filename = filename

    CS.initProfile(maxinitharm=maxinitharm)

    np.savez(os.path.join(plotdir, 'start'),
             cs=CS.cs,
             pp_ref=CS.pp_ref,
             pp_start=CS.data.mean(2).squeeze())

    for k in range(1, niter + 1):
        CS.pp_ref = CS.pp_int.copy()
        CS.loop(make_plots=True,
                plotdir=plotdir,
                hf_prev=CS.hf_prev,
                maxfun=maxfun)
        np.savez(
            os.path.join(plotdir, ('iter%d' % k)),
            pp_ref=CS.pp_ref,
            pp_int=CS.pp_int,
            hf=CS.hf_prev,
            ht=pycyc.freq2time(CS.hf_prev),
            csm=CS.modelCS(hf=CS.hf_prev),
        )
Exemplo n.º 3
0
Arquivo: tests.py Projeto: gitj/pycyc
    print "reconstructed ph does not match original ph"
    nfail +=1
    
cs, a, b, c = pycyc.make_model_cs(hf, ph, bw, ref_freq)

ph_pyrecon = pycyc.optimize_profile(cs, hf, bw, ref_freq)

ntests += 1
phreconerr = np.abs(ph[1:]-ph_pyrecon[1:]).mean() #skip zeroth harmonic since it's zeroed in ph
print "(pycyc) test if ph reconstructed from model cs and given hf matches original ph: ", phreconerr
if phreconerr > 1e-7:
    print "reconstructed ph does not match original ph"
    nfail +=1

CS = pycyc.CyclicSolver()
ht = pycyc.freq2time(hf)
CS.rindex = np.abs(ht).argmax()
print "pycyc rindex:",CS.rindex, "Cyclic-Modelling rindex:", params['rindex1']
ntests += 1
if CS.rindex != params['rindex1']:
    print "rindex1 does not agree"
    nfail +=1
CS.s0 = ph
CS.bw= bw
CS.ref_freq = ref_freq
CS.cs = cs
CS.objval = []
CS.nlag = ht.shape[0]
CS.nchan = ht.shape[0]
CS.iprint = 1
CS.make_plots = False