Source code for irfpy.imacommon.ql.panels

""" A collection of axis methods.
"""
import datetime as _datetime

import numpy as np
from matplotlib import pyplot as plt
import matplotlib.colors as mplcolors

from irfpy.imacommon import imascipac

import irfpy.util.time_panel

[docs]def axis_etdiagram(etbl, data2d, azim=None, ax=None, vmin=0.1, vmax=100.0): """ From given 2D data, ET diagram is plotted. :: import matplotlib.pyplot as plt plt.ion() from irfpy.mima.ql import panels import irfpy.mima.scidata_util as msu import datetime t0 = datetime.datetime(2016, 1, 1, 20) t1 = datetime.datetime(2016, 1, 1, 22) msu.getarray2d(t0, t1) arr2d = msu.getarray2d(t0, t1, emulate_full=True) from irfpy.mima import energy energy.get_default_table_v5_late() etbl = energy.get_default_table_v5_late() ax, img = panels.axis_etdiagram(etbl, arr2d) ax.set_xlabel('UT') ax.set_ylabel('Energy [eV]') clb = plt.colorbar(img) clb.set_label('Counts [Az: sum(0-15)]') plt.show() """ if ax is None: fig = plt.figure() ax = fig.add_subplot(111) if len(data2d) == 0: ax.plot_date([_datetime.datetime(2000, 1, 1), _datetime.datetime(2000, 1, 2)], [0, 96]) # Just plot invalid data. return obst = np.array(data2d.getobstime()) ## (N,) array in datetime object et = imascipac.timeseries2d_to_energytime_simple(data2d, azim=azim) # (96, N) matrix x, y = irfpy.util.time_panel.reform(obst, et.T, _datetime.timedelta(seconds=192)) img = ax.pcolormesh(x, etbl, y.T, vmin=vmin, vmax=vmax, norm=mplcolors.LogNorm()) ax.set_yscale('log') ax.set_ylim(1, 16000) # ax.set_xlabel('UT') # ax.set_ylabel('Energy') return ax, img
[docs]def axis_etdiagram_max(etbl, data2d, azim=None, ax=None, vmin=0.1, vmax=100.0): """ From given 2D data, ET diagram is plotted. Take the maximum counts for the specific bin over the given azimuth channel. :: import matplotlib.pyplot as plt plt.ion() from irfpy.mima.ql import panels import irfpy.mima.scidata_util as msu import datetime t0 = datetime.datetime(2016, 1, 1, 20) t1 = datetime.datetime(2016, 1, 1, 22) msu.getarray2d(t0, t1) arr2d = msu.getarray2d(t0, t1, emulate_full=True) from irfpy.mima import energy energy.get_default_table_v5_late() etbl = energy.get_default_table_v5_late() ax, img = panels.axis_etdiagram_max(etbl, arr2d) ax.set_xlabel('UT') ax.set_ylabel('Energy [eV]') clb = plt.colorbar(img) clb.set_label('Counts [Az: max(0-15)]') plt.show() """ if ax is None: fig = plt.figure() ax = fig.add_subplot(111) if len(data2d) == 0: ax.plot_date([_datetime.datetime(2000, 1, 1), _datetime.datetime(2000, 1, 2)], [0, 96]) # Just plot invalid data. return obst = np.array(data2d.getobstime()) ## (N,) array in datetime object et = imascipac.timeseries2d_to_energytime_max(data2d, azim=azim) # (96, N) matrix x, y = irfpy.util.time_panel.reform(obst, et.T, _datetime.timedelta(seconds=192)) img = ax.pcolormesh(x, etbl, y.T, vmin=vmin, vmax=vmax, norm=mplcolors.LogNorm()) ax.set_yscale('log') ax.set_ylim(1, 16000) # ax.set_xlabel('UT') # ax.set_ylabel('Energy') return ax, img