コード例 #1
0
def test_gauss_peak():
    """
    test of gauss function from xrf fit
    """
    area = 1
    cen = 0
    std = 1
    x = np.arange(-3, 3, 0.5)
    out = gaussian(x, area, cen, std)

    y_true = [
        0.00443185,
        0.0175283,
        0.05399097,
        0.1295176,
        0.24197072,
        0.35206533,
        0.39894228,
        0.35206533,
        0.24197072,
        0.1295176,
        0.05399097,
        0.0175283,
    ]

    assert_array_almost_equal(y_true, out)
コード例 #2
0
def test_gauss_peak():
    """
    test of gauss function from xrf fit
    """
    area = 1
    cen = 0
    std = 1
    x = np.arange(-3, 3, 0.5)
    out = gaussian(x, area, cen, std)

    y_true = [
        0.00443185, 0.0175283, 0.05399097, 0.1295176, 0.24197072, 0.35206533,
        0.39894228, 0.35206533, 0.24197072, 0.1295176, 0.05399097, 0.0175283
    ]

    assert_array_almost_equal(y_true, out)
コード例 #3
0
def get_spectrum(ax, name, incident_energy, emax=15):
    """
    Plot fluorescence spectrum for a given element.

    Parameters
    ----------
    name : str or int
        element name, or atomic number
    incident_energy : float
        xray incident energy for fluorescence emission
    emax : float
        max value on spectrum

    """
    e = XrfElement(name)
    lines = e.emission_line.all
    ratio = [val for val in e.cs(incident_energy).all if val[1] > 0]

    x = np.arange(0, emax, 0.01)

    spec = np.zeros(len(x))

    i_min = 1e-6

    for item in ratio:
        for data in lines:
            if item[0] == data[0]:

                ax.plot([data[1], data[1]], [i_min, item[1]],
                        'g-',
                        linewidth=2.0)

    std = 0.1
    area = std * np.sqrt(2 * np.pi)
    for item in ratio:
        for data in lines:
            if item[0] == data[0]:
                spec += gaussian(x, area, data[1], std) * item[1]

    #plt.semilogy(x, spec)
    ax.set_title('Simulated spectrum for %s at %s eV' %
                 (name, incident_energy))
    ax.set_xlabel('Energy [KeV]')
    ax.set_ylabel('Intensity')
    ax.plot(x, spec)
コード例 #4
0
def get_spectrum(ax, name, incident_energy, emax=15):
    """
    Plot fluorescence spectrum for a given element.

    Parameters
    ----------
    name : str or int
        element name, or atomic number
    incident_energy : float
        xray incident energy for fluorescence emission
    emax : float
        max value on spectrum

    """
    e = XrfElement(name)
    lines = e.emission_line.all
    ratio = [val for val in e.cs(incident_energy).all if val[1] > 0]

    x = np.arange(0, emax, 0.01)

    spec = np.zeros(len(x))

    i_min = 1e-6

    for item in ratio:
        for data in lines:
            if item[0] == data[0]:

                ax.plot([data[1], data[1]],
                         [i_min, item[1]], 'g-', linewidth=2.0)

    std = 0.1
    area = std * np.sqrt(2 * np.pi)
    for item in ratio:
        for data in lines:
            if item[0] == data[0]:
                spec += gaussian(x, area, data[1], std) * item[1]

    #plt.semilogy(x, spec)
    ax.set_title('Simulated spectrum for %s at %s eV' % (name, incident_energy))
    ax.set_xlabel('Energy [KeV]')
    ax.set_ylabel('Intensity')
    ax.plot(x, spec)