next up previous contents index
Next: Index Up: Part III: Appendices Previous: E.14 Color Palettes

F Frequently Asked Questions

 

This Appendix presents many frequently asked questions about WIP and WIP commands. These questions have come from users from their usage of WIP. Hopefully, this list will address most of the questions that novice users may encounter and present solutions to problems that others may find useful as they become more experienced and attempt more complicated plots. Each topic will first present the problem or question and then a solution will begin following the `' character. This list of questions should also be the most volatile of the entire manual as more users submit questions and solutions to various problems.

Lack of Printer Output

 

When I run my plot file on my screen, everything looks great. But when I send it to the printer, nothing shows up. Here are the commands I execute:

     
%
wip

WIP>
input myfile.wip    # Plots okay on the screen.
WIP>
device myfile.ps/vps    # Get a printing device.
WIP>
input myfile.wip    # Play through the commands again.
WIP>
end    # All finished.
%
lpr myfile.ps

The light on the printer flashes for a few minutes and then stops and does not produce a plot. What's wrong?

Whenever you send a plot to a printing device, you should terminate the plot by using either the hardcopy  command or another call to the device  command. These commands inform the plot that there is not going to be any further information coming and it should insert device specific closing commands. In the case of the printing device `/vps' shown above, the commands that are inserted instruct the printer to print and eject the page it has been generating. Without these inserted commands, the plot file is (internally) read by the printer and then ignored because it is never told to eject the page.

An alternative to the example above is to use the phard  command. This command initiates a (temporarily) new, user specified device and then plays back all the commands issued and then performs the hardcopy command to close the plot file. The final operation of the phard command is to reinstate the device that was active when this command was called. To illustrate, the commands shown previously, can be replaced with the following:

     
%
wip

WIP>
input myfile.wip    # Plots okay on the screen.
WIP>
phard myfile.ps/vps    # Spool it to the printing device.
WIP>
end    # All finished.

If the print user variable has its default value, the plot will automatically be spooled to the printer.

Finally, this plot could also be sent by using the single command line:

%
wip -x -d myfile.ps/vps myfile.wip

See Appendix B for an explanation of the command line options and their meanings.

erase Command Troubles

 

I have a macro defined as follows:

           
WIP>
define doloop    # $1=Passed counter.

DEFINE>
erase    # Erase the screen.
DEFINE>
expand 0.5    # Initialize the expansion.
DEFINE>
set \0 -1    # Initialize a counter.
DEFINE>
loop 16 mymacro \0 $1    # Call another macro.
DEFINE>
end    # End of macro definition.

which I use to plot multi-page panel plots (panel  commands appear in mymacro macro). When I call this macro as follows:
   
WIP>
device myfile.ps/vps    # Set up the printer file.

WIP>
doloop 1    # Do the first page.
WIP>
hardcopy    # Send it to the printer.
WIP>
doloop 2    # Do the second page.
WIP>
hardcopy    # Send it to the printer.
WIP>
doloop 3    # Do the third page.
WIP>
hardcopy    # Send it to the printer.

I get the following error messages:
Trouble setting expand value.

Saving expand as 1.000000.
Trouble setting expand value.
Saving expand as 1.000000.

I am calling expand with a proper argument; what is wrong?

The error message is not so much to do with the macro, per say, as to what it is going on in the macro. Every time the command hardcopy is called, the device that was used to do the drawing is closed. However, the next command to be executed is to enter the macro again and the first "graphical command" is to set the expansion size. WIP checks that the requested expand size matches the returned value from PGPLOT. If the two do not match, a warning message is sent (which is the message that was displayed). Now, PGPLOT interprets erase commands as a new page request. For printing devices, this is basically the same as the hardcopy command except that it does not close the device. Because the macro doloop above has the erase command at the top of it, a suggested alternative to the commands above would be (the macros may stay the same):

   
WIP>
device myfile.ps/vps    # Set up the printer file.

WIP>
doloop 1    # Do the first page.
WIP>
doloop 2    # Do the second page.
WIP>
doloop 3    # Do the third page.
WIP>
hardcopy    # Send it to the printer.

The erase command will automatically switch to a new page of paper for hardcopy (printing) devices (and all drawing will appear in the same file) or erase the screen for interactive devices.

Offset Positions

 

I often need an offset to move away from my current position. Is there (or can there be) a command like ``shift'' that moves the pointer relative to the previous move or draw end position?

A general offset command would be quite difficult to create due to the possible range and direction of world coordinates. If you want a macro that would do it for a particular orientation and scale (e.g. RA/dec plots), consider the following macro definition:

               
WIP>
define doshift    # $1=delx; $2=dely.

DEFINE>
new offx offy    # Creates offx and offy.
DEFINE>
set offx cx + $1    # Set up x-offset.
DEFINE>
set offy cy + $2    # Set up y-offset.
DEFINE>
move offx offy    # Move to the offset position.
DEFINE>
free offx offy    # Release offx and offy.
DEFINE>
end

and commands:
   
WIP>
move 5000 50000    # Some command that sets position.

