View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Graphics Overlay from Non-IRAF Tasks (repost)

Mike Fitzpatrick wrote on May 29, 1998


> I would like to be able to plot a contour which was created using
> PGplot over a 2 dimensional image.  I haven't found any IRAF tasks
> that would easily do this.  I have only seen the newcont and disconlab
> tasks which create their own contours, but I want to use my own.
> Is there a task for overplotting my contour?

        PGPLOT supports a number of output options, unfortunately these do
not include IRAF images or the image display itself.  There are also no
tasks that can use the PGPLOT output formats directly to overlay, but I
can still think of a few ways to do what you want.
        The most general way for PGPLOT or any other system is to somehow
rasterize the plot and convert it to an image IRAF can use.  For example,
you could use the GIF output option from PGPLOT to render the plot as a
2-color GIF file, then use the IMPORT task to convert this to a pixel mask
you would use as an overlay.  Specifically, something like:

    1)  Run your pgplot program with "/GIF" as the output, producing 
        a file called 'pgplot.gif'
    2)  In the CL rasterize and display the plot using

            cl> import pgplot.gif pgplot.pl format=gif
            cl> display imname 1 overlay=pgplot.pl

The import command converts the pgplot GIF file to a pixel mask you can
display automatically using the DISPLAY task 'overlay' parameter.  The
tricky part here is getting the plot and the image to overlap correctly,
the plot viewport (the area within the plot axes) must be the same size as
the image in the display frame buffer.  The easiest way to do this is to
adjust the pgplot task so the viewport fills the whole window and sets the
output size to be the size of the image you want to overlay, you would not
put axis labels on the contour plot.  Using labels isn't impossible, just
more difficult,  if you really want then you could use the pgplot
contours, but run WCSLAB once it's all displayed to draw the labels.
        If you used the PGCONX procedure in your task then this procedure
accepts a user function to draw the contour.  I haven't tried this but it
may be possible to write a function which uses the Client Display Library
(CDL, available from our /iraf/x11iraf archive directory) to draw each
line segment directly to the display.  Similarly if you've got your own
contour algorithm you can replace the pgplot calls with CDL ones to draw
to the display.  This method isn't very efficient for complex graphics
though because of the overhead involved but might work.
        The first method above is more efficient and you can do something
similar for just about any plot.  As long as you can display the plot on
the screen (e.g. an EPS file displayed with Ghostview, some format
displayed with XV, etc) and scale it to be the same size as the image you
want to overlay, you can use tools like snapshot, XV, xwd, etc to save the
display window to a disk image.  Then use the import/display trick above
to draw it to the display, then use the TVMARK task to save this back to a
new IRAF image.

Mike Fitzpatrick

Last post on May 29, 1998