casautil — CASA-dependent utilities module.

This module contains utility functions that rely on CASA.

admit.util.casautil.getdata(imgname, chans=[], zeromask=False)[source]

Return all good data from a CASA image as a masked numpy array.

The tb.open() access method, although faster, didn’t seem to carry the mask (or at least in an easy way). ma.masked_invalid(data) still returned all pixels ok.

NOTE: since this routine grabs all data in a single numpy array, this routine should only be used for 2D images or small 3D cubes, things with little impact on memory

Parameters:

imagename : str

The (absolute) CASA image filename

Returns:

array

data in a masked numpy array

admit.util.casautil.getdata1(imgname)[source]

Return all good data from a CASA image as a compressed 1D numpy array.

The tb.open() access method, although faster, didn’t seem to carry the mask (or at least in an easy way). ma.masked_invalid(data) still returned all pixels ok.

NOTE: since this routine grabs all data in a single numpy array, this routine should only be used for 2D images or small 3D cubes.

Parameters:

imagename : str

The (absolute) CASA image filename

Returns:

array

data in a 1D numpy array

admit.util.casautil.getdata_raw(imgname)[source]

Return data as a 2D numpy array For more detailed access to cubes, don’t use this method, as it will use all the memory. instead use ia.open() and getslice/putslice() to cycle through the cube. Note we’re not getting the mask this way.... see Moment_AT for a version that return a numpy.ma array with masking

See putdata(imgname,data) for the reverse operation, but you will need to create a clone of the image to ensure the header.

Parameters:

imagename : str

The (absolute) CASA image filename

Returns:

array

data in a 2D numpy array

admit.util.casautil.implot(rasterfile, figname, contourfile=None, plottype=5, plotmode=32, colorwedge=False, zoom=1)[source]

Wrapper for CASA’s imview, that will also create thumbnails.

Parameters:

rasterfile : str

Fully-qualified image file to use as raster map. Optional if contourfile is given.

figname : str

Fully-qualified output file name.

contourflie : str

Fully-qualified image file to use as contour map. Contours will be overlaid on rasterfile if both are given. Optional if rasterfile is given.

plottype : int

Plotting format, one of util.PlotControl plot type (e.g., PlotControl.PNG). Default: PlotControl.PNG

plotmode : int

Plot mode, one of util.PlotControl plot mode (e.g., PlotControl.INTERACTIVE). Default: PlotControl.BATCH

colorwedge : boolean

True - show color wedge, False - don’t show color wedge

zoom : int

Image zoom ratio.

Returns:

None

admit.util.casautil.iscasa(file)[source]

is a file a casa image

Returns:boolean
admit.util.casautil.mapdim(imgname, dim=None)[source]

Return the dimensionality of the map, or if dim is given.

Returns True if the dimensionality matches this value, or False if not.

Warning: opens and closes the map via ia.open()

Parameters:

imagename : str (a filename)

dim : integer (or None)

admit.util.casautil.parse_robust(robust)[source]

parse a compound robust=[‘algorithm’,optional_parameters...]

Within ADMIT we use robust=[] Within CASA we use a varargs type algorithm=,fence=,...

Parameters:

robust : list of robust parameters, method specific. See e.g. casa::imstat

Returns:

dict

A dictionary ready for **args inclusion in a CASA command. If none found, returns an empty dictionary.

admit.util.casautil.putdata_raw(imgname, data, clone=None)[source]

Store (overwrite) data in an existing CASA image. See getdata_raw(imgname) for the reverse operation.

Parameters:

imagename : str

The (absolute) CASA image filename. It should exist already, unless clone was given.

data : 2D numpy array or a list of 2D numpy arrays

The data...

clone : str, optional

An optional filename from which to clone the image for output. It needs to be an absolute filename.