Appendix

Gains

ragavi.ragavi.add_axis(fig, axis_range, ax_label, ax_name)

Add an extra axis to the current figure

Parameters:
  • fig (bokeh.plotting.figure) – The figure onto which to add extra axis
  • axis_range (float, float) – Starting and ending point for the range
  • ax_label (str) – Label of the new axis
  • ax_name (str) – Name of the new model for the extra axis incase of multiple spectral windows.
Returns:

fig (bokeh.plotting.figure) – Figure containing the extra axis

ragavi.ragavi.alpha_slider_callback()

JS callback to alter alpha of glyphs

Returns:code (str)
ragavi.ragavi.ant_select_callback()

JS callback for the selection and de-selection of antennas

Returns:code (str)
ragavi.ragavi.autofill_gains(t, g)

Normalise length of f and g lists to the length of t. This function is meant to support the ability to specify multiple gain tables while only specifying single values for gain table types.

Note

An assumption will be made that for all the specified tables, the same gain table type will be used.

Parameters:
  • g (list) – type of gain table [B,G,K,F].
  • t (list) – list of the gain tables.
Returns:

f (list) – lists of length ..code::len(t) containing gain types.

ragavi.ragavi.axis_fs_callback()

JS callback to alter axis label font sizes

Returns:code (str)
ragavi.ragavi.batch_select_callback()

JS callback for batch selection Checkboxes

Returns:code (str)
ragavi.ragavi.condense_legend_items(inlist)

Combine renderers of legend items with the same legend labels. Must be done in case there are groups of renderers which have the same label due to iterations, to avoid a case where there are two or more groups of renderers containing the same label name.

Parameters:inlist (list) – # bokeh.models.annotations.LegendItem>`_ List containing legend items of the form (label, renders) as described in: `Bokeh legend items <https://bokeh.pydata.org/en/latest/docs/reference/models/annotations.html
Returns:outlist (list) – A reduction of inlist
ragavi.ragavi.create_legend_batches(num_leg_objs, li_ax1, batch_size=16)

Automates creation of antenna batches of 16 each unless otherwise.

This function takes in a long list containing all the generated legend items from the main function’s iteration and divides this list into batches, each of size batch_size. The outputs provides the inputs to ragavi.ragavi.create_legend_objs().

Parameters:
  • batch_size (int, optional) – Number of antennas in a legend object. Default is 16
  • li_ax1 (list) – # bokeh.models.annotations.LegendItem>`_ for antennas for 1st figure # items are in the form (antenna_legend, [renderer]) List containing all `legend items <https://bokeh.pydata.org/en/latest/docs/reference/models/annotations.html
  • num_leg_objs (int) – Number of legend objects to be created
Returns:

bax1 (list) – Tuple containing List of lists which each have batch_size number of legend items for each batch. bax1 are batches for figure1 antenna legends, and ax2 batches for figure2 antenna legends

e.g bax1 = [[batch0], [batch1], …, [batch_numOfBatches]]

ragavi.ragavi.create_legend_objs(num_leg_objs, bax1)

Creates legend objects using items from batches list Legend objects allow legends be positioning outside the main plot

Parameters:
  • num_leg_objs (int) – Number of legend objects to be created
  • bax1 (list) – Batches for antenna legends of 1st figure
Returns:

lo_ax1 (dict) – Dictionaries with legend objects for figure1 antenna legend objects

ragavi.ragavi.determine_table(table_name)

Find pattern at end of string to determine table to be plotted. The search is not case sensitive

Parameters:table_name (str) – Name of table / gain type to be plotted
Returns:result (str) – Table type of (if valid) of the input table_name
ragavi.ragavi.errorbar(fig, x, y, yerr=None, color='red')

Add errorbars to Figure object based on x, y and attr:yerr

Parameters:
  • color (str) – Color for the error bars
  • fig (bokeh.plotting.figure) – Figure onto which the error-bars will be added
  • x (numpy.ndarray) – x_axis data
  • y (numpy.ndarray) – y_axis data
  • yerr (numpy.ndarray, numpy.ndarray) – Tuple with high and low limits for y
Returns:

ebars (bokeh.models.Whisker) – Return the object containing error bars

ragavi.ragavi.field_selector_callback()

Return JS callback for field selection checkboxes

Returns:code (str)
ragavi.ragavi.flag_callback()

JS callback for the flagging button

Returns:code (str)
ragavi.ragavi.gen_checkbox_labels(batch_size, num_leg_objs, antnames)

Auto-generating Check box labels

Parameters:
  • batch_size (int) – Number of items in a single batch
  • num_leg_objs (int) – Number of legend objects / Number of batches
Returns:

labels (list) – Batch labels for the batch selection check box group

ragavi.ragavi.gen_flag_data_markers(y, fid=None, markers=None, fmarker='circle_x')

