apps120714_mhddata.mhddata_sample_enaflux_2dΒΆ

''' A sample to plot the data point for the flux.
'''

import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt

from pyana.pep import mhddata

if __name__ == "__main__":
    f = mhddata.Flux1205()

    lon = f.reshape(f.lonlist())
    lat = f.reshape(f.latlist())
    flx = f.reshape(f.flist())

    enaflx = flx * 0.2   # 20% fraction backscattered
    enaflx = enaflx / (2 * np.pi)   # 2 pi steradian, ie isotropic
    enaflx = enaflx / 100   # 100eV width assumed

    enaflx = np.log10(enaflx)  # LOG scale

    # Prepare the map
    plt.figure(figsize=(12, 5))
    m = Basemap(projection='moll', lon_0=0, resolution='c')
    # Note that lon_0 should be 0, if one calls
    # pcolor or pcolormesh.
    # In case you want to change the longitude,
    # it is simpler to change the data array rather than the
    # argument lon_0.  Wrapping may have some issues in the core library.
    x, y = m(lon, lat)

    # Mask the data if too small.
    enaflx = np.ma.masked_less(enaflx, -3)
    p = m.pcolor(x, y, enaflx, vmin=0)

    # Decoration.
    m.drawparallels(np.arange(-90, 120, 30))
    m.drawmeridians(np.arange(-180, 210, 30))
    m.drawmapboundary()
    plt.title('LOG of ENA diff flux [/cm2 /s /sr /eV]')

    # Colorbar.
    plt.colorbar(p)
#    plt.show()

    plt.savefig('mhddata_sample_enaflux_2d.eps')