Diagnostic plotting functions¶
The hera_stats.plot
module contains a variety of diagnostic plotting functions. These include a function to generate long waterfalls plots of nsamples
or flags
across many files (long_waterfall
), including summary statistics on the flag fraction for each time/frequency bin.
-
hera_stats.plot.
antenna_matrix
(mat, ants, label=None, cmap='viridis')[source]¶ Plot 2D square array, intended to be a matrix of antenna vs antenna values of some quantity.
Parameters: - mat (array_like) – 2D square array containing matrix values to be plotted.
- ants (array_like) – 1D array of unique antennas represented in the matrix, in the same ordering as the input matrix.
- label (str, optional) – Label for the plot (displayed as the colorbar label). Default: None.
- cmap (str, optional) – Matplotlib colormap name. Default: ‘viridis’.
Returns: fig – Matplotlib figure containing matshow.
Return type: matplotlib.Figure
-
hera_stats.plot.
long_waterfall
(uvd_list, bl, pol, title=None, cmap='gray', starting_lst=[], mode='nsamples', operator='abs', file_type='uvh5', figsize=(20, 80))[source]¶ Generates a waterfall plot of flags or nsamples with axis sums from an input array.
Parameters: - uvd_list (list of UVData objects or list of str) – List of UVData objects to be stacked and displayed. If a list of strings is specified, each UVData object will be loaded one at a time (reduces peak memory consumption).
- bl (int or tuple) – Baseline integer or antenna pair tuple of the baseline to plot.
- pol (str or int) – Polarization string or integer.
- title (str, optional) – Title of the plot. Default: none.
- cmap (str, optional) – Colormap parameter for the waterfall plot. Default: ‘gray’.
- starting_lst (list, optional) – list of starting lst to display in the plot
- mode (str, optional) – Which array to plot from the UVData objects. Options: ‘data’, ‘flags’, ‘nsamples’. Default: ‘nsamples’.
- operator (str, optional) – If mode=’data’, the operator to apply when plotting the data. Can be ‘real’, ‘imag’, ‘abs’, ‘phase’. Default: ‘abs’.
- file_type (str, optional) – If uvd_list is passed as a list of strings, specifies the file type of the data files to assume when loading them. Default: ‘uvh5’.
- figsize (tuple, optional) – The size of the figure, in inches. Default: (20, 80).
Returns: - main_waterfall (matplotlib.axes) – Matplotlib Axes instance of the main plot
- freq_histogram (matplotlib.axes) – Matplotlib Axes instance of the sum across times
- time_histogram (matplotlib.axes) – Matplotlib Axes instance of the sum across freqs
- data (numpy.ndarray) – A copy of the stacked_array output that is being displayed
-
hera_stats.plot.
redgrp_corrmat
(corr, red_grp, cmap='RdBu', figsize=(30.0, 20.0), line_alpha=0.2)[source]¶ Plot the correlation matrix for a set of delay spectra in a redundant group. See hera_stats.stats.redgrp_pspec_covariance() for a function to calculate the correlation matrix.
The elements of the correlation matrix are assumed to be in the same order as the red_grp list. Furthermore, the red_grp list is assumed to be ordered by blpair integer. Blocks of elements that have the same first bl in common are marked in the matrix.
Parameters: - corr (ndarray) – Covariance or correlation matrix.
- red_grp (list) – List of baseline-pairs in the redundant group (one for each row/column of the corr matrix).
- cmap (str, optional) – Matplotlib colormap to use for the correlation matrix plot. Default: ‘RdBu’.
- vmin, vmax (float, optional) – Minimum and maximum values of the
- figsize (tuple, optional) – Size of the figure, in inches. Default: (30, 20).
- line_alpha (float, optional) – Alpha value of the lines used to draw blocks in the correlation matrix. Default: 0.2.
Returns: fig – Figure containing the correlation matrix.
Return type: matplotlib.Figure
-
hera_stats.plot.
scatter_bandpowers
(uvp, x_dly, y_dly, keys, operator='abs', label=None, ax=None)[source]¶ Scatter plot of delay spectrum bandpowers from two different delay bins. The bandpowers can be taken from multiple spws / blpairs / polpairs at the same time (see the keys argument).
Example of keys argument: .. highlight:: python .. code-block:: python
red_grps, red_lens, red_angs = uvp.get_red_blpairs() keys = { ‘spws’: 0, ‘blpairs’: red_grps[0], ‘polpairs’: uvp.get_polpairs(), }Parameters: - uvp (UVPSpec) – Input delay spectrum object.
- x_dly, y_dly (int) – Index of delay bins to use as the x and y values respectively.
- keys (dict) – Dictionary with keys ‘spws’, ‘blpairs’, ‘polpairs’, which can be lists or single values. This allows bandpowers from multiple spws / blpairs / polpairs to be plotted simultaneously.
- operator (str, optional) – If mode=’data’, the operator to apply when plotting the data. Can be ‘real’, ‘imag’, ‘abs’, ‘phase’. Default: ‘abs’. Default: ‘abs’.
- label (str, optional) – Label to use for this set of data in the plot legend. Default: None.
- ax (matplotlib.axes, optional) – Default: None.
Returns: ax – Matplotlib Axes instance.
Return type: matplotlib.axes