sirius._sirius_utils._cngi_io
¶
-
ms_selection
(infile, outfile=None, verbose=False, spw=None, field=None, times=None, baseline=None, scan=None, scanintent=None, array=None, uvdist=None, observation=None, polarization=None)[source]¶
-
read_generic_table
(infile, subtables=False, timecols=None, ignore=None)[source]¶ read generic casacore table format to xarray dataset loaded in memory
- Parameters
infile (str) – Input table filename. To read a subtable simply append the subtable folder name under the main table (ie infile = ‘/path/mytable.tbl/mysubtable’)
subtables (bool) – Whether or not to include subtables underneath the specified table. If true, an attribute called subtables will be added to the returned xds. Default False
timecols (list) – list of column names to convert to numpy datetime format. Default None leaves times as their original casacore format.
ignore (list) – list of column names to ignore and not try to read. Default None reads all columns
- Returns
- Return type
xarray.core.dataset.Dataset
-
read_ms
(infile, rowmap=None, subtables=False, expand=False, chunks=(22000, 512, 2))[source]¶ Read legacy format MS to xarray Visibility Dataset
The MS is partitioned by DDI, which guarantees a fixed data shape per partition. This results in separate xarray dataset (xds) partitions contained within a main xds (mxds).
- Parameters
infile (str) – Input MS filename
rowmap (dict) – Dictionary of DDI to tuple of (row indices, channel indices). Returned by ms_selection function. Default None ignores selections
subtables (bool) – Also read and include subtables along with main table selection. Default False will omit subtables (faster)
expand (bool) – Whether or not to return the original flat row structure of the MS (False) or expand the rows to time x baseline dimensions (True). Expanding the rows allows for easier indexing and parallelization across time and baseline dimensions, at the cost of some conversion time. Default False
chunks (4-D tuple of ints) – Shape of desired chunking in the form of (time, baseline, channel, polarization). Larger values reduce the number of chunks and speed up the reads at the cost of more memory. Chunk size is the product of the four numbers. Default is (400, 400, 64, 2). None disables re-chunking and returns native chunk size from table row reads
- Returns
Main xarray dataset of datasets for this visibility set
- Return type
xarray.core.dataset.Dataset
-
write_generic_table
(xds, outfile, subtable='', cols=None, verbose=False)[source]¶ Write generic xds contents back to casacore table format on disk
- Parameters
xds (xarray.Dataset) – Source xarray dataset data
outfile (str) – Destination filename (or parent main table if writing subtable)
subtable (str) – Name of the subtable being written, triggers special logic to add subtable to parent table. Default ‘’ for normal generic writes
cols (str or list) – List of cols to write. Default None writes all columns
-
write_main_table_slice
(xda, outfile, ddi, col, full_shape, starts)[source]¶ Write an xds row chunk to the corresponding main table slice
-
write_ms
(mxds, outfile, infile=None, subtables=False, modcols=None, verbose=False, execute=True)[source]¶ Write ms format xds contents back to casacore table format on disk
- Parameters
mxds (xarray.Dataset) – Source multi-xarray dataset (originally created by read_ms)
outfile (str) – Destination filename
infile (str) – Source filename to copy subtables from. Generally faster than reading/writing through mxds via the subtables parameter. Default None does not copy subtables to output.
subtables (bool) – Also write subtables from mxds. Default of False only writes mxds attributes that begin with xdsN to the MS main table. Setting to True will write all other mxds attributes to subtables of the main table. This is probably going to be SLOW! Use infile instead whenever possible.
modcols (list) – List of strings indicating what column(s) were modified (aka xds data_vars). Different logic can be applied to speed up processing when a data_var has not been modified from the input. Default None assumes everything has been modified (SLOW)
verbose (bool) – Whether or not to print output progress. Since writes will typically execute the DAG, if something is going to go wrong, it will be here. Default False
execute (bool) – Whether or not to actually execute the DAG, or just return it with write steps appended. Default True will execute it
-
visplot
(xda, axis=None, overplot=False, drawplot=True, tsize=250)[source]¶ Plot a preview of Visibility xarray DataArray contents
- Parameters
xda (xarray.core.dataarray.DataArray) – input DataArray to plot
axis (str or list or xarray.core.dataarray.DataArray) – Coordinate(s) within the xarray DataArray, or a second xarray DataArray to plot against. Default None uses range. All other coordinates will be maxed across dims
overplot (bool) – Overlay new plot on to existing window. Default of False makes a new window for each plot
drawplot (bool) – Display plot window. Should pretty much always be True unless you want to overlay things in a Jupyter notebook.
tsize (int) – target size of the preview plot (might be smaller). Default is 250 points per axis
- Returns
- Return type
Open matplotlib window
-
read_image
(infile, masks=True, history=True, chunks=(1000, 1000, 1, 4), verbose=False)[source]¶ Read casacore format Image to xarray Image Dataset format
- Parameters
infile (str) – Input image filename (.image or .fits format)
masks (bool) – Also read image masks as additional image data_vars. Default is True
history (bool) – Also read history log table. Default is True
chunks (4-D tuple of ints) – Shape of desired chunking in the form of (l, m, chan, pol). Default is (1000, 1000, 1, 4) Note: chunk size is the product of the four numbers (up to the actual size of the dimension)
- Returns
new xarray Datasets of Image data contents
- Return type
xarray.core.dataset.Dataset
-
write_image_slice
(xda, outfile, col, starts)[source]¶ Write image xda chunk to the corresponding image table slice
-
write_image
(xds, outfile, portion='IMAGE', masks=True, history=True, verbose=False, execute=True)[source]¶ Read casacore format Image to xarray Image Dataset format
- Parameters
xds (xarray.Dataset) – Image xarray dataset to write
outfile (str) – Output image filename (.image format)
portion (str) – Name of the data_var in the xds that corresponds to the image data. Default ‘IMAGE’
masks (bool) – Also write the masks to the output. Can be used instead of infile parameter. Default True
history (bool) – Also write the history log file to the output. Can be used instead of infile paramter. Default True
verbose (bool) – Whether or not to print output progress. Since writes will typically execute the DAG, if something is going to go wrong, it will be here. Default False
execute (bool) – Whether or not to actually execute the DAG, or just return it with write steps appended. Default True will execute it