WIP>
doshift 30 300    # Shift the position.
WIP>
draw 5100 49000    # Another set position command.
WIP>
doshift 30 500    # Shift the position.

The move or draw commands could be folded into the doshift macro by adding another 3 arguments, as in:

                 
WIP>
define mdshift    # $1/2=delx/y; $3/4=x/y; $5=m/d.

DEFINE>
new offx offy    # Creates offx and offy.
DEFINE>
if (0$5 == 0) move $3 $4    # Move if ($5 == 0).
DEFINE>
if (0$5 == 1) draw $3 $4    # Draw if ($5 == 1).
DEFINE>
set offx cx + $1    # Set up x-offset.
DEFINE>
set offy cy + $2    # Set up y-offset.
DEFINE>
move offx offy    # Move to the offset position.
DEFINE>
free offx offy    # Release offx and offy.
DEFINE>
end

Then, you can use it as:
WIP>
mdshift 30 300 5000 50000 0

WIP>
mdshift 30 500 5100 49000 1

Writing Numbers as Text

 

I have been using WIP to make a macro for doing multi-panel plots with velocity labeling all automatically grabbed from the image header, or at least attempting to do so. I have made good progress but I am having trouble dealing with changing numbers into characters and having the various text writing command believe in text variables.  For example if I calculate the velocity of a channel in a macro, how do I load that value into a text variable and get it printed to the screen without doing it one symbol at a time?

This is illustrated in section E.7.

Box Label is Incorrect

 

I am trying to display an image with Right Ascension and Declination coordinates. When I use the command

 
WIP>
box bcnstz bcnstvz