Generate different markers for where data has been flagged.

Parameters:
  • fid (int) – field id number to identify the marker to be used
  • fmarker (str) – Marker to be used for flagged data
  • markers (list) – A list of all available bokeh markers
  • y (numpy.ndarray) – The flagged data containing NaNs
Returns:

masked_markers_arr (numpy.ndarray) – Returns an n-d array of shape y.shape containing markers for valid data and fmarker where the data was NaN.

ragavi.ragavi.get_table(tab_name, antenna=None, fid=None, spwid=None, where=None)

Get xarray Dataset objects containing gain table columns of the selected data

Parameters:
  • antenna (str, optional) – A string containing antennas whose data will be selected
  • fid (int, optional) – FIELD_ID whose data will be selected
  • spwid (int, optional) – DATA_DESC_ID or spectral window whose data will be selected
  • tab_name (str) – name of your table or path including its name
  • where (str, optional) – TAQL where clause to be used with the MS.
Returns:

tab_objs (list) – A list containing xarray.Dataset objects where each item on the list is determined by how the data is grouped

ragavi.ragavi.get_time_range(tab_name, unix_time=True)

Get the first TIME column before selections

ragavi.ragavi.get_tooltip_data(xds_table_obj, gtype, antnames, freqs)

Get the data to be displayed on the tool-tip of the plots

Parameters:
  • antnames (list) – List containing antenna names
  • gtype (str) – Type of gain table being plotted
  • xds_table_obj (xarray.Dataset) – xarray-ms table object
Returns:

  • spw_id (numpy.ndarray) – Spectral window ids
  • scan_no (numpy.ndarray) – scan ids
  • ttip_antnames (numpy.ndarray) – Antenna names to show up on the tool-tips

ragavi.ragavi.legend_toggle_callback()

JS callback for legend toggle Dropdown menu

Returns:code (str)
ragavi.ragavi.main(**kwargs)

Main function that launches the gains plotter

ragavi.ragavi.make_plots(source, ax1, ax2, fid=0, color='red', y1err=None, y2err=None)

Generate a pair of plots

Parameters:
  • ax1 (bokeh.plotting.figure) – First figure
  • ax2 (bokeh.plotting.figure) – Second Figure
  • color (str) – Glyph color[s]
  • fid (int) – field id number to set the line width
  • source (bokeh.models.ColumnDataSource) – Data source for the plot
  • y1err (numpy.ndarray, optional) – y1 Error margins for figure ax1 data
  • y2err (numpy.ndarray, optional) – y2 error margins for figure ax2 data
Returns:

(p1, p1_err, p2, p2_err ) ((bokeh.models.renderers.GlyphRenderer, bokeh.models.Whisker, bokeh.models.renderers.GlyphRenderer, bokeh.models.Whisker)) – Tuple of containing bokeh.models.renderers.GlyphRenderer with the data glyphs as well as errorbars. p1 and p2: renderers containing data for ax1 and ax2 respectively. p1_err, p2_err outputs from ragavi.ragavi.errorbar() for ax1 and ax2 respectively.

ragavi.ragavi.plot_table(mytabs, gain_types, **kwargs)

Plot gain tables within Jupyter notebooks.

Parameters:
  • _corr (int, optional) – Correlation index to plot. Can be a single integer or comma separated integers e.g ‘0,2’. Defaults to all.
  • doplot (str, optional) – Plot complex values as amp and phase (ap) or real and imag (ri). Default is ‘ap’.
  • ddid (int) – SPECTRAL_WINDOW_ID or ddid number. Defaults to all
  • fields (str, optional) – Field ID(s) / NAME(s) to plot. Can be specified as “0”, “0,2,4”, “0~3” (inclusive range), “0:3” (exclusive range), “3:” (from 3 to last) or using a field name or comma separated field names. Defaults to all.
  • gain_types (str, list) – Cal-table (list of caltypes) type to be plotted. Can be either ‘B’-bandpass, ‘D’- D jones leakages, G’-gains, ‘K’-delay or ‘F’-flux. Default is none
  • image_name (str, optional) – Output image name. Default is of the form: table_corr_doplot_fields
  • mycmap (str, optional) – Matplotlib colour map to use for antennas. Default is coolwarm
  • mytabs (str or list required) – The table (list of tables) to be plotted.
  • plotants (str, optional) – Plot only this antenna, or comma-separated string of antennas. Default is all
  • taql (str, optional) – TAQL where clause
  • t0 (int, optional) – Minimum time [in seconds] to plot. Default is full range
  • t1 (int, optional) – Maximum time [in seconds] to plot. Default is full range
ragavi.ragavi.save_html(hname, plot_layout)

Save plots in HTML format

Parameters:
  • hname (str) – HTML Output file name
  • plot_layout (bokeh.layouts) – Layout of the Bokeh plot, could be row, column, gridplot.
