コード例 #1
0
def get_line(ax, name, incident_energy):
    """
    Plot emission lines for a given element.

    Parameters
    ----------
    name : str or int
        element name, or atomic number
    incident_energy : float
        xray incident energy for fluorescence emission
    """
    e = XrfElement(name)
    lines = e.emission_line.all
    ratio = [val for val in e.cs(incident_energy).all if val[1] > 0]

    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)

    ax.set_title('Emission lines for %s at %s eV' % (name, incident_energy))
    ax.set_xlabel('Energy [KeV]')
    ax.set_ylabel('Intensity')
コード例 #2
0
def get_line(ax, name, incident_energy):
    """
    Plot emission lines for a given element.

    Parameters
    ----------
    name : str or int
        element name, or atomic number
    incident_energy : float
        xray incident energy for fluorescence emission
    """
    e = XrfElement(name)
    lines = e.emission_line.all
    ratio = [val for val in e.cs(incident_energy).all if val[1] > 0]

    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)

    ax.set_title('Emission lines for %s at %s eV' % (name, incident_energy))
    ax.set_xlabel('Energy [KeV]')
    ax.set_ylabel('Intensity')
コード例 #3
0
def run_demo():
    import matplotlib.pyplot as plt
    e = XrfElement('Cu')
    print('Cu ka1 = %s' % e.emission_line['ka1'])
    print('all Cu emission lines\n{}'.format(e.emission_line.all))
    print('fluorescence cross section of Cu at 12 eV = %s' % e.cs(12).all)
    print('showing spectrum for Cu at 12 eV')
    fig, ax = plt.subplots(nrows=2, ncols=2, sharex=True, sharey=True)
    ax = ax.ravel()
    get_line(ax[0], 'Cu', 12)
    get_spectrum(ax[1], 'Cu', 12)
    get_line(ax[2], 'Gd', 12)
    get_spectrum(ax[3], 'Gd', 12)
    plt.show()
コード例 #4
0
def run_demo():
    import matplotlib.pyplot as plt
    e = XrfElement('Cu')
    print('Cu ka1 = %s' % e.emission_line['ka1'])
    print('all Cu emission lines\n{}'.format(e.emission_line.all))
    print('fluorescence cross section of Cu at 12 eV = %s' % e.cs(12).all)
    print('showing spectrum for Cu at 12 eV')
    fig, ax = plt.subplots(nrows=2, ncols=2, sharex=True, sharey=True)
    ax = ax.ravel()
    get_line(ax[0], 'Cu', 12)
    get_spectrum(ax[1], 'Cu', 12)
    get_line(ax[2], 'Gd', 12)
    get_spectrum(ax[3], 'Gd', 12)
    plt.show()
コード例 #5
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)
コード例 #6
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)