vima_demo.vima_masscontourΒΆ

Script to plot mass contours for PACC=0, 3, and 6 for VEX.

The mass contour is obtained from irfpy.vima.massring.massline() function.

""" Script to plot mass contours for PACC=0, 3, and 6 for VEX.

The mass contour is obtained from :func:`irfpy.vima.massring.massline` function.
"""
import numpy as np
import matplotlib.pyplot as plt
import irfpy.vima.massring

def main():
    '''Main script'''

    mass = [1, 2, 4, 16, 32, 44]
    massname = ['H+', 'He++', 'He+', 'O+', 'O2+', 'CO2+']
    masscolor = 'brgcmyk'

    energy = np.logspace(1, 4.5, 96)   # 10 eV to 30000 eV with 96 steps.

    fig = plt.figure(figsize=[14, 6])

    for i, pacc_index in enumerate((0, 3, 6)):
        ax = fig.add_subplot(1, 3, i + 1)

        for m, mn, c in zip(mass, massname, masscolor):  # m for mass, mn for mass name, and c for color to plot.

            # The massline function returns two arrays, energy [eV/q] and mass index list for given mass, m.
            energy_list, mass_list = irfpy.vima.massring.massline(m, pacc_index, enestep=energy)
            ax.plot(mass_list, energy_list, color=c)    # Plotting the mass line.
            ax.text(mass_list[75 - m], energy_list[75 - m], mn, color=c, ha='center')   # Just to make label.

        ax.set_title('PACC={}'.format(pacc_index))
        ax.set_yscale('log')
        ax.set_xlabel('Mass ring')
        ax.set_ylabel('Energy [eV/q]')
        ax.set_xlim(0, 32)
        ax.set_ylim(10, 10 ** 4.5)

    plt.savefig('vima_masscontour.png')

if __name__ == "__main__":
    main()