with my image, the y-coordinate values appear incorrect. The header  command appears to be getting the parameters okay (using the `show i'  command).

What is happening is that the second argument to the box command is missing the y character. This character tells the time labeling routine not to break up the label at the 24 hour mark (i.e. do not do any day formatting). To correctly display declination, you must include both the y and the z character in the second argument to box. Another alternative is to include in the second argument the d option (and the h in the first argument) which will add unit superscripts. The d option implicitly implies the y option. For more details about these and other characters and what duties they perform, see Table 3.4.

FITS Images

 

I have loaded a FITS  image, retrieved the header, and displayed and boxed the image in WIP as follows:

       
WIP>
image myimage.fits

WIP>
header rd
WIP>
halftone
WIP>
box bcnsthz bcnstvdzy

No halftone is present and the box is label incorrectly. I have displayed this image in IRAF before making a FITS file with no problems; why can't WIP display it?

Some FITS image writers omit keywords. Make sure that the image header keywords required by WIP are present in the FITS image. In order to properly read header information and use it to display the coordinates with the box command, the optional header keywords should also be present. See the FITS image description in Section 5.1 for a list of required and requested keywords. Also see Section E.10 for a sample FITS header.

Fortran Callable

 

Is it possible to call various WIP routines from a Fortran program?

No. WIP is a collection of routines designed to act as a user interface to the PGPLOT graphics routines. Fortran programmers should call the individual PGPLOT routines directly.

Panel Movements with Images

 

I am using the panel command to display multiple images side by side. I want to have the individual boxes butt up against each other. However, every time I call panel with negative arguments (even after calling submargin 0 0), there is still a gap between the boxes.

This is dealt with in Section 5.3.

User Interaction with Prompts

 

This problem concerns writing instructions to users inside the WIP command window. For example, a macro allows the user to select where in a frame to place a label using the cursor. But, if this macro is to be generally usable, it really should write to the command window a message telling the user what the macro is expecting at each cursor prompt. Can this be done simply in WIP?

This is quite easy to do with the echo  command. The following simple macro shows how to prompt just before a cursor call.

             
WIP>
define doprompt    # $1-$0 used for the label.

DEFINE>
echo "Find the desired position"    # Prompt the user.
DEFINE>
echo "and then hit any key."
DEFINE>
cursor    # Move to the desired position.
DEFINE>
    # Put the label at the cursor position.
DEFINE>
label $1 $2 $3 $4 $5 $6 $7 $8 $9 $0
DEFINE>
end    # End of macro definition.

Overlapping Y-Axis Labels

 

When I chose vertical tick labels along the y-axis of the box, the y-axis text label overlaps them (especially if the numbers at a major tick interval is 3 or more digits).

Vertical labeling is a problem for large value coordinates (like declination). The default ylabel  command is actually an alias for the mtext  command. In fact, the following two commands are identical:

DEFINE>
mtext L 2.2 0.5 0.5 Yaxis label string

DEFINE>
ylabel Yaxis label string

To use labels along the y-axis without overlapping the tick labels, use the mtext command with a larger displacement (i.e. use 3 or 4 instead of 2.2). Also be careful to make sure that the left viewport value is large enough that it does not clip the tick labels.

Logarithmic Error Bars

 

I want to plot error bars on a log plot. Is there a simple way to do this? I've tried using the logarithm err command but can't seem to get it to work. Any suggestions?

Logarithmic plots with error bars is a bit tricky because the values in the ERR array are offset values rather than the actual error values. To solve this, either modify the data outside of WIP or write a macro to do the math internally. Examples of both are shown below. In both examples, it is assumed that the X, Y, and ERR data in data.lis are found in columns 1, 2, and 3, respectively. For UNIX users, the awk command:

%
awk '{print $0,($2+$3)/$2,$2/($2-$3)}' data.lis > d2.lis

will generate a new file called d2.lis which has the same contents as the old file plus new values in the fourth and fifth columns. Using d2.lis, the following WIP commands should work:
           
WIP>
data d2.lis

WIP>
xcolumn 1
WIP>
ycolumn 2
WIP>
ecolumn 4
WIP>
logarithm y
WIP>
logarithm err
WIP>
points
WIP>
errorbar 2
WIP>
ecolumn 5
WIP>
logarithm err
WIP>
errorbar 4

or, within WIP, one can use:
                 
WIP>
define eplus
DEFINE>
set $1 $1 + 1
DEFINE>
set err[$1] log((y[$1] + err[$1]) / y[$1])
DEFINE>
end
WIP>
define eminus
DEFINE>
set $1 $1 + 1
DEFINE>
set err[$1] log(y[$1] / (y[$1] - err[$1]))
DEFINE>
end
WIP>
data data.lis
WIP>
xcolumn 1
WIP>
ycolumn 2
WIP>
ecolumn 3
WIP>
set \0 0
WIP>
loop npts(err) eplus \0
WIP>
logarithm y
WIP>
points
WIP>
errorbar 2
WIP>
ycolumn 2
WIP>
ecolumn 3
WIP>
set \0 0
WIP>
loop npts(err) eminus \0
WIP>
logarithm y
WIP>
points
WIP>
errorbar 4

Aspect Ratio Without Images

 

I have tried to plot the spatial distribution of stars (i.e. dots on Right Ascension -- Declination plot) but I can't get the aspect ratio of the map right. The star positions are read in from a text file. I know that winadj    works for images but when I use it for a simple plot with individual points, it didn't seem to understand that the Right Ascension unit is 15 times smaller than the Declination unit. Am I missing something?

In order to get the spatial distribution correct, you will have to help WIP out. You are correct that WIP doesn't know that Right Ascension is about 15 times smaller than the Declination axis. This is because the world coordinate system   has no units associated with it. The best solution is use winadj with the spatial extent arguments provided in the same units. For example, if your plot runs in Right Ascension from to and Declination from to , you might use the following:

               
WIP>
set \1 (5 * 3600) + (37 * 60)
WIP>
set \2 (5 * 3600) + (29 * 60)
WIP>
set \3 -8 * 3600
WIP>
set \4 -5 * 3600
WIP>
set \5 (\1 - \2) * 15
WIP>
set \6 \4 - \3
WIP>
winadj 0 \5 0 \6
WIP>
limits \1 \2 \3 \4
WIP>
box bcnsthz bcnstvdzy

This will generate the proper 2:3 aspect ratio and also label the coordinates correctly.

Strange Hardcopy Output

 

Suppose I have two WIP plotting command files and do the following:

     
WIP>
input first.wip    # Plots out OK on the workstation.

WIP>
phard /ps    # Plots out OK on the PostScript printer.
WIP>
input second.wip    # Plots out OK on the workstation.
WIP>
phard /ps    # Plots both first and second figures!

Why does the second PostScript file contain both figures?

What you are actually getting out in the second PostScript file is the combination of both input commands. This is because the input command stays on the playback stack and the phard command plays back all commands on the stack. Hence, the second phard command will call input first.wip followed by input second.wip.

Changing the Number of Digits Displayed

 

I wish to do something quite simple: have a number like 1.234 (which is generated within a WIP macro) be part of a plot label. Is this possible? If so, there a way to control the number of significant figures for this purpose?

The answer to both questions is yes. Any label with the construct \[x] will actually be plotted as if the current value of the user variable x was used in the command. See Section 3.6 and Table 3.5 for more details on how to insert user variables in a text command.

To control the number of significant digits, change the value of the user variable nsig. By default, it is set to 3; specifying a larger value will cause more digits to be displayed.

Leaving Loops Early

 

Is it possible to break out of a loop command early (i.e. before the total number of iterations are reached) based on some condition within that macro?

The only way to do this is (not very elegant) to add a conditional to the macro and have the macro exit when the condition is met. This will still mean the macro is called the requested number of times, but each time it is called with the counter greater than the conditional value, it will just exit. A trivial example follows that will only print out the first ten numbers even though the loop is being executed twenty times:

                     
WIP>
define dummy    # $1=counter.

DEFINE>
set $1 $1 + 1    # Increment the counter.
DEFINE>
if ($1 > 10) end    # Exit if condition is true.
DEFINE>
echo $1    # Write out the current value.
DEFINE>
end    # End the macro definition.
WIP>
set \0 0    # Initialize the counter.
WIP>
loop 20 dummy \0    # Loop through the macro.



next up previous contents index
Next: Index Up: Part III: Appendices Previous: E.14 Color Palettes



morgan@astro.umd.edu