py21cmfast.plotting =================== .. py:module:: py21cmfast.plotting .. autoapi-nested-parse:: Simple plotting functions for 21cmFAST objects. .. !! processed by numpydoc !! Attributes ---------- .. autoapisummary:: py21cmfast.plotting.eor_colour py21cmfast.plotting.logger Functions --------- .. autoapisummary:: py21cmfast.plotting.coeval_sliceplot py21cmfast.plotting.coeval_summary_plot py21cmfast.plotting.get_global_quantities py21cmfast.plotting.lightcone_sliceplot py21cmfast.plotting.lightcone_summary_plot py21cmfast.plotting.plot_global_evolution py21cmfast.plotting.plot_global_history py21cmfast.plotting.plot_global_signal py21cmfast.plotting.summary_plot Module Contents --------------- .. py:function:: coeval_sliceplot(struct: py21cmfast.wrapper.outputs._OutputStruct | py21cmfast.drivers.coeval.Coeval, kind: str | None = None, cbar_label: str | None = None, **kwargs) Show a slice of a given coeval box. :Parameters: * **struct** (:class:`~outputs._OutputStruct` or :class:`~wrapper.Coeval` instance) -- The output of a function such as `ionize_box` (a class containing several quantities), or `run_coeval`. * **kind** (*str or nd-array*) -- If str: The quantity within the structure to be shown. A full list of available options can be obtained by running ``Coeval.get_fields()``. If nd-array: A 3D box to be shown. This could be useful for plotting the coeval brightness temperature box after redshift space distortions have been applied. * **cbar_label** (*str, optional*) -- A label for the colorbar. Some values of `kind` will have automatically chosen labels, but these can be turned off by setting ``cbar_label=''``. :returns: *fig, ax* -- figure and axis objects from matplotlib :Other Parameters: * **All other parameters are passed directly to :func:`_imshow_slice`. These include `slice_axis`** * **and `slice_index`,** * **which choose the actual slice to plot, optional `fig` and `ax` keywords which enable** * **over-plotting previous figures,** * **and the `imshow_kw` argument, which allows arbitrary styling of the plot.** .. !! processed by numpydoc !! .. py:function:: coeval_summary_plot(coeval: py21cmfast.drivers.coeval.Coeval, kinds: collections.abc.Sequence[str] | None = None, slice_index: int | None = None, log: bool | None = None, **kwargs) -> tuple[matplotlib.pyplot.Figure, list[matplotlib.pyplot.Axes]] Make a simple summary plot of a coeval cube. This plots a slice through the box for each of a default set of fields, as a quick visual check that the simulation ran as expected. :Parameters: * **coeval** -- The :class:`~py21cmfast.drivers.coeval.Coeval` object to plot. * **kinds** -- The fields to plot. By default, whichever of ``brightness_temp``, ``neutral_fraction``, ``density`` and ``spin_temperature`` are available. * **slice_index** -- The index of the slice to plot. By default, the middle of the box. * **log** -- Whether to use a logarithmic color scale. By default, chosen per-field: fields spanning several orders of magnitude (e.g. the temperatures) are plotted logarithmically, provided they are everywhere positive. These fields also have their color scale clipped to their 1st-99th percentile range, unless you pass explicit ``vmin``/``vmax``. * **kwargs** -- Passed through to :func:`coeval_sliceplot`. :returns: *fig, axes* -- The matplotlib Figure and list of Axes objects. .. !! processed by numpydoc !! .. py:function:: get_global_quantities(obj) -> tuple[numpy.ndarray, dict[str, numpy.ndarray]] Get the redshifts and global quantities of a lightcone or global evolution. :Parameters: **obj** -- Either a :class:`~py21cmfast.drivers.lightcone.LightCone` or a :class:`~py21cmfast.drivers.global_evolution.GlobalEvolution`. :returns: * *redshifts* -- The node redshifts of the simulation. * *quantities* -- A dictionary of global (i.e. mean) quantities at each node redshift. .. !! processed by numpydoc !! .. py:function:: lightcone_sliceplot(lightcone: py21cmfast.drivers.lightcone.LightCone, kind: str = 'brightness_temp', lightcone2: py21cmfast.drivers.lightcone.LightCone = None, vertical: bool = False, xlabel: str | None = None, ylabel: str | None = None, cbar_label: str | None = None, zticks: str = 'redshift', fig: matplotlib.pyplot.Figure | None = None, ax: matplotlib.pyplot.Axes | None = None, z_range=None, **kwargs) Create a 2D plot of a slice through a lightcone. :Parameters: * **lightcone** (:class:`~py21cmfast.wrapper.Lightcone`) -- The lightcone object to plot * **kind** (*str, optional*) -- The attribute of the lightcone to plot. Must be an array. * **lightcone2** (*str, optional*) -- If provided, plot the _difference_ of the selected attribute between the two lightcones. * **vertical** (*bool, optional*) -- Whether to plot the redshift in the vertical direction. * **cbar_label** (*str, optional*) -- A label for the colorbar. Some quantities have automatically chosen labels, but these can be removed by setting `cbar_label=''`. * **zticks** (*str, optional*) -- Defines the co-ordinates of the ticks along the redshift axis. Can be "redshift" (default), "frequency", "distance" (which starts at zero for the lowest redshift) or the name of any function in an astropy cosmology that is purely a function of redshift. * **kwargs** -- Passed through to ``imshow()``. :returns: * *fig* -- The matplotlib Figure object * *ax* -- The matplotlib Axis object onto which the plot was drawn. .. !! processed by numpydoc !! .. py:function:: lightcone_summary_plot(lightcone: py21cmfast.drivers.lightcone.LightCone, kind: str = 'brightness_temp', panels: collections.abc.Sequence[str] | None = None, width: float = 9.0, panel_height: float = 1.8, **kwargs) -> tuple[matplotlib.pyplot.Figure, list[matplotlib.pyplot.Axes]] Make a simple summary plot of a lightcone. The top panel is a slice through the lightcone, and the panels below show the global evolution of a default set of quantities. All panels share the same line-of-sight axis, so that features can be matched up by eye. :Parameters: * **lightcone** -- The :class:`~py21cmfast.drivers.lightcone.LightCone` to plot. * **kind** -- The lightcone field to show in the top panel. * **panels** -- Which global-evolution panels to show below the lightcone. See :func:`plot_global_evolution`. * **width** -- The width of the figure, in inches. * **panel_height** -- The height of each global-evolution panel, in inches. * **kwargs** -- Passed through to :func:`lightcone_sliceplot`. :returns: *fig, axes* -- The matplotlib Figure and list of Axes objects. The first is the lightcone slice, the rest are the global-evolution panels. .. !! processed by numpydoc !! .. py:function:: plot_global_evolution(obj, panels: collections.abc.Sequence[str] | None = None, fig: matplotlib.pyplot.Figure | None = None, axes: collections.abc.Sequence[matplotlib.pyplot.Axes] | None = None, frequency_axis: bool = True, **kwargs) -> tuple[matplotlib.pyplot.Figure, list[matplotlib.pyplot.Axes]] Plot a default set of global (mean) quantities as a function of redshift. This is a simple summary plot, giving a quick overview of a simulation: the global 21-cm signal, the ionization history and the temperature history (whichever of these are available in the given object). :Parameters: * **obj** -- A :class:`~py21cmfast.drivers.lightcone.LightCone` or :class:`~py21cmfast.drivers.global_evolution.GlobalEvolution` object. * **panels** -- Which panels to plot. By default, all of "signal", "ionization" and "temperature" that have data available. * **fig, axes** -- Optional pre-existing figure/axes on which to plot. If given, there must be at least as many axes as panels. * **frequency_axis** -- Whether to add a secondary axis at the top of the figure showing the observed frequency of the 21-cm line. * **kwargs** -- Passed through to ``ax.plot()``. :returns: * *fig* -- The matplotlib Figure object. * *axes* -- The list of matplotlib Axes objects that were drawn onto. .. !! processed by numpydoc !! .. py:function:: plot_global_history(lightcone: py21cmfast.drivers.lightcone.LightCone, kind: str | None = None, ylabel: str | None = None, ylog: bool = False, ax: matplotlib.pyplot.Axes | None = None, zmax: float | None = None, **kwargs) Plot the global history of a given quantity from a lightcone. :Parameters: * **lightcone** (:class:`~LightCone` or :class:`~GlobalEvolution` instance) -- The object containing the quantity to plot. * **kind** (*str, optional*) -- The quantity to plot. Must be one of the global quantities of the given object. By default, will choose the first one. * **ylabel** (*str, optional*) -- A y-label for the plot. If None, will use ``kind``. * **ylog** (*bool, optional*) -- Whether to use a logarithmic y-axis. * **ax** (*Axes, optional*) -- The matplotlib Axes object on which to plot. Otherwise, created. * **zmax** (*float, optional*) -- If given, only plot redshifts below this value. .. !! processed by numpydoc !! .. py:function:: plot_global_signal(obj, ax: matplotlib.pyplot.Axes | None = None, frequency_axis: bool = True, **kwargs) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot the global 21-cm signal as a function of redshift. :Parameters: * **obj** -- A :class:`~py21cmfast.drivers.lightcone.LightCone` or :class:`~py21cmfast.drivers.global_evolution.GlobalEvolution` object. * **ax** -- The matplotlib Axes on which to plot. Created by default. * **frequency_axis** -- Whether to add a secondary axis at the top showing the observed frequency of the 21-cm line. * **kwargs** -- Passed through to ``ax.plot()``. :returns: *fig, ax* -- The matplotlib Figure and Axes objects. .. !! processed by numpydoc !! .. py:function:: summary_plot(obj, **kwargs) -> tuple[matplotlib.pyplot.Figure, list[matplotlib.pyplot.Axes]] Make a simple default summary plot of a 21cmFAST simulation output. The plot produced depends on the type of ``obj``: see :func:`coeval_summary_plot`, :func:`lightcone_summary_plot` and :func:`plot_global_evolution`. :Parameters: * **obj** -- A ``Coeval``, ``LightCone`` or ``GlobalEvolution`` object. * **kwargs** -- Passed through to the relevant plotting function. :returns: *fig, axes* -- The matplotlib Figure and list of Axes objects. .. !! processed by numpydoc !! .. py:data:: eor_colour .. py:data:: logger