Source code for irfpy.vima.ql.panels

"""
"""
import numpy as _np
import matplotlib.pyplot as _plt
import matplotlib.patches as _mplpatches
import matplotlib.colors as _mplcolors
from matplotlib.colors import LogNorm as _LogNorm

from irfpy.vima import fov as _fov
from irfpy.vima import energy as _energy
from irfpy.imacommon.imascipac import CntMatrix


[docs]def axis_shadow_mask_line(ax=None, **kwds): simplefov = _fov.SimpleFOV() aedge, pedge = _fov.edge_shadow_mask() if ax is None: ax = _plt.gca() ax.plot(simplefov.azimuth_angle(aedge, normalize=False), simplefov.elevation_angle(pedge), **kwds) return ax, ()
[docs]def axis_shadow_mask_alpha(ax=None, alpha=0.2, color='k', **kwds): simplefov = _fov.SimpleFOV() shadow_mask = _fov.get_shadow_mask() if ax is None: ax = _plt.gca() for ia in range(16): for ip in range(16): if shadow_mask[ia, ip]: p = _mplpatches.Rectangle([simplefov.azimuth_angle(ia - 0.45, normalize=False), simplefov.elevation_angle(ip - 0.45)], 22.5 * 0.9, 5.625 * 0.9, alpha=alpha, color=color, **kwds) ax.add_patch(p) return ax, ()
[docs]def axis_polar_azimuth(ima3d, e0=0, e1=96, m0=0, m1=32, vmin=0.9, vmax=3000, ax=None, ): """ Polar-Azimuth plot """ simplefov = _fov.SimpleFOV() dat3d = ima3d.matrix # (M32, A16, E96, P16) array ap = dat3d[m0:m1, :, e0:e1, :].sum(axis=2).sum(axis=0) if ax is None: ax = _plt.gca() img = ax.pcolormesh(simplefov.azimuth_angle(_np.arange(-0.5, 16.5), normalize=False), simplefov.elevation_angle(_np.arange(-0.5, 16.5)), ap.T, norm=_mplcolors.LogNorm(vmin=vmin, vmax=vmax)) # axis.set_xlabel('Azimuth angle (Geometric, IMAS)') # axis.set_ylabel('Elevation angle (Geometric, IMAS)') # title = 'VEX/IMA @ {:%FT%T}'.format(ima3d.t) + '({}<=E<{})'.format(e0, e1) +'({}<=M<{})'.format(m0, m1) # # axis.set_title(title) # # axis.set_xlim(-90, 270) # axis.set_ylim(-90, 90) return ax, (img,)
[docs]def axis_energy_mass(ima3d: CntMatrix , vmin=0.9, vmax=3000, vlog=True, masses=[1, 2, 4, 16, 32], masscolor='white', massalpha=0.4, ax=None, *args, **kwds): """ Energy mass plot """ if ax is None: ax = _plt.gca() if vlog: norm = _LogNorm(vmin=vmin, vmax=vmax) else: raise NotImplementedError('') import numpy as _np mring = _np.arange(33) ene = _energy.get_default_table_for(ima3d, keep_negative=False) from irfpy.util import nptools as _npt eneb = _npt.guess_bounds(ene, log=True) emmatrix = ima3d.matrix.sum(axis=(1, 3)) # MAEP -> ME img = ax.pcolormesh(mring, eneb, emmatrix.T, norm=norm, *args, **kwds) ax.set_ylim(10, ene.max()) ax.set_yscale('log') ax.set_xlabel('Mass ring number') ax.set_ylabel('Energy [eV]') from irfpy.vima import massring as _mring pi = 6 # Always for VEX. for m in masses: estep, mline = _mring.massline(m, pi, enestep=ene) ax.plot(mline, estep, color=masscolor, alpha=massalpha) ax.text(mline[8], estep[8], f'{m:d}', color=masscolor, ha='center') return ax, (img,)