Source code for pyarts3.plots.ZenGrid

""" Plotting routine for ZenGrid """

import numpy
import matplotlib
import pyarts3 as pyarts
import numpy as np
from .common import default_fig_ax, select_flat_ax

__all__ = [
    'plot',
]


[docs] def plot(data: pyarts.arts.ZenGrid, *, fig: matplotlib.figure.Figure | None = None, ax: matplotlib.axes.Axes | list[matplotlib.axes.Axes] | numpy.ndarray[matplotlib.axes.Axes] | None = None, polar: bool = False, **kwargs) -> tuple[matplotlib.figure.Figure, matplotlib.axes.Axes | list[matplotlib.axes.Axes] | numpy.ndarray[matplotlib.axes.Axes]]: """Plot a ZenGrid showing zenith angles. .. rubric:: Example .. plot:: :include-source: import pyarts3 as pyarts import numpy as np # Create zenith angles from 0° (up) to 180° (down) zenith = pyarts.arts.ZenGrid(np.linspace(0, 180, 19)) pyarts.plots.ZenGrid.plot(zenith, polar=True) Parameters ---------- data : ~pyarts3.arts.ZenGrid A sorted grid of zenith angles [0, 180] fig : ~matplotlib.figure.Figure, optional The matplotlib figure to draw on. Defaults to None for new figure. ax : ~matplotlib.axes.Axes | list[~matplotlib.axes.Axes] | ~numpy.ndarray[~matplotlib.axes.Axes] | None, optional The matplotlib axes to draw on. Defaults to None for new axes. polar : bool, optional If True, use polar plot. Defaults to False. **kwargs : keyword arguments Additional keyword arguments to pass to the plotting functions. Returns ------- fig : As input if input. Otherwise the created Figure. ax : As input if input. Otherwise the created Axes. """ fig, ax = default_fig_ax(fig, ax, ax_kwargs={"subplot_kw": {'polar': polar}}, fig_kwargs={ 'figsize': (10, 8) if polar else (10, 6)}) if polar: select_flat_ax(ax, 0).plot(np.deg2rad(data), np.ones_like(data), **kwargs) else: select_flat_ax(ax, 0).plot(np.arange(len(data)), data, **kwargs) return fig, ax