mViewer and Python (beta)

Python mViewer: Basic Example

mViewer provides a great deal of functionality for presenting regions of the sky but the basis for it all is the dispay of a single FITS image in grayscale. While mViewer can be wrapped in any number of ways to support different user scenarios, we will focus on the raw underlying functionality.
    import astroMontage.mViewer as mv
    viewer = mv.mViewer()

    The Montage Python package can be downloaded as part of the Montage distribution available through GitHub: or, if you already have Montage installed, through PyPI. The latter route has the advantage of ensuring that any Python dependencies are also installed (an issue with some Python distributions).

    Example data can be downloaded here

Click image to view full resolution in a new tab.

There is a lot going on here behind the scenes. The mViewer object maintains the state of the view, which can be directly output to PNG or JPEG image files or can be used to drive an interactive display. This display is handled by a separate thread which contacts the user's browser and sets up two-way communication with a new window.

Because it is in a browser, we can augment the display with very complicated GUI constructs (in Javascript), though the basic use case is a simple minimal display filling the window. Because it is in a separate thread, user input through the browser (window resize, zooming, selecting image regions) can be processed in parallel with any user input via the Python prompt. Even the intial display is automatically resized to fit the display canvas and any time you resize the browser window the image adjusts to fit.

So independent of the command prompt, you can draw a zoom box on the displayed image, click for region statistics or click the zoom-reset icon in the lower right of the display.

mViewer does not have to be used with an interactive display. All of the images in these examples were created using a script which sent the image to a PNG file using the command "viewer.createImage('output.png', 1000)" (where 1000 is the size of the larger dimension of the output image).