Visread + casatools API#

Visread tools with a casatools dependency (visread[casa]). See Visread Installation for more details.

Before getting started with the visread package, we recommend becoming familiar with the casatools provided as part of CASA. You can see some of our highlights in the tutorials and in Casatools API.

These tools are mainly designed to streamline reading visibilities from a CASA measurement set and then passing these to the underlying visread routines in Visread API.

Process#

visread.process_casa.get_channel_sorted_data(filename, datadescid, incl_model_data=True, datacolumn='corrected_data')[source]#

Acquire and sort the channel frequencies, data, flags, and model_data columns.

Parameters:
  • filename (string) – the measurement set to query

  • datadescid (int) – the spw id to query

  • incl_model_data (boolean) – if True, return the model_data column as well

  • datacolumn (string) – “corrected_data” by default

Returns:

chan_freq, data, flag, model_data

Return type:

tuple

visread.process_casa.get_processed_visibilities(filename, datadescid, sigma_rescale=1.0, incl_model_data=None, datacolumn='corrected_data')[source]#

Process all of the visibilities from a specific datadescid. This means

  • (If necessary) reversing the channel dimension such that channel frequency decreases with increasing array index (blueshifted to redshifted)

  • averaging the polarizations together

  • rescaling weights

  • scanning and removing any auto-correlation visibilities

Parameters:
  • filename (str) – path to measurementset to process

  • datadescid (int) – a specific datadescid to process

  • sigma_rescale (float) – by what factor should the sigmas be rescaled (applied to weights via rescale_weights)

  • incl_model_data (bool) – include the model_data column?

Returns:

dictionary with keys “frequencies”, “uu”, “data”, “flag”, “weight”

Scatter#

visread.scatter_casa.get_scatter_datadescid(filename, datadescid, sigma_rescale=1.0, apply_flags=True, residual=True, datacolumn='corrected_data')[source]#

Calculate the residuals for each polarization (XX, YY) in units of \(\sigma\), where

\[\sigma = \mathrm{sigma\_rescale} \times \sigma_0\]

and \(\sigma_0 = \sqrt{1/w}\). The scatter is defined as

\[\mathrm{scatter} = \frac{\mathrm{DATA} - \mathrm{MODEL\_DATA}}{\sigma}\]
Parameters:
  • filename (string) – measurement set filename

  • datadescid (int) – the DATA_DESC_ID to be queried

  • sigma_rescale (int) – multiply the uncertainties by this factor

  • apply_flags (bool) – calculate the scatter after the flags have been applied

  • residual (bool) – if True, subtract MODEL_DATA column (from a tclean model, most likely) to plot scatter of residual visibilities.

  • datacolumn (string) – which datacolumn to use (i.e., ‘corrected_data’ or ‘data’).

  • available (If 'corrected_data' is not) –

  • 'data'. (will fall back to) –

Returns:

a 2-tuple of numpy arrays containing the scatter in each polarization. If apply_flags==True, each array will be 1-dimensional. If apply_flags==False, each array will retain its original shape, including channelization (e.g., shape nchan,nvis).

Return type:

scatter_XX, scatter_YY

visread.scatter_casa.get_sigma_rescale_datadescid(filename, datadescid, datacolumn='corrected_data')[source]#

For a given datadescid, calculate the residual scatter in each of the XX and YY polarization visibilities, then calculate the sigma rescale factor for each of the real and imaginary values of the polarizations. Return the average of all four quantities as the final sigma rescale factor for that datadescid.

Parameters:
  • filename (string) – path to measurement set

  • datadescid (int) – the spectral window in the measurement set

Returns:

the multiplicative factor by which to scale \(\sigma\)

Return type:

float

Visualization#

visread.visualization_casa.plot_scatter_datadescid(filename, datadescid, log=False, sigma_rescale=1.0, chan_slice=None, apply_flags=True, residual=True, datacolumn='corrected_data')[source]#

Plot a set of histograms of the scatter of the residual visibilities for the real and imaginary components of the XX and YY polarizations.

Parameters:
  • filename (string) – measurement set filename

  • datadescid (int) – the DATA_DESC_ID to be queried

  • log (bool) – should the histogram values be log scaled?

  • sigma_rescale (int) – multiply the uncertainties by this factor

  • chan_slice (slice) – if not None, a slice object specifying the channels to subselect

  • apply_flags (bool) – calculate the scatter after the flags have been applied

  • residual (bool) – if True, subtract MODEL_DATA column (from a tclean model, most likely) to plot scatter of residual visibilities.

  • datacolumn (string) – which datacolumn to use (i.e., ‘corrected_data’ or ‘data’).

Returns:

matplotlib figure with scatter histograms