ragavi.ragavi.save_png_image(img_name, disp_layout)

Save plots in PNG format

Note

One image will emerge for each figure in disp_layout. To save png images, the python package selenium, node package phantomjs are required. More information Exporting bokeh plots

Parameters:
  • disp_layout (bokeh.layouts) – Layout object containing the renderers
  • img_name (str) – Name of output image
ragavi.ragavi.save_svg_image(img_name, figa, figb, glax1, glax2)

Save plots in SVG format

Note

Two images will emerge. the python package selenium, node package phantomjs are required. More information Exporting bokeh plots

Parameters:
  • img_name (str) – Desired image name
  • figa (bokeh.plotting.figure) – First figure
  • figb (bokeh.plotting.figure) – Second figure
  • glax1 (list) – Contains glyph metadata saved during execution
  • glax2 (list) – Contains glyph metadata saved during execution
ragavi.ragavi.size_slider_callback()

JS callback to select size of glyphs

Returns:code (str)
ragavi.ragavi.stats_display(tab_name, gtype, ptype, corr, field, f_names=None, flag=True, spwid=None)

Display some statistics on the plots. These statistics are derived from a specific correlation and a specified field of the data.

Note

Currently, only the medians of these plots are displayed.

Parameters:
  • corr (int) – Correlation number of the data to be displayed
  • field (int) – Integer field id of the field being plotted. If a string name was provided, it will be converted within the main function by ragavi.vis_utils.name_2id().
  • gtype (str) – Type of gain table to be plotted.
  • ptype (str) – Type of plot ap / ri
Returns:

pre (bokeh.models.widgets) – Pre-formatted text containing the medians for both model. The object returned must then be placed within the widget box for display.

ragavi.ragavi.title_fs_callback()

JS callback for title font size slider

Returns:code (str)
ragavi.ragavi.toggle_err_callback()

JS callback for Error toggle Toggle button

Returns:code (str)

Visibilites

ragavi.visibilities.add_axis(fig, axis_range, ax_label)

Add an extra axis to the current figure

Parameters:
  • fig (bokeh.plotting.figure) – The figure onto which to add extra axis
  • axis_range (list, tuple) – A range of sorted values or a tuple with 2 values containing or the order (min, max). This can be any ordered iteraable that can be indexed.
Returns:

fig (bokeh.plotting.figure) – Bokeh gigure with an extra axis added

ragavi.visibilities.average_ms(ms_name, tbin=None, cbin=None, chunk_size=None, taql='', columns=None, chan=None)

Perform MS averaging :param ms_name: Name of the input MS :type ms_name: str :param tbin: Time bin in seconds :type tbin: float :param cbin: Number of channels to bin together :type cbin: int :param chunk_size: Size of resulting MS chunks. :type chunk_size: dict :param taql: TAQL clause to pass to xarrayms :type taql: str

Returns:x_dataset (list) – List of xarray.Dataset containing averaged MS. The MSs are split by Spectral windows
ragavi.visibilities.create_bl_data_array(ant1, ant2)

Make a dataArray containing baseline numbers

Parameters:
  • ant1 (xarray.DataArray) – ANTENNA1 dataArray
  • ant2 (xarray.DataArray) – ANTENNA2 dataArray
Returns:

baseline (xarray.DataArray) – DataArray containing baseline numbers

ragavi.visibilities.get_ms(ms_name, chunks=None, data_col='DATA', ddid=None, fid=None, scan=None, where=None, cbin=None, tbin=None, chan_select=None)

Get xarray Dataset objects containing Measurement Set columns of the selected data

Parameters:
  • ms_name (str) – Name of your MS or path including its name
  • chunks (str) – Chunk sizes for the resulting dataset.
  • cbin (int) – Number of channels binned together for channel averaging
  • data_col (str) – Data column to be used. Defaults to ‘DATA’
  • ddid (int) – DATA_DESC_ID or spectral window to choose. Defaults to all
  • fid (int) – Field id to select. Defaults to all
  • scan (int) – SCAN_NUMBER to select. Defaults to all
  • tbin (float) – Time in seconds to bin for time averaging
  • where (str) – TAQL where clause to be used with the MS.
  • chan_select (int or slice) – Channels to be selected
Returns:

tab_objs (list) – A list containing the specified table objects as xarray.Dataset

ragavi.visibilities.main(**kwargs)

Main function that launches the visibilities plotter

ragavi.visibilities.make_cbar(cats, category, cmap=None)

Initiate a colorbar for categorical data :param cats: Available category ids e.g scan_number, field id etc :type cats: np.ndarray :param category: Name of the categorizing axis :type category: str :param cmap: Matplotlib colormap :type cmap: matplotlib.cmap

Returns:cbar (bokeh.models) – Colorbar instance