Beispiel #1
0
def test_elastic_model():

    area = 11
    energy = 10
    offset = 0.02
    fanoprime = 0.03
    e_offset = 0
    e_linear = 0.01
    e_quadratic = 0

    true_param = [fanoprime, area, energy]

    x = np.arange(800, 1200, 1)
    out = elastic(x, area, energy, offset, fanoprime,
                  e_offset, e_linear, e_quadratic)

    elastic_model = ElasticModel()

    # fwhm_offset is not a sensitive parameter, used as a fixed value
    elastic_model.set_param_hint(name='e_offset', value=0, vary=False)
    elastic_model.set_param_hint(name='e_linear', value=0.01, vary=False)
    elastic_model.set_param_hint(name='e_quadratic', value=0, vary=False)
    elastic_model.set_param_hint(name='coherent_sct_energy', value=10, vary=False)
    elastic_model.set_param_hint(name='fwhm_offset', value=0.02, vary=False)
    elastic_model.set_param_hint(name='fwhm_fanoprime', value=0.03, vary=False)

    result = elastic_model.fit(out, x=x, coherent_sct_amplitude=10)

    fitted_val = [result.values['fwhm_fanoprime'], result.values['coherent_sct_amplitude'],
                  result.values['coherent_sct_energy']]

    assert_array_almost_equal(true_param, fitted_val, decimal=2)
Beispiel #2
0
def test_elastic_peak():
    """
    test of elastic peak from xrf fit
    """

    y_true = [0.00085311,  0.00164853,  0.00307974,  0.00556237,  0.00971259,
              0.01639604,  0.02675911,  0.04222145,  0.06440556,  0.09498223,
              0.13542228,  0.18666663,  0.24875512,  0.32048386,  0.39918028,
              0.48068522,  0.55960456,  0.62984039,  0.68534389,  0.72096698,
              0.73324816,  0.72096698,  0.68534389,  0.62984039,  0.55960456,
              0.48068522,  0.39918028,  0.32048386,  0.24875512,  0.18666663,
              0.13542228,  0.09498223,  0.06440556,  0.04222145,  0.02675911,
              0.01639604,  0.00971259,  0.00556237,  0.00307974,  0.00164853]

    area = 1
    energy = 10
    offset = 0.01
    fanoprime = 0.01
    e_offset = 0
    e_linear = 1
    e_quadratic = 0

    ev = np.arange(8, 12, 0.1)
    out = elastic(ev, area, energy,
                  offset, fanoprime,
                  e_offset, e_linear, e_quadratic)

    assert_array_almost_equal(y_true, out)