Simple plotting functions

The hera_pspec.plot module contains functions for making simple plots of delay power spectra.

The following example plots the power spectra from a UVPSpec object, averaged over baseline-pairs and times.

# Load or generate a UVPSpec object containing delay power spectra
uvp = ...

# Set which baseline-pairs should be included in the plot
blpairs = list(uvp.blpair_array) # This includes all blpairs!

# Plot the delay spectrum, averaged over all blpairs and times
# (for the spectral window with index=0, and polarization 'xx')
ax = hp.plot.delay_spectrum(uvp, [blpairs,], spw=0, pol='xx',
                            average_blpairs=True, average_times=True,
                            delay=False)

# Setting delay=False plots the power spectrum in cosmological units

For a more extensive worked example, see this example Jupyter notebook.

The only plotting function currently available in the hera_pspec.plot module is delay_spectrum().

hera_pspec.plot.delay_spectrum(uvp, blpairs, spw, pol, average_blpairs=False, average_times=False, fold=False, plot_noise=False, delay=True, deltasq=False, legend=False, ax=None, component='real', lines=True, markers=False, error=None, times=None, logscale=True, force_plot=False, label_type='blpairt', plot_stats=None, **kwargs)[source]

Plot a 1D delay spectrum (or spectra) for a group of baselines.

Parameters
  • uvp (UVPspec) – UVPSpec object, containing delay spectra for a set of baseline-pairs, times, polarizations, and spectral windows.

  • blpairs (list of tuples or lists of tuples) – List of baseline-pair tuples, or groups of baseline-pair tuples.

  • spw, pol (int or str) – Which spectral window and polarization to plot.

  • average_blpairs (bool, optional) – If True, average over the baseline pairs within each group.

  • average_times (bool, optional) – If True, average spectra over the time axis. Default: False.

  • fold (bool, optional) – Whether to fold the power spectrum in \(|k_\parallel|\). Default: False.

  • plot_noise (bool, optional) – Whether to plot noise power spectrum curves or not. Default: False.

  • delay (bool, optional) – Whether to plot the power spectrum in delay units (ns) or cosmological units (h/Mpc). Default: True.

  • deltasq (bool, optional) – If True, plot dimensionless power spectra, Delta^2. This is ignored if delay=True. Default: False.

  • legend (bool, optional) – Whether to switch on the plot legend. Default: False.

  • ax (matplotlib.axes, optional) – Use this to pass in an existing Axes object, which the power spectra will be added to. (Warning: Labels and legends will not be altered in this case, even if the existing plot has completely different axis labels etc.) If None, a new Axes object will be created. Default: None.

  • component (str, optional) – Component of complex spectra to plot, options=[‘abs’, ‘real’, ‘imag’]. Default: ‘real’.

  • lines (bool, optional) – If True, plot lines between bandpowers for a given pspectrum. Default: True.

  • markers (bool, optional) – If True, plot circles at bandpowers. Filled for positive, empty for negative. Default: False.

  • error (str, optional) – If not None and if error exists in uvp stats_array, plot errors on bandpowers. Default: None.

  • times (array_like, optional) – Float ndarray containing elements from time_avg_array to plot.

  • logscale (bool, optional) – If True, put plot on a log-scale. Else linear scale. Default: True.

  • force_plot (bool, optional) – If plotting a large number of spectra (>100), this function will error. Set this to True to override this large plot error and force plot. Default: False.

  • label_type (int, optional) –

    Line label type in legend, options=[‘key’, ‘blpair’, ‘blpairt’].

    key : Label lines based on (spw, blpair, pol) key. blpair : Label lines based on blpair. blpairt : Label lines based on blpair-time.

  • plot_stats (string, optional) – If not None, plot an entry in uvp.stats_array instead of power spectrum in uvp.data_array.

  • kwargs (dict, optional) – Extra kwargs to pass to _all_ ax.plot calls.

Returns

fig – Matplotlib Figure instance.

Return type

matplotlib.pyplot.Figure