Esempio n. 1
0
def test_voigt_norm():
    """Tests voigt function
    """
    p = np.array([0., 0., 1., -30., 2., 3., 1., 30., 2., 3.])
    x = np.linspace(-1e6, 1e6, 8e6 + 1)
    y = functions.voigt(p, x)
    integ = simps(y, x)
    assert (abs(integ - 2.) < 1e-5)
Esempio n. 2
0
def build_data(clean=True):
    """Builds data object
    """
    p = np.array([20., 0., 3., -0.15, 0.08, 0.2, 3., 0.15, 0.08, 0.2])
    x = np.linspace(-1, 1, 81)

    if clean:
        y = functions.voigt(p, x)
        mon = 1e5
        tim = 15
    else:
        y = functions.voigt(p, x) + np.random.normal(loc=0., scale=5, size=len(x))
        mon = 1e3
        tim = 5

    output = Data(Q=np.vstack((item.ravel() for item in np.meshgrid(x, 0., 0., 4., 300.))).T,
                  detector=y, monitor=np.full(x.shape, mon, dtype=float), time=np.full(x.shape, tim, dtype=float))

    return output
Esempio n. 3
0
def test_voigt_fit_of_voigt_rand():
    """Test voigt fit of voigt function
    """
    p = np.array([0., 0., 3., 0., 0.3, 0.2])
    x = np.linspace(-1, 1, 201)
    y = functions.voigt(p, x) + np.random.normal(loc=0., scale=0.1, size=201)
    err = np.sqrt(np.abs(y))

    fitobj = Fitter(residuals=residuals, data=(functions.voigt, x, y, err))
    fitobj.parinfo = [{'fixed': fix} for fix in np.asarray([0, 0, 0, 0, 0, 0]).astype(bool)]
    fitobj.fit(params0=p)

    assert ((fitobj.chi2_min < 5.))