Ejemplo n.º 1
0
def test_compton_model():

    energy = 10
    offset = 0.001
    fano = 0.01
    angle = 90
    fwhm_corr = 1
    amp = 20
    f_step = 0.05
    f_tail = 0.1
    gamma = 2
    hi_f_tail = 0.01
    hi_gamma = 1
    e_offset = 0
    e_linear = 0.01
    e_quadratic = 0
    x = np.arange(800, 1200, 1.0)

    true_param = [energy, amp]

    out = compton(x, amp, energy, offset, fano, e_offset, e_linear,
                  e_quadratic, angle, fwhm_corr, f_step, f_tail, gamma,
                  hi_f_tail, hi_gamma)

    cm = ComptonModel()
    # parameters not sensitive
    cm.set_param_hint(name='compton_hi_gamma', value=hi_gamma, vary=False)
    cm.set_param_hint(name='fwhm_offset', value=offset, vary=False)
    cm.set_param_hint(name='compton_angle', value=angle, vary=False)
    cm.set_param_hint(name='e_offset', value=e_offset, vary=False)
    cm.set_param_hint(name='e_linear', value=e_linear, vary=False)
    cm.set_param_hint(name='e_quadratic', value=e_quadratic, vary=False)
    cm.set_param_hint(name='fwhm_fanoprime', value=fano, vary=False)
    cm.set_param_hint(name='compton_hi_f_tail', value=hi_f_tail, vary=False)
    cm.set_param_hint(name='compton_f_step', value=f_step, vary=False)
    cm.set_param_hint(name='compton_f_tail', value=f_tail, vary=False)
    cm.set_param_hint(name='compton_gamma', value=gamma, vary=False)
    cm.set_param_hint(name='compton_amplitude', value=20, vary=False)
    cm.set_param_hint(name='compton_fwhm_corr', value=fwhm_corr, vary=False)

    p = cm.make_params()
    result = cm.fit(out,
                    x=x,
                    params=p,
                    compton_amplitude=20,
                    coherent_sct_energy=10)

    fit_val = [
        result.values['coherent_sct_energy'],
        result.values['compton_amplitude']
    ]

    assert_array_almost_equal(true_param, fit_val, decimal=2)
Ejemplo n.º 2
0
def test_compton_model():

    energy = 10
    offset = 0.001
    fano = 0.01
    angle = 90
    fwhm_corr = 1
    amp = 20
    f_step = 0.05
    f_tail = 0.1
    gamma = 2
    hi_f_tail = 0.01
    hi_gamma = 1
    e_offset = 0
    e_linear = 0.01
    e_quadratic = 0
    x = np.arange(800, 1200, 1.0)

    true_param = [energy, amp]

    out = compton(x, amp, energy, offset, fano,
                  e_offset, e_linear, e_quadratic,
                  angle, fwhm_corr, f_step, f_tail,
                  gamma, hi_f_tail, hi_gamma)

    cm = ComptonModel()
    # parameters not sensitive
    cm.set_param_hint(name='compton_hi_gamma', value=hi_gamma, vary=False)
    cm.set_param_hint(name='fwhm_offset', value=offset, vary=False)
    cm.set_param_hint(name='compton_angle', value=angle, vary=False)
    cm.set_param_hint(name='e_offset', value=e_offset, vary=False)
    cm.set_param_hint(name='e_linear', value=e_linear, vary=False)
    cm.set_param_hint(name='e_quadratic', value=e_quadratic, vary=False)
    cm.set_param_hint(name='fwhm_fanoprime', value=fano, vary=False)
    cm.set_param_hint(name='compton_hi_f_tail', value=hi_f_tail, vary=False)
    cm.set_param_hint(name='compton_f_step', value=f_step, vary=False)
    cm.set_param_hint(name='compton_f_tail', value=f_tail, vary=False)
    cm.set_param_hint(name='compton_gamma', value=gamma, vary=False)
    cm.set_param_hint(name='compton_amplitude', value=20, vary=False)
    cm.set_param_hint(name='compton_fwhm_corr', value=fwhm_corr, vary=False)

    p = cm.make_params()
    result = cm.fit(out, x=x, params=p, compton_amplitude=20,
                    coherent_sct_energy=10)

    fit_val = [result.values['coherent_sct_energy'],
               result.values['compton_amplitude']]

    assert_array_almost_equal(true_param, fit_val, decimal=2)
Ejemplo n.º 3
0
def test_compton_peak():
    """
    test of compton peak from xrf fit
    """
    y_true = [
        0.01332237, 0.01536984, 0.01870113, 0.02401014, 0.03223281, 0.04455143,
        0.0623487, 0.08709168, 0.12013435, 0.16244524, 0.2142911, 0.27493377,
        0.34241693, 0.41352197, 0.48395163, 0.5487556, 0.6029529, 0.64224726,
        0.66369326, 0.65792554, 0.63050209, 0.58478146, 0.52510892, 0.45674079,
        0.38508357, 0.31500557, 0.25033778, 0.19362201, 0.14610264, 0.10790876,
        0.07834781, 0.05623019, 0.04016135, 0.02876383, 0.02081757, 0.01532608,
        0.01152704, 0.00886833, 0.00696818, 0.00557234
    ]

    energy = 10
    offset = 0.01
    fano = 0.01
    angle = 90
    fwhm_corr = 1
    amp = 1
    f_step = 0
    f_tail = 0.1
    gamma = 10
    hi_f_tail = 0.1
    hi_gamma = 1

    e_offset = 0
    e_linear = 1
    e_quadratic = 0

    ev = np.arange(8, 12, 0.1)

    out = compton(ev, amp, energy, offset, fano, e_offset, e_linear,
                  e_quadratic, angle, fwhm_corr, f_step, f_tail, gamma,
                  hi_f_tail, hi_gamma)

    assert_array_almost_equal(y_true, out)
Ejemplo n.º 4
0
def test_compton_peak():
    """
    test of compton peak from xrf fit
    """
    y_true = [0.01332237,  0.01536984,  0.01870113,  0.02401014,  0.03223281,
              0.04455143,  0.0623487,   0.08709168,  0.12013435,  0.16244524,
              0.2142911,   0.27493377,  0.34241693,  0.41352197,  0.48395163,
              0.5487556,   0.6029529,   0.64224726,  0.66369326,  0.65792554,
              0.63050209,  0.58478146,  0.52510892,  0.45674079,  0.38508357,
              0.31500557,  0.25033778,  0.19362201,  0.14610264,  0.10790876,
              0.07834781,  0.05623019,  0.04016135,  0.02876383,  0.02081757,
              0.01532608,  0.01152704,  0.00886833,  0.00696818,  0.00557234]

    energy = 10
    offset = 0.01
    fano = 0.01
    angle = 90
    fwhm_corr = 1
    amp = 1
    f_step = 0
    f_tail = 0.1
    gamma = 10
    hi_f_tail = 0.1
    hi_gamma = 1

    e_offset = 0
    e_linear = 1
    e_quadratic = 0

    ev = np.arange(8, 12, 0.1)

    out = compton(ev, amp, energy, offset, fano,
                  e_offset, e_linear, e_quadratic, angle,
                  fwhm_corr, f_step, f_tail,
                  gamma, hi_f_tail, hi_gamma)

    assert_array_almost_equal(y_true, out)