Appendix

Gains

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.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 containing renderers sharing the same labels grouped together.
ragavi.ragavi.corr_select_callback()

Correlation selection callback

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 for plot
Returns:

lo_ax1 (dict) – Dictionaries with legend objects for a plot

ragavi.ragavi.create_stats_table(stats, yaxes)

Create data table with median statistics :param stats: List of lists containing data stats for each iterations from

Parameters:yaxes (list) – Contains y-axes for the current plot
Returns:Bokeh column layout containing data table with stats
ragavi.ragavi.errorbar(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
  • 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=[], group_cols=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 (list, optional) – TAQL where clause to be used within the table.
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 initial and final TIME column before selections

Returns:init_time, f_time (tuple) – Containing initial time and final time available in the ms
ragavi.ragavi.get_tooltip_data(xds_table_obj, xaxis, freqs)

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

Parameters:
  • xaxis (str) – Current xaxis
  • xds_table_obj (xarray.Dataset) – xarray-ms table object
  • freqs (np.array) – An array containing frequencies for the current SPW
Returns:

  • spw_id (numpy.ndarray) – Spectral window ids
  • scan_no (numpy.ndarray) – scan ids

ragavi.ragavi.legend_toggle_callback()

JS callback for legend toggle Dropdown menu

Returns:code (str)

Link all plots generated by this script. Done to unify interactivity within the plots such as panning, zoomin etc.

Parameters:
  • all_figures (list) – Containing all the figures generated in the plot
  • all_fsources (list) – All data sources containing flagged data for all figures
  • all_ebars (list) – All error bars for all figures
Returns:

all_fsrc, all_ufsrc (tuple) – Unified flagged and un-flagged data sources

ragavi.ragavi.main(**kwargs)

Main function that launches the gains plotter

ragavi.ragavi.make_plots(source, fid=0, color='red', yerr=None, yidx=None)

Generate a pair of plots

Parameters:
  • fig (bokeh.plotting.figure) – First figure
  • color (str) – Glyph color[s]
  • fid (int) – field id number to set the line width
  • source (bokeh.models.ColumnDataSource) – Data source for the renderer
  • yerr (numpy.ndarray, optional) – Y-axis error margins
  • yidx (int) – Current enumerated y-axis number. Used for keeping track of the figures.
Returns:

  • p_glyph, ebars ((bokeh.models.Glyph, bokeh.models.Whisker))
  • Tuple of containing glyphs and error bars to be used (from ragavi.ragavi.errorbar()).

ragavi.ragavi.make_table_name(tab_name)

Create div for stats data table

ragavi.ragavi.plot_table(**kwargs)

Plot gain tables within Jupyter notebooks. Parameter names correspond to the long names of each argument (i.e those with –) from the ragavi-vis command line help

Parameters:
  • table (str or list) – The table (list of tables) to be plotted.
  • ant (str, optional) – Plot only specific antennas, or comma-separated list of antennas.
  • corr (int, optional) – Correlation index to plot. Can be a single integer or comma separated integers e.g “0,2”. Defaults to all.
  • cmap (str, optional) – Matplotlib colour map to use for antennas. Default is coolwarm
  • ddid (int) – SPECTRAL_WINDOW_ID or ddid number. Defaults to all
  • doplot (str, optional) – Plot complex values as amp and phase (ap) or real and imag (ri). Default is “ap”.
  • field (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.
  • k-xaxis (str) – Choose the x-xaxis for the K table. Valid choices are: time or antenna. Defaults to time.
  • 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(name, 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_static_image(fname, figs=None, batch_size=16, cmap='viridis', dpi=None)

Save plots in png, ps, pdf, svg format

Parameters:
  • name (str) – Desired image name
  • figs (list) – A list containing bokeh.plotting.Plot objects (The figures to be plotted.)
ragavi.ragavi.set_tempdir(name)

Set the current dir as the temp dir also

ragavi.ragavi.size_slider_callback()

JS callback to select size of glyphs

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

SPW selection callaback

ragavi.ragavi.stats_display(tab_name, yaxis, 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
  • f_names (list) – List with all the available field names
  • 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().
  • flag (bool) – Whether to flag data or not
  • spwid (int) – Spectral window to be selected
  • yaxis (str) – Can be amplitude, phase, real, imaginary or delay
Returns:

List containing stats

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.antenna_iter(ms_name, columns, **kwargs)

Return a list containing iteration over antennas in respective SPWs :param ms_name: Name of the MS :type ms_name: str :param columns: Columns that should be present in the dataset :type columns: list

Returns:outp (list) – A list containing data for each individual antenna. This list is ordered by antenna and SPW.
ragavi.visibilities.append_cbar(cats, category, cmap, ax, x_min, y_min, labels=None)

Add a colourbar 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 :param labels: Labels containing names for the iterated stuff :type labels: list :param ax: Figure to append the color bar to :type ax: bokeh.models.figure

ragavi.visibilities.corr_iter(subs)

Return a list containing iteration over corrs in respective SPWs

Parameters:subs (list) – List containing subtables for the daskms grouped data
Returns:
  • outp (list) – A list containing data for each individual corr. This list is ordered by corr and SPW.
  • # NOTE (can also be used for chan iteration. Will require name change)
ragavi.visibilities.create_bl_data_array(xds_table_obj, bl_combos=False)

Make a dataArray containing baseline numbers

Parameters:
  • xds_table_obj (xarray.Dataset) – Daskms dataset object
  • bl_combos (Bool) – Whether to return only the available baseline combinations
Returns:

baseline (xarray.DataArray) – DataArray containing baseline numbers

ragavi.visibilities.create_categorical_df(it_axis, x_data, y_data, xds_table_obj)
it_axis: str
Column over which to iterate / colourise
x_data: xr.DataArray
x-axis data
y_data: xr.DataArray
y-axis data
xds_table_obj: xr.Dataset
Daskms partition for this chunk of data
Returns:
  • xy_df (dask.DataFrame) – Dask dataframe with the required category
  • cat_values (np.array) – Array containing the unique identities of the iteration axis
ragavi.visibilities.create_dask_df(inp, idx)
Parameters:
  • inp (dict) – A dictionary containing column name as the key, and the dictionary value is the dask array to be associated with the column name.
  • ids (da.array) – A dask array to form the index of the resulting dask dataframe
Returns:

ddf (dd.Dataframe) – Dask dataframe containing the presented data

ragavi.visibilities.create_df(x, y, iter_data=None)

Create a dask dataframe from input x, y and iterate columns if available. This function flattens all the data into 1-D Arrays

Parameters:
  • x (dask.array) – Data for the x-axis
  • y (dask.array) – Data for the y-axis
  • iter_ax (dask.array) – iteration axis if possible
Returns:

new_ds (dask.Dataframe) – Dataframe containing the required columns

ragavi.visibilities.gen_image(df, x_min, x_max, y_min, y_max, c_height, c_width, cat=None, c_labels=None, color=None, i_labels=None, ph=1080, pw=1920, x_axis_type='linear', x_name=None, x=None, xlab=None, y_axis_type='linear', y_name=None, ylab=None, title=None, xds_table_obj=None, **kwargs)

Generate single bokeh figure

ragavi.visibilities.get_ms(ms_name, ants=None, cbin=None, chan_select=None, chunks=None, corr_select=None, colour_axis=None, data_col='DATA', ddid=None, fid=None, iter_axis=None, scan=None, tbin=None, where=None, x_axis=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.
  • ants (str) – Values for antennas in ANTENNA1 whose baselines will be selected
  • cbin (int) – Number of channels binned together for channel averaging
  • colour_axis (str) – Axis to be used for colouring
  • iter_axis (str) – Axis to iterate over
  • 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
  • x_axis (:obj:`) – The chosen x-axis
  • where (str) – TAQL where clause to be used with the MS.
  • chan_select (int or slice) – Channels to be selected
  • corr_select (int or slice) – Correlations to be selected
Returns:

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

Link all the plots in the X and Y axes

ragavi.visibilities.massage_data(x, y, get_y=False, iter_ax=None)

Massages x-data into a size similar to that of y-axis data via the necessary repetitions. This function also flattens y-axis data into 1-D.

Parameters:
  • x (xr.DataArray) – Data for the x-axis
  • y (xr.DataArray) – Data for the y-axis
  • get_y (bool) – Choose whether to return y-axis data or not
Returns:

  • x (dask.array) – Data for the x-axis
  • y (dask.array) – Data for the y-axis

ragavi.visibilities.mod_unlinked_grid_plots(plot_list, nrows, ncols)
  • Move tick marks into the plots
  • Reduce frame size of plots
  • Switch on only axis label for first item in row
ragavi.visibilities.validate_axis_inputs(inp)

Check if the input axes tally with those that are available :param inp: User’s axis input :type inp: str :param choices: Available choices for a specific axis :type choices: list :param alts: All the available altenatives for the various axes :type alts: dict

Returns:oup (str) – Validated string