casagui.bokeh.sources._image_pipe

Implementation of ImagePipe class which provides a websockets implementation for CASA images which allows for interacitve display of image cube channels in response to user input.

Module Contents

Classes

ImagePipe

The ImagePipe allows for updates to Bokeh plots from a CASA or CNGI

class casagui.bokeh.sources._image_pipe.ImagePipe(image, *args, mask=None, stats=False, **kwargs)

The ImagePipe allows for updates to Bokeh plots from a CASA or CNGI

image. This is done using a websocket. A ImagePipe is created with the path to the image, and then it is used as the input to an ImageDataSource or a SpectraDataSource. This allows a single CASA or CNGI imge to be opened once and shared among multiple Bokeh plots, for example ploting an image channel and a plot of a spectrum from the image cube.

address

the string is the IP address for the network that should be used and the integer is the port number, see casagui.utils.find_ws_address

Type:

tuple of string and int

init_script

this javascript is run when this DataPipe object is initialized. init_script is used to run caller JavaScript which needs to be run at initialization time. This is optional and does not need to be set.

Type:

JavaScript

stokes_labels()

Returns stokes plane labels

channel(index, pixel_type)

Retrieve one channel from the image cube. The index should be a two element list of integers. The first integer is the ‘’stokes’’ axis in the image cube. The second integer is the ‘’channel’’ axis in the image cube.

Parameters:
  • index ([ int, int ]) – list containing first the ‘’stokes’’ index and second the ‘’channel’’ index

  • pixel_type (numpy type) – the numpy type for the pixel elements of the returned channel

have_mask0()

Check to see if the synthesis imaging ‘mask0’ mask exists

Returns:

‘’True’’ if the cube contains an internal ‘’mask0’’ mask otherwise ‘’False’’

Return type:

bool

mask0(index)

Within the image, there can be an arbitrary number of INTERNAL masks. They can have arbitrary names. The synthesis imaging module uses a mask named ‘mask0’. This mask is used in processing (it MAY represent the beam).

Parameters:

index ([ int, int ]) – list containing first the ‘’stokes’’ index and second the ‘’channel’’ index

have_mask()

Check to see if a mask exists.

Returns:

‘’True’’ if a mask cube is available otherwise ‘’False’’

Return type:

bool

mask(index, modify=False)

Retrieve one channel mask from the mask cube. The index should be a two element list of integers. The first integer is the ‘’stokes’’ axis in the image cube. The second integer is the ‘’channel’’ axis in the image cube.

Parameters:
  • index ([ int, int ]) – list containing first the ‘’stokes’’ index and second the ‘’channel’’ index

  • modify (boolean) – If true, it implies that the channel mask is being retrieved for modification and updating the channel on disk. If false, it implies that the channel mask is being retrieved for display.

put_mask(index, mask)

Replace one channel mask with the mask specified as the second parameter. The index should be a two element list of integers. The first integer is the ‘’stokes’’ axis in the image cube. The second integer is the ‘’channel’’ axis in the image cube. The assumption is that the mask parameter was retrieved from the mask cube using the mask(...) function with the modify parameter set to True.

Parameters:
  • index ([ int, int ]) – list containing first the ‘’stokes’’ index and second the ‘’channel’’ index

  • mask (numpy.ndarray) – two dimensional array to replace the existing mask for the channel specified by index

spectrum(index, mask=False)

Retrieve one spectrum from the image cube. The index should be a three element list of integers. The first integer is the ‘’right ascension’’ axis, the second integer is the ‘’declination’’ axis, and the third integer is the ‘’stokes’’ axis.

Parameters:

index ([ int, int, int ]) – list containing first the ‘’right ascension’’, the ‘’declination’’ and the ‘’stokes’’ axis

statistics_config(use_mask=None)

Configure the behavior of the statistics function. use_mask indicates that if a mask is available, the statistics should be based upon the portion of the image included in the mask instead of the whole channel.

statistics(index)

Retrieve statistics for one channel from the image cube. The index should be a two element list of integers. The first integer is the ‘’stokes’’ axis in the image cube. The second integer is the ‘’channel’’ axis in the image cube.

Parameters:

index ([ int, int ]) – list containing first the ‘’stokes’’ index and second the ‘’channel’’ index

histogram(index)

Calculate histogram (Bokeh Quad) extents for update of colormap adjuster (or anything else that wants a histogram of image intensities.

Parameters:

index ([ int, int ]) – list containing first the ‘’stokes’’ index and second the ‘’channel’’ index