Source code for irfpy.mima.ql.patches

""" Provide 'matplotlib patches'.
"""
import numpy as _np
from matplotlib.patches import Polygon as _Polygon

from irfpy.mima import fov as ifov


[docs]def BlockedFov(kind, phase=0, **kwds): r""" Return a patch that represents the blocked angle Blocked FOV is returned as a patch. Usual work flow is .. code-block:: python b0 = BlockedFov('angle', phase=0, facecolor='black') b1 = BlockedFov('angle', phase=1, facecolor='black') plt.add_patch(b0) plt.add_patch(b1) plt.xlim(-22.5, 337.5) # This is for azim0 to 15. plt.ylim(-90, 90) # Full elevation angle Here one may want to add two or more shapes, since the azimuthal angle is periodic, and not necessarily coincide the boundary angle. (e.g. where the plot start? 0 deg? -22.5 deg (=CH-0)? or -180 deg?) :param kind: Kind of returned values. - "index" or "number" is for the instrument index (looking angle) - "angle" is for the angle in IMA's frame (elevation-azimuthal pair) :keyword phase: A number that specify the phase. - If phase=0 as default, the returned index is in the range of [-8.5 to 1.5] (or corresponding angles). - If phase=1, the returned index is in the range of [7.5 to 17.5] or corresponding angles). :keyword **kwds: Any keyword that are fed into matplotlib.pathces.Polygon """ if kind.lower() in ('number', 'index'): return _BlockFov_number(phase=phase, **kwds); elif kind.lower() in ('angle'): return _BlockFov_angle(phase=phase, **kwds); else: raise ValueError('The given kind (=``{}``) is unknown. ' + 'The kind should be either of index, number, or angle')
def _BlockFov_number(phase=0, **kwds): fov = ifov.SimpleFOV() corners = fov.shadow_mask_corners(phase=phase) return _Polygon(corners, **kwds) def _BlockFov_angle(phase=0, **kwds): fov = ifov.SimpleFOV() corners = fov.shadow_mask_corners(phase=phase) a = fov.azimuth_angle(corners[:, 0]) e = fov.elevation_angle(corners[:, 1]) return _Polygon(_np.transpose([a, e]), **kwds)