| RXTE GOF |
Plotting with PLT Recipes from the RXTE Cook Book |
RXTE FAQ |
|---|
Introduction
In the course of your RXTE data reduction and analysis, you'll be plotting files using PGPLOT routines packaged together in a Fortran subroutine called PLT. This is the case whether you run the general plotting ftool fplot or the data analysis programs xspec and xronos. Here, we explain how to exploit the power of PLT to produce attractive plots tailored - we hope - to your needs.
This isn't really a set of recipes. Rather, it's a primer divided into sections that cover different aspects of PLT:
- Basic PLT Commands lists the most common commands entered at the PLT> prompt to change the appearance of a plot.
- Multi-Panel Plots, Vectors and Errors discusses how PLT deals with multi-y plots and lists more PLT commands, some of which can also be used with single-panel plots.
- More PLT Commands continues the listing of PLT commands.
- QDP, the Quick and Dandy Plotter, and PCO files describes QDP, a program for plotting ASCII files. It also explains PCO (Plot Command) files and some general issues about how PLT interprets data.
- Fitting in PLT explains the modest, but useful, model-fitting capabilities of PLT.
- PLT in Xspec: Some Idiosyncrasies
- PLT in Fplot: Some Idiosyncrasies
Two additional options are worth mentioning here. First, if you want to enter some PLT commands before sending the plot to a device, you can enter /null or > as the device. Second, if you want to change the device once inside PLT, use the "device" command (abbreviated to d) at the prompt:
PLT can plot up to nine quantities simultaneously against a tenth - either all in one large panel or in separate horizontal panels. The relevant PLT term here is vector which refers either to a single array of data or to a combination of data array and associated error array. By default, the first vector is used as the x-axis and the others are plotted against it.
To obtain a single-panel plot of all the vectors, the command p o, for plot overlay, is used.
Labelling works in the same way. For example, to label the y-axis of the top panel with "Elevation Angle":
As mentioned above, PLT is a Fortran subroutine called by programs like xspec and fplot which pass it arrays to plot. Another program that uses PLT is QDP, the Quick and Dandy Plotter. QDP is a handy program that drives PLT to plot ASCII files. As such, QDP can be thought of as the ASCII analogue of fplot which only plots FITS files.
To tell PLT which columns are errors and which are data, the header commands read serr and read terr are used:
serr for single-sided errors (one column of errors); terr for twin-sided errors (two columns of errors). Note that xronos, xspec and fplot take care of this automatically: you only need to insert these header commands into QDP files you create yourself.
Thus for the sample QDP file above, the following header commands can all be used and will have different effects:
Will create a three-vector plot, with the third and fifth columns being plotted against the first column. The errors for the first, third and fifth columns being the second, fourth and sixth columns, respectively.
Will create a three-vector plot, with the second and fourth columns being plotted against the first column. This time, the first column has no error bars; the second column has errors in the third column; while the fourth column has errors in the fifth and sixth columns.
Note that the programs like xspec and xronos that call PLT use their own internal PCO files. For example, when you plot a spectrum in xspec, PLT is called with a PCO file that labels the x-axis with "Energy (keV)".
There are other options: for help, type "help la #" at the PLT> prompt.
PLT contains a chi-squared minimization routine and a suite of simple models that can be used to fit your data. Models are defined with the mo command (mo ? will list the choices) and can be built up of more than one component. For example:
To initiate a fit, type "fit" followed by the number of the vector you want to fit. [Note that the fit will include only those x-values in the current window, i.e. the full range unless you rescaled the x-axis before the fit.] The screen output will look like something this:
Confidence ranges are obtained with the "fit err" command which takes, as its argument, the model parameter number. For example:
If you want to reset a parameter value, then use the "newpar" command.
Other fitting commands: "fit sub" will subtract the current model from the data to produce a new column of data; "wm" (for "write model") will create an ASCII file containing the current model and its parameters. You can read it back in with the "mo @" command, e.g.:
The spectral fitting program xspec uses internal, "pre-programmed" PCO files extensively. Whenever you type "plot data resids", for example, PLT is instructed to create two windows, one with the current model and data, the other with the residuals. In both cases, the x-axis, if energy not channels, is obtained from the EBOUNDS extension of the response file. Descriptive labels are added, including the path to the current data file in the filename position. Other things can be plotted; to see the list, type:
If you want to alter the appearance of an xspec plot, you should use the iplot command which will send a plot to the current device (set with the cpd command) and then give you a PLT> prompt at which you can enter any of the commands above. For "double" plots (e.g. iplot ldata chi) PLT is called twice and overlays two windows on top of one another. By default, the top window (usually the one with the data and model) is window-1, while the second (often with the residuals) is window-2. To work in window-1, type
Like xspec, the plotting ftool fplot uses internal, "pre-programmed" PCO files, though not as extensively. Here's a typical run:
Plotting Basics
/xw for XWindows
/xt for Xterm
/vt for Versaterm
/ps for PostScript
Setting the plot device initially occurs outside PLT and depends on the program driving it:
To see the full list of available devices type ?.
Device: /XWindow, /XTerm, /TK, /PS, etc[/XW] /xw
XSPEC> cpd /xw
Enter PGPLOT device[/XW] /xt
PLT> d /vt
PLT> r x 100 250
Rescaling the y-axis works in the same way; e.g. r y 0.8 1.2 will redraw the y-axis to run between 0.8 and 1. And if you want to combine both rescalings in one, command:
PLT> r 100 250 0.8 1.2
PLT> la x Time (MET in seconds)
You can put labels at these other locations in the same way:
top .. at the top of the plot, above the plot window
otop . over the top label
y .... on the y-axis
oy ... over the y-axis label
ox ... below the x-axis label
f .... at the default filename location (above the top left corner of
the plot window)
PLT> t off
The command t on will restore it.
PLT> vp 0.25 0.1 0.75 0.9
PLT> h hard_pulse.ps/ps
Please note the /ps which must be appended, without a space, to the name of the PostScript file. Alternatives to /ps comprise:
/PS (PostScript file, landscape orientation)
/VPS (PostScript file, portrait orientation)
/CPS (Colour PostScript file, landscape orientation)
/VCPS (Colour PostScript file, portrait orientation)
PLT> lw 3
for example, will make the lines three times thicker than the minimum, which is the default.
PLT> cs 1.5
will increase the size of text by 50 percent.
Multi-Panel Plots, Vectors and Errors
PLT> r y3 80 120
Note that these commands do not cause an automatic replot, unlike the case for r y and r x. To see the changes, just type p. You can rescale the x-axis either with r x or with r y1.
PLT> r y2 Elevation Angle
PLT> e off 2
PLT> ls ?
PGPLOT line styles are:
1=Solid, 2=Dash, 3=Dash-dot, 4=Dot, 5=Dash-dot-dot-dot
To make the top panel have a dotted line connecting the points, for example, type:
PLT> ls 3 on 2
PLT> li st on 2
PLT> ma 14 on 4
PLT> co 4 on 2
PLT> co off 3
PLT> p v
PLT> p
The final plot command is necessary because, by itself, p v doesn't send a plot to the device.
QDP, the Quick and Dandy Plotter, and PCO files
1.23 0.5 104 0.567 51.6 10.7
2.04 0.4 112 0.411 58.8 10.6
3.94 0.5 178 0.149 96.4 12.1
5.12 0.6 181 0.148 17.6 8.9
6.55 0.6 259 0.299 12.3 10.7
7.90 0.5 411 0.515 19.6 10.7
The default filename extension is .qdp.
read terr 3
x l -0.3107 0.05
read serr 1
12.39 4.0
11.09 3.8
7.79 3.4
. .
. .
. .
where, in this example, the phase of the first bin is -0.3107, and the step size of 0.05, i.e. 1/20, is chosen because the data were taken at regular phase intervals spanning one complete orbit.
la otop The Bursting Pulsar GRO J1744-27
la top RXTE PCA
la f PCUs 0-3, all layers combined
la y1 Time (seconds)
la oy1 16-s bins
la y2 Counts/s
t off
la ro
r y1 0 10000
PCO files, which have the default filename extension .pco, are invoked in PLT with an @ sign:
PLT> @burst
The same command can also be placed in a QDP file.
More PLT Commands
PLT> font roman
If you want a few characters to be in a different font, then use the \f flag followed by the first letter of the font name. For example, suppose all your characters are in Roman font, but you'd like the name of the spacecraft, as it appears on the filename label, to be in Italic. The corresponding commands would be:
PLT> font roman
PLT> la f \fiRossi X-ray Timing Explorer
PLT> la y3 \gG
PLT> la y4 \gr \fn(cm/3)
Note the use of the \fn flag to reset the font (to Normal) for the rest of the label.
PLT> la y \fiF\fn\d2-10 \u(erg cm\u-2\d s\u-1\d keV\u-1\d)
roughly corresponds to the TeX:
$F_{\rm 2--10}$ (erg cm$^{-1}$ s$^{-1}$ keV$^{-1}$)
PLT> la 1 p 6.4 12 "Iron Fluorescence"
The label command is followed first by a position number, in this case 1, which serves to identify it as a "position" label (as opposed to one of the standard labels) and to distinguish it from other position labels. The next part of the string, "p 6.4 12", contains the location of the center of the label: the first number is the x-coordinate in the same units as the x-axis and the second number is the
y-coordinate in the same units as the y-axis. Finally, comes the label itself enclosed in double quotation marks.
0 for the background
1 for the frame and labels
2 for the data themselves
The next three arguments are the normalized intensities (to unity) of the red, green and blue cathode ray tubes. For example, to change the background color to a deep purple:
PLT> sc 0 0.6 0 0.6
PLT> h hard_pulse.ps/ps
PLT> $ lpr hard_pulse.ps
will first create a PostScript file, then send it to the printer. If you want to execute more than one shell command, type $ without anything after it.
PLT> help ?
This will provide an entrance point for more information.
Fitting in PLT
PLT> mo const gauss
will define a model comprising a constant plus a Gaussian. After defining a model, you'll be prompted for the initial parameter values, like this:
PLT> mo co gaus
1 CO: VAL( 1.000 ), SIG( 0.0000E+00), PLO( 0.0000E+00), PHI( 0.0000E+00)?
10
2 GC: VAL( 1.000 ), SIG( 0.0000E+00), PLO( 0.0000E+00), PHI( 0.0000E+00)?
1700
3 GW: VAL( 1.000 ), SIG( 0.0000E+00), PLO( 0.0000E+00), PHI( 0.0000E+00)?
300
4 GN: VAL( 1.000 ), SIG( 0.0000E+00), PLO( 0.0000E+00), PHI( 0.0000E+00)?
10
where the user input in this example is emboldened. Here, only the initial values of the parameters have been specified, but it's also possible to fix the parameters and to set upper and lower limits. This is done by entering values for the other fields associated with each parameter. Setting SIG to -1 will fix a parameter, while setting PLO and PHI will constrain the range of the parameter during the fits to be no less than PLO and no greater than PHI.
PLT> fit 2
Fitting group 2, from 0.000E+00 to 3.000E+03
Fitting 187 points in a band of 187.
10.00000 1700.000 300.0000 10.00000
( -3) W-VAR=5.6675E+04
( -3) W-VAR=3.6336E+04
( -4) W-VAR= 7212.
( -5) W-VAR= 2779.
( -6) W-VAR= 283.4
( -7) W-VAR= 32.80
( -8) W-VAR= 32.74
-15.75922 1678.088 1096.758 92.64162
Here, the initial parameter values are shown, along with the fit iterations, then the final, best-fitting parameter values.
PLT> fit err 3
will calculate the 90-percent confidence range of the third fit parameter.
PLT> wm cdm.mod
.
.
.
PLT> mo @cdm.mod
PLT in Xspec: Some Idiosyncrasies
XSPEC> plot ?
PLT> win 1
before changing anything. Not specifying the window can sometimes lead to puzzling consequences. For example, if you label the top "Thermal model omitted" but don't see anything, it might be because the label, being associated with the residuals window, is actually covered by the data window.
PLT in Fplot: Some Idiosyncrasies
kaah[45]%
And here's some explanation:
If you have a question about RXTE, please send email to one of our
help desks.

