Esempio n. 1
0
def test_make_p0_amp_appropriate():
    options = gsim.Options()
    bnd = gsim.get_start_srt(options)
    p0 = gfit_amp.make_p0(bnd, options)

    # correct length
    ntask = bnd.PSTHs.shape[0]
    assert_equal(p0.size, options.n * (ntask + 2) + 1)

    # check baseline is in range 0:20 Hz, which seems reasonable
    assert_((p0[0] >= 0) & (p0[0] <= 20.)) 
    
    # check amplitudes are in range 10:150 Hz
    assert_(np.all(p0[1:ntask * options.n + 1] >= 0) &
                       np.all(p0[1:ntask * options.n + 1] <= 150.))
    assert_(np.all(p0[1:ntask * options.n + 1] >= 0) &
                       np.all(p0[1:ntask * options.n + 1] <= 150.))

    # check widths are in range 0:0.5 s
    assert_(np.all(p0[-4:-2] >= 0) & np.all(p0[-4:-2] <= .5))
    assert_(np.all(p0[-4:-2] >= 0) & np.all(p0[-4:-2] <= .5))
    
    # check centers are in range 0:1 s
    assert_(np.all(p0[-2:] >= 0) & np.all(p0[-2:] <= 1))
    assert_(np.all(p0[-2:] >= 0) & np.all(p0[-2:] <= 1))
Esempio n. 2
0
def test_fit_pd_sim_compatibility():
    options = gsim.Options()
    bnd = gsim.get_start_srt(options)

    # test if gfit_amp.gsmx with pset gives same result
    # as gsim.make_template with amp and pd
    bin = np.linspace(0, options.tt, options.nbin + 1)
    theta = gmix.expand_theta(gmix.calc_theta_target(bnd.parent.tasks,
                                                     options.pd), bnd)
    res0 = gsim.make_template(bin, options.amp, options.width,
                              options.center, theta)
    pset = gfit_pd.make_p_from_options(bnd, options)
    b0, pd, amp, width, center = gfit_pd.unpackp(pset, options.n)
    res1 = gfit_pd.gsmx(bin, bnd.parent.tasks, pd, amp, width, center)
    res1b = np.tile(res1[:,None,:], (1, bnd.PSTHs.shape[1], 1))
    assert_array_almost_equal(res0, res1b)