An example of combining contour plots

It is often useful to be able to superimpose contour plots based on multiple steppar or margin commands. This cannot be done within xspec but can be done by combining and editing files produced by xspec and plotting the result using qdp. This page describes an example case of combining the results of steppar commands for the same model but with two different spectra.

The model used was phabs(pow) and the datasets were file1.pha and file2.pha in the ftools/spectral/session directory. The steppar command was:

XSPEC12> steppar 1 8. 12. 25 2 1.2 1.5 25

and the files were written out using

XSPEC12> iplot contour
PLT> wenv test1

and

XSPEC12> iplot contour
PLT> wenv test2

respectively. This creates files test1.pco, test1.qdp, test2.pco, test2.qdp. The qdp files contain the data and the pco files the commands used to make the contour plots.

Making combined plot requires combining the qdp data files and writing a new pco file. So, copy test1.qdp into a new file:

cp test1.qdp testboth.qdp

Now open an editor and read in testboth.qdp. On the first line replace test1.pco with testboth.pco. Go to the end of the file and insert test2.qdp. The inserted data will start with the lines:

@test2.pco
!

Delete these and save the resulting file.

Now copy test1.pco into testboth.pco and open in an editor. If there are lines starting IMAG then delete them because they create the background image which will be confusing if multiple contours are being overplotted. The DG command is used to define data groups. The command

DG     1       1      1     26     26

tells qdp that the first data group is from columns 1 to 26 in rows 1 to 26. This is the data from test1.qdp. Since the data from test2.qdp were appended the second data group is defined using the command

DG     2      27      1     52     26

so this is added to the testboth.pco file. Finally take the CONT commands from test2.pco and add them to testboth.pco changing them all from CONT 1 to CONT 2. The color, style and width of the lines can be changed as necessary to distinguish the two sets of contours. To include a cross at the position of best fit for the second set of contours copy the LAB 1 command from test2.pco and change it to LAB 2. The resulting testboth.pco file will look something like:

LWIDTH   2.
COL  OFF 1..26
DG     1       1      1     26     26
LIne ON    1
LW   1.0 ON   1
LIne ON    2
LW   1.0 ON   2
CONT  1 LEVEL 82.6023636 84.9123611 89.5123596
CONT  1 COLOR       2       3       4
CONT  1 LSTYL       1       1       1
CONT  1  LWID       1       1       1
XAX  LIN  8 0.159999847
YAX  LIN 1.20000005 1.19999647E-2
LOC  0 0 1 1
LAB  1 COL 5
LAB  1 POS 9.86781979 1.31636 "+"
LAB  T  Confidence contours: Chi-Squared
LAB  X  Parameter: nH (10\u22\d)
LAB  Y  Parameter: PhoIndex
R    X1 8 12
R    Y1 1.20000005 1.5
DG     2     27      1     52     26
CONT  2 LEVEL 89.659462 91.9694595 96.569458
CONT  2 COLOR       2       3       4
CONT  2 LSTYL       2       2       2
CONT  2  LWID       1       1       1
LAB  2 POS 10.3893003 1.39174998 "+"

Now create the plot using

qdp testboth.qdp

combining contour plots (last edited 2018-06-29 19:05:46 by KeithArnaud)