DisplayDev module

displaydev.py: Interact with IRAF-compatible image display

Modeled after the NOAO Client Display Library (CDL)

Public functions:

readCursor(sample=0)
Read image cursor position
open(imtdev=None)

Open a connection to the display server. This is called automatically by readCursor if the display has not already been opened, so it is not generally necessary for users to call it.

See the open doc string for info on the imtdev argument, which allows various forms of socket and network connections.

close()
Close the active display server. Called automatically on exit.

Various classes are defined for the different connections (ImageDisplay, ImageDisplayProxy, UnixImageDisplay, InetImageDisplay, FifoImageDisplay). They should generally be created using the _open factory function. This could be used to maintain references to multiple display servers.

Ultimately more functionality may be added to make this a complete replacement for CDL.

$Id$

class stsci.numdisplay.displaydev.FifoImageDisplay(infile, outfile)

FIFO version of image display

_write(s)

Write string s to image display

Raises IOError on failure

class stsci.numdisplay.displaydev.ImageDisplay

Interface to IRAF-compatible image display

_read(n)

Read n bytes from image display and return as string

Raises IOError on failure. If a Tkinter widget exists, runs a Tk mainloop while waiting for data so that the Tk widgets remain responsive.

_write(s)

Write string s to image display

Raises IOError on failure

_writeHeader(tid, subunit, thingct, x, y, z, t)

Write request to image display

close(os_close=<built-in function close>)

Close image display connection

eraseFrame()

Sends commands to erase active frame.

getConfigno(stdname)

Determine which config number matches specified frame buffer name.

readCursor(sample=0)

Read image cursor value for this image display

Return immediately if sample is true, or wait for keystroke if sample is false (default). Returns a string with x, y, frame, and key.

readData(x, y, pix)

Reads data from x,y position in active frame.

readInfo()

Read tx and ty from active frame of display device.

readWCS(wcsinfo)

Reads WCS information from active frame of display device.

selectFB(nx, ny, reset=None, useiraf=True)

Select the frame buffer that best matches the input image size.

setCursor(x, y, wcs)

Moves cursor to specified position in frame.

setFBconfig(fbnum, bufname=None)

Set the frame buffer values for the given frame buffer name.

setFrame(frame_num=1)

Sets the active frame in frame buffer to specified value.

syncWCS(wcsinfo)

Update WCS to match frame buffer being used.

writeData(x, y, pix)

Writes out image data to x,y position in active frame.

writeImage(pix, wcsinfo)

Write out image to display device in 32Kb sections.

writeWCS(wcsinfo)

Writes out WCS information for frame to display device.

class stsci.numdisplay.displaydev.ImageDisplayProxy(imtdev=None)

Interface to IRAF-compatible image display

This is a proxy to the actual display that allows retries on failures and can switch between display connections.

checkDisplay()

Returns True if a valid connection to a display device is found, False if no connection could be found.

close()

Close active image display connection

open(imtdev=None)

Open image display connection, closing any active connection

readCursor(sample=0)

Read image cursor value for the active image display

Return immediately if sample is true, or wait for keystroke if sample is false (default). Returns a string with x, y, frame, and key. Opens image display if necessary.

class stsci.numdisplay.displaydev.InetImageDisplay(port, hostname=None)

INET socket version of image display

class stsci.numdisplay.displaydev.UnixImageDisplay(filename, family=<AddressFamily.AF_UNIX: 1>, type=<SocketKind.SOCK_STREAM: 1>)

Unix socket version of image display

close()

Close image display connection

stsci.numdisplay.displaydev._open(imtdev=None)

Open connection to the image display server

This is a factory function that returns an instance of the ImageDisplay class for the specified imtdev. The default connection if no imtdev is specified is given in the environment variable IMTDEV (if defined) or is “unix:/tmp/.IMT%d”. Failing that, a connection is attempted on the /dev/imt1[io] named fifo pipes.

The syntax for the imtdev argument is <domain>:<address> where <domain> is one of “inet” (internet tcp/ip socket), “unix” (unix domain socket) or “fifo” (named pipe). The form of the address depends upon the domain, as illustrated in the examples below.

inet:5137                  Server connection to port 5137 on the local
                           host.  For a client, a connection to the
                           given port on the local host.

inet:5137:foo.bar.edu      Client connection to port 5137 on internet
                           host foo.bar.edu.  The dotted form of address
                           may also be used.

unix:/tmp/.IMT212          Unix domain socket with the given pathname
                           IPC method, local host only.

fifo:/dev/imt1i:/dev/imt1o FIFO or named pipe with the given pathname.
                           IPC method, local host only.  Two pathnames
                           are required, one for input and one for
                           output, since FIFOs are not bidirectional.
                           For a client the first fifo listed will be
                           the client's input fifo; for a server the
                           first fifo will be the server's output fifo.
                           This allows the same address to be used for
                           both the client and the server, as for the
                           other domains.

The address field may contain one or more “%d” fields. If present, the user’s UID will be substituted (e.g. “unix:/tmp/.IMT%